X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fopengl%2Fr_map.pas;h=35445c35fe00b08ecc51ec8ecbada997370e29ed;hb=d581025b391fdf3b429d362f4b1a94e1f6e53413;hp=50d06d03c88d3cf55380a11864f44df446fb4754;hpb=3a76b7e2235c387754facfcccd6e4de45f36a460;p=d2df-sdl.git diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas index 50d06d0..35445c3 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, utils, - 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 ; @@ -46,6 +54,31 @@ implementation 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 @@ -151,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(); @@ -210,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, 0, Mirror, False); + 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; @@ -273,7 +287,7 @@ end; h := RenTextures[Texture].Height; for xx := 0 to p.Width div w - 1 do for yy := 0 to p.Height div h - 1 do - r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, p.X + xx * w, p.Y + yy * h, TMirrorType.None); + r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, p.X + xx * w, p.Y + yy * h, p.Alpha, TMirrorType.None, p.Blending); end end else @@ -361,4 +375,9 @@ end; end end; + procedure r_Map_Update; + begin + FlagAnim.Update + end; + end.