diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index c56bc488529fa761b9efd506474c5e4ffc26ad73..36b1016abb6720dab7e7006448c8ef2ad7e966c5 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*)
-{$MODE DELPHI}
+{$INCLUDE g_amodes.inc}
unit g_game;
interface
unit g_game;
interface
var
lnum, idx: Integer;
begin
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
lnum := 0;
for idx := 0 to g_dynLightCount-1 do
begin
procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
begin
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;
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;
procedure g_DynLightExplosion (x, y, radius: Integer; r, g, b: Single);
begin
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;
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;
Inc(g_dynLightCount);
end;
Inc(g_dynLightCount);
end;
+
type
TEndCustomGameStat = record
PlayerStat: TPlayerStatArray;
type
TEndCustomGameStat = record
PlayerStat: TPlayerStatArray;
end;
// HACK: add dynlight here
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
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;
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();
end;
procedure g_Game_Update();
glTranslatef(-x, -y, 0);
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_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_Monsters_Draw();
- g_Map_DrawPanels(PANEL_CLOSEDOOR);
+ g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_CLOSEDOOR);
g_GFX_Draw();
g_Map_DrawFlags();
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;
if g_debug_HealthBar then
begin
g_Monsters_DrawHealth();
g_Player_DrawHealth();
end;
- g_Map_ResetPVP();
glPopMatrix();
end;
glPopMatrix();
end;
glTranslatef(a, b+p.IncCam, 0);
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_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_Monsters_Draw();
- g_Map_DrawPanels(PANEL_CLOSEDOOR);
+ g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_CLOSEDOOR);
g_GFX_Draw();
g_Map_DrawFlags();
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);
- if g_debug_HealthBar then
- begin
- g_Monsters_DrawHealth();
- g_Player_DrawHealth();
- end;
+ 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
glStencilMask($FFFFFFFF);
glStencilFunc(GL_ALWAYS, 0, $FFFFFFFF);
glEnable(GL_STENCIL_TEST);
if gwin_has_stencil and (g_dynLightCount > 0) then
begin
// setup OpenGL parameters
glStencilMask($FFFFFFFF);
glStencilFunc(GL_ALWAYS, 0, $FFFFFFFF);
glEnable(GL_STENCIL_TEST);
- //!glEnable(GL_SCISSOR_TEST);
- //glClear(GL_STENCIL_BUFFER_BIT);
+ glEnable(GL_SCISSOR_TEST);
+ glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_EQUAL, 0, $ff);
for lln := 0 to g_dynLightCount-1 do
glStencilFunc(GL_EQUAL, 0, $ff);
for lln := 0 to g_dynLightCount-1 do
lx := g_dynLights[lln].x;
ly := g_dynLights[lln].y;
lrad := g_dynLights[lln].radius;
lx := g_dynLights[lln].x;
ly := g_dynLights[lln].y;
lrad := g_dynLights[lln].radius;
- if lrad < 2 then continue;
+ 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
// set scissor to optimize drawing
- //!glScissor((lx-cameraOfsX)-lrad+2, v_height-(ly-cameraOfsY)-lrad-1+2, lrad*2-4, lrad*2-4);
- // clear stencil buffer
- glClear(GL_STENCIL_BUFFER_BIT); //!!!
+ glScissor((lx-sX)-lrad+2, gPlayerScreenSize.Y-(ly-sY)-lrad-1+2, lrad*2-4, lrad*2-4);
+ // 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);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
// draw extruded panels
glDisable(GL_TEXTURE_2D);
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
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);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // draw light, and clear stencil buffer
// blend it
glEnable(GL_BLEND);
glTexCoord2f(0.0, 1.0); glVertex2i(lx-lrad, ly+lrad); // bottom-left
glEnd();
end;
glTexCoord2f(0.0, 1.0); glVertex2i(lx-lrad, ly+lrad); // bottom-left
glEnd();
end;
+
// done
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glDisable(GL_SCISSOR_TEST);
// done
glDisable(GL_STENCIL_TEST);
glDisable(GL_BLEND);
glDisable(GL_SCISSOR_TEST);
- //!glScissor((lx-cameraOfsX)-radius+2, v_height-(ly-cameraOfsY)-radius-1+2, radius*2-4, radius*2-4);
+ glScissor(0, 0, sWidth, sHeight);
+ end;
+
+ g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_FORE);
+ if g_debug_HealthBar then
+ begin
+ g_Monsters_DrawHealth();
+ g_Player_DrawHealth();
end;
if p.FSpectator then
end;
if p.FSpectator then
}
glPopMatrix();
}
glPopMatrix();
- g_Map_ResetPVP();
p.DrawPain();
p.DrawPickup();
p.DrawPain();
p.DrawPickup();
State: Byte;
OuterLoop: Boolean;
newResPath: string;
State: Byte;
OuterLoop: Boolean;
newResPath: string;
+ Len: Word;
begin
g_Game_Free();
begin
g_Game_Free();
Ptr := NetEvent.packet^.data;
e_Raw_Seek(0);
Ptr := NetEvent.packet^.data;
e_Raw_Seek(0);
+ Len := e_Raw_Read_Word(Ptr);
MID := e_Raw_Read_Byte(Ptr);
if (MID = NET_MSG_INFO) and (State = 0) then
MID := e_Raw_Read_Byte(Ptr);
if (MID = NET_MSG_INFO) and (State = 0) then
g_Player_Init();
NetState := NET_STATE_GAME;
g_Player_Init();
NetState := NET_STATE_GAME;
- MC_SEND_FullStateRequest;
+ MC_SEND_FullStateRequest();
e_WriteLog('NET: Connection successful.', MSG_NOTIFY);
end;
e_WriteLog('NET: Connection successful.', MSG_NOTIFY);
end;