X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_game.pas;h=73e6b28e6221babfb08549a07202ca96ac9f1bf9;hb=7d312543a62c1a290f329110d16835c9065f0147;hp=693798382f8943bdb8cfbf2858d7fca05e9e4af8;hpb=2249a689b020a4e0d2860e58eafde84010e8f3f4;p=d2df-sdl.git diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 6937983..73e6b28 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -341,6 +341,7 @@ procedure g_ResetDynlights (); var lnum, idx: Integer; begin + if not gwin_has_stencil then begin g_dynLightCount := 0; exit; end; lnum := 0; for idx := 0 to g_dynLightCount-1 do begin @@ -367,6 +368,7 @@ end; procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single); begin + if not gwin_has_stencil then exit; if g_dynLightCount = length(g_dynLights) then SetLength(g_dynLights, g_dynLightCount+1024); g_dynLights[g_dynLightCount].x := x; g_dynLights[g_dynLightCount].y := y; @@ -381,6 +383,7 @@ end; procedure g_DynLightExplosion (x, y, radius: Integer; r, g, b: Single); begin + if not gwin_has_stencil then exit; if g_dynLightCount = length(g_dynLights) then SetLength(g_dynLights, g_dynLightCount+1024); g_dynLights[g_dynLightCount].x := x; g_dynLights[g_dynLightCount].y := y; @@ -394,6 +397,7 @@ begin Inc(g_dynLightCount); end; + type TEndCustomGameStat = record PlayerStat: TPlayerStatArray; @@ -1361,16 +1365,19 @@ begin end; // HACK: add dynlight here - if e_KeyPressed(IK_F8) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then - begin - g_playerLight := true; - end; - if e_KeyPressed(IK_F9) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then + if gwin_k8_enable_light_experiments then begin - g_playerLight := false; + if e_KeyPressed(IK_F8) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then + begin + g_playerLight := true; + end; + if e_KeyPressed(IK_F9) and gGameOn and (not gConsoleShow) and (g_ActiveWindow = nil) then + begin + g_playerLight := false; + end; end; - if (g_playerLight) then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6); + if gwin_has_stencil and g_playerLight then g_AddDynLight(plr.GameX+32, plr.GameY+40, 128, 1, 1, 0, 0.6); end; procedure g_Game_Update(); @@ -2601,29 +2608,27 @@ begin glTranslatef(-x, -y, 0); - g_Map_BuildPVP(sX, sY, sX+sWidth-1, sY+sHeight-1); - g_Map_DrawPanels(PANEL_BACK); - g_Map_DrawPanels(PANEL_STEP); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_BACK); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_STEP); g_Items_Draw(); g_Weapon_Draw(); g_Player_DrawShells(); g_Player_DrawAll(); g_Player_DrawCorpses(); - g_Map_DrawPanels(PANEL_WALL); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WALL); g_Monsters_Draw(); - g_Map_DrawPanels(PANEL_CLOSEDOOR); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_CLOSEDOOR); g_GFX_Draw(); g_Map_DrawFlags(); - g_Map_DrawPanels(PANEL_ACID1); - g_Map_DrawPanels(PANEL_ACID2); - g_Map_DrawPanels(PANEL_WATER); - g_Map_DrawPanels(PANEL_FORE); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID1); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID2); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WATER); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_FORE); if g_debug_HealthBar then begin g_Monsters_DrawHealth(); g_Player_DrawHealth(); end; - g_Map_ResetPVP(); glPopMatrix(); end; @@ -2719,24 +2724,24 @@ begin glTranslatef(a, b+p.IncCam, 0); - g_Map_BuildPVP(sX, sY, sX+sWidth-1, sY+sHeight-1); - - g_Map_DrawPanels(PANEL_BACK); - g_Map_DrawPanels(PANEL_STEP); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_BACK); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_STEP); g_Items_Draw(); g_Weapon_Draw(); g_Player_DrawShells(); g_Player_DrawAll(); g_Player_DrawCorpses(); - g_Map_DrawPanels(PANEL_WALL); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WALL); g_Monsters_Draw(); - g_Map_DrawPanels(PANEL_CLOSEDOOR); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_CLOSEDOOR); g_GFX_Draw(); g_Map_DrawFlags(); - g_Map_DrawPanels(PANEL_ACID1); - g_Map_DrawPanels(PANEL_ACID2); - g_Map_DrawPanels(PANEL_WATER); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID1); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID2); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WATER); + //TODO: lights should be in separate grid, i think + // but on the other side: grid may be slower for dynlights, as their lifetime is short if gwin_has_stencil and (g_dynLightCount > 0) then begin // setup OpenGL parameters @@ -2753,10 +2758,15 @@ begin ly := g_dynLights[lln].y; lrad := g_dynLights[lln].radius; if lrad < 3 then continue; + + if lx-sX+lrad < 0 then continue; + if ly-sY+lrad < 0 then continue; + if lx-sX-lrad >= gPlayerScreenSize.X then continue; + if ly-sY-lrad >= gPlayerScreenSize.Y then continue; + // set scissor to optimize drawing glScissor((lx-sX)-lrad+2, gPlayerScreenSize.Y-(ly-sY)-lrad-1+2, lrad*2-4, lrad*2-4); - // clear stencil buffer - //glClear(GL_STENCIL_BUFFER_BIT); //!!! + // no need to clear stencil buffer, light blitting will do it for us glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // draw extruded panels glDisable(GL_TEXTURE_2D); @@ -2765,7 +2775,6 @@ begin if (lrad > 4) then g_Map_DrawPanelShadowVolumes(lx, ly, lrad); // render light texture glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer - //glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // draw light, and clear stencil buffer // blend it glEnable(GL_BLEND); @@ -2789,7 +2798,7 @@ begin glScissor(0, 0, sWidth, sHeight); end; - g_Map_DrawPanels(PANEL_FORE); + g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_FORE); if g_debug_HealthBar then begin g_Monsters_DrawHealth(); @@ -2819,7 +2828,6 @@ begin } glPopMatrix(); - g_Map_ResetPVP(); p.DrawPain(); p.DrawPickup();