X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fopengl%2Fr_map.pas;h=b3efdc30be82fd2df53e77538f05631c83c185fb;hb=f9982f4e6fd7f5d7cd3b09ee1ebb01d5f06e6e8a;hp=7cb4263764ba7b37031ecaff219eafb5541d224e;hpb=dc37333a08186fc9d9ceffb8b7a0b49534fcf5ee;p=d2df-sdl.git diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas index 7cb4263..b3efdc3 100644 --- a/src/game/opengl/r_map.pas +++ b/src/game/opengl/r_map.pas @@ -19,9 +19,17 @@ interface uses g_panel, MAPDEF; // TPanel, TDFColor + procedure r_Map_Initialize; + procedure r_Map_Finalize; + + procedure r_Map_Load; + procedure r_Map_Free; + procedure r_Map_LoadTextures; + procedure r_Map_FreeTextures; + + procedure r_Map_Update; - procedure r_Map_DrawBack (dx, dy: Integer); procedure r_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor); // unaccelerated procedure r_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer); procedure r_Map_DrawPanelShadowVolumes (lightX: Integer; lightY: Integer; radius: Integer); @@ -34,8 +42,8 @@ implementation uses {$INCLUDE ../nogl/noGLuses.inc} - SysUtils, Classes, Math, e_log, wadreader, CONFIG, - r_graphics, r_animations, r_textures, + SysUtils, Classes, Math, e_log, wadreader, CONFIG, utils, g_language, + r_graphics, r_animations, r_textures, g_textures, g_base, g_basic, g_game, g_options, g_map ; @@ -44,7 +52,33 @@ implementation RenTextures: array of record ID: DWORD; Width, Height: WORD; + Anim: Boolean; end; + FlagFrames: array [FLAG_RED..FLAG_BLUE] of DWORD; + FlagAnim: TAnimationState; + + procedure r_Map_Initialize; + begin + FlagAnim := TAnimationState.Create(True, 8, 5); + end; + + procedure r_Map_Finalize; + begin + FlagAnim.Free; + FlagAnim := nil; + end; + + procedure r_Map_Load; + begin + g_Frames_CreateWAD(@FlagFrames[FLAG_RED], 'FRAMES_FLAG_RED', GameWAD + ':TEXTURES\FLAGRED', 64, 64, 5, False); + g_Frames_CreateWAD(@FlagFrames[FLAG_BLUE], 'FRAMES_FLAG_BLUE', GameWAD + ':TEXTURES\FLAGBLUE', 64, 64, 5, False); + end; + + procedure r_Map_Free; + begin + g_Frames_DeleteByName('FRAMES_FLAG_RED'); + g_Frames_DeleteByName('FRAMES_FLAG_BLUE'); + end; procedure r_Map_LoadTextures; const @@ -67,9 +101,11 @@ implementation SetLength(RenTextures, n); for i := 0 to n - 1 do begin + // e_LogWritefln('r_Map_LoadTextures: -> [%s] :: [%s]', [Textures[i].FullName, Textures[i].TextureName]); RenTextures[i].ID := LongWord(TEXTURE_NONE); RenTextures[i].Width := 0; RenTextures[i].Height := 0; + RenTextures[i].Anim := False; case Textures[i].TextureName of TEXTURE_NAME_WATER: RenTextures[i].ID := LongWord(TEXTURE_SPECIAL_WATER); TEXTURE_NAME_ACID1: RenTextures[i].ID := LongWord(TEXTURE_SPECIAL_ACID1); @@ -82,7 +118,7 @@ implementation begin if WAD.GetResource(ResName, ResData, ResLen, log) then begin - if Textures[i].Anim then + if IsWadData(ResData, ResLen) then begin WADz := TWADFile.Create(); if WADz.ReadMemory(ResData, ResLen) then @@ -105,7 +141,9 @@ implementation begin if WADz.GetResource('TEXTURES/' + TextureResource, ReszData, ReszLen) then begin - if not g_Frames_CreateMemory(@RenTextures[i].ID, '', ReszData, ReszLen, Width, Height, FramesCount, BackAnim) then + if g_Frames_CreateMemory(@RenTextures[i].ID, '', ReszData, ReszLen, Width, Height, FramesCount, BackAnim) then + RenTextures[i].Anim := True + else e_LogWritefln('r_Map_LoadTextures: failed to create frames object (%s)', [Textures[i].FullName]); FreeMem(ReszData) end @@ -146,6 +184,11 @@ implementation end end; + procedure r_Map_FreeTextures; + begin + // TODO + end; + procedure dplClear (); begin if (gDrawPanelList = nil) then gDrawPanelList := TBinHeapPanelDraw.Create() else gDrawPanelList.clear(); @@ -205,52 +248,28 @@ begin it.release(); end; -procedure r_Map_DrawBack(dx, dy: Integer); -begin - if gDrawBackGround and (BackID <> DWORD(-1)) then - e_DrawSize(BackID, dx, dy, 0, False, False, gBackSize.X, gBackSize.Y) - else - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); -end; - -procedure r_Map_DrawFlags(); -var - i, dx: Integer; - Mirror: TMirrorType; -begin - if gGameSettings.GameMode <> GM_CTF then - Exit; - - for i := FLAG_RED to FLAG_BLUE do - with gFlags[i] do - if State <> FLAG_STATE_CAPTURED then + procedure r_Map_DrawFlags; + var i, dx: Integer; Mirror: TMirrorType; f: PFlag; + begin + if gGameSettings.GameMode = GM_CTF then + begin + for i := FLAG_RED to FLAG_BLUE do begin - if State = FLAG_STATE_NONE then - continue; - - if Direction = TDirection.D_LEFT then - begin - Mirror := TMirrorType.Horizontal; - dx := -1; - end - else - begin - Mirror := TMirrorType.None; - dx := 1; - end; - - r_Animation_Draw(Animation, Obj.X + dx, Obj.Y + 1, Mirror); - - if g_debug_Frames then + f := @gFlags[i]; + if not (f.State in [FLAG_STATE_NONE, FLAG_STATE_CAPTURED]) then begin - e_DrawQuad(Obj.X+Obj.Rect.X, - Obj.Y+Obj.Rect.Y, - Obj.X+Obj.Rect.X+Obj.Rect.Width-1, - Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1, - 0, 255, 0); - end; - end; -end; + if f.Direction = TDirection.D_LEFT then + Mirror := TMirrorType.Horizontal + else + Mirror := TMirrorType.None; + dx := IfThen(f.Direction = TDirection.D_LEFT, -1, +1); + r_AnimationState_Draw(FlagFrames[i], FlagAnim, f.Obj.X + dx, f.Obj.Y + 1, Mirror); + if g_debug_Frames then + e_DrawQuad(f.Obj.X + f.Obj.Rect.X, f.Obj.Y + f.Obj.Rect.Y, f.Obj.X + f.Obj.Rect.X + f.Obj.Rect.Width - 1, f.Obj.Y + f.Obj.Rect.Y + f.Obj.Rect.Height - 1, 0, 255, 0) + end + end + end + end; procedure r_Panel_Draw (constref p: TPanel; hasAmbient: Boolean; constref ambColor: TDFColor); var xx, yy: Integer; NoTextureID, TextureID, FramesID: DWORD; NW, NH: Word; Texture: Cardinal; IsAnim: Boolean; w, h: Integer; @@ -258,7 +277,7 @@ end; if {p.Enabled and} (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then begin Texture := p.TextureIDs[p.FCurTexture].Texture; - IsAnim := p.TextureIDs[p.FCurTexture].Anim; + IsAnim := RenTextures[Texture].Anim; if IsAnim then begin if p.TextureIDs[p.FCurTexture].AnTex <> nil then @@ -332,10 +351,9 @@ end; if radius < 4 then exit; if p.Enabled and (p.FCurTexture >= 0) and (p.Width > 0) and (p.Height > 0) and (p.Alpha < 255) {and g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then begin - if not p.TextureIDs[p.FCurTexture].Anim then + Texture := p.TextureIDs[p.FCurTexture].Texture; + if not RenTextures[Texture].Anim then begin - Texture := p.TextureIDs[p.FCurTexture].Texture; - // case Textures[Texture].TextureID of case RenTextures[Texture].ID of LongWord(TEXTURE_SPECIAL_WATER): exit; LongWord(TEXTURE_SPECIAL_ACID1): exit; @@ -357,4 +375,9 @@ end; end end; + procedure r_Map_Update; + begin + FlagAnim.Update + end; + end.