diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 4a9bfbe5641c27e0127ec8c3fabc67bb751c4d49..f45ac3d7e55ae8284caabcf6987912b6bdb3c905 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
uses
g_basic, g_player, e_graphics, Classes, g_res_downloader,
- SysUtils, g_sound, g_gui, MAPSTRUCT, wadreader, md5;
+ SysUtils, g_sound, g_gui, MAPSTRUCT, wadreader, md5, xprofiler;
type
TGameSettings = record
procedure GameCommands(P: SArray);
procedure GameCheats(P: SArray);
procedure DebugCommands(P: SArray);
+procedure ProfilerCommands(P: SArray);
procedure g_Game_Process_Params;
procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean);
procedure g_Game_StepLoading();
P1MoveButton: Byte = 0;
P2MoveButton: Byte = 0;
+ g_profile_frame_update: Boolean = false;
+ g_profile_frame_draw: Boolean = true;
+
procedure g_ResetDynlights ();
procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
procedure g_DynLightExplosion (x, y, radius: Integer; r, g, b: Single);
ENet, e_fixedbuffer, g_netmsg, g_netmaster, GL, GLExt,
utils, sfs;
+
+// ////////////////////////////////////////////////////////////////////////// //
type
TDynLight = record
x, y, radius: Integer;
end;
+// ////////////////////////////////////////////////////////////////////////// //
+procedure drawProfiles (x, y: Integer; title: AnsiString);
+var
+ wdt, hgt: Integer;
+ yy: Integer;
+
+ procedure drawItems ();
+ begin
+ repeat
+ e_TextureFontPrintEx(x+2+4*xprofItDepth, yy, Format('%s: %d', [xprofItName, xprofItMicro]), gStdFont, 255, 255, 0, 1, false);
+ Inc(yy, 16+2);
+ if xprofItHasChildren then
+ begin
+ xprofItDive();
+ drawItems();
+ xprofItPop();
+ end;
+ until xprofItNext();
+ end;
+
+begin
+ // gScreenWidth
+ if not xprofItReset() then exit;
+ wdt := 256;
+ hgt := 16+2+xprofTotalCount*(16+2); // title, items
+ // background
+ e_DrawFillQuad(x, y, x+wdt-1, y+hgt-1, 255, 255, 255, 200, B_BLEND);
+ // title
+ e_TextureFontPrintEx(x+2, y+2, Format('%s: %d', [title, Integer(xprofTotalMicro)]), gStdFont, 255, 255, 0, 1, false);
+ yy := y+16+2;
+ //drawItems();
+end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
type
TEndCustomGameStat = record
PlayerStat: TPlayerStatArray;
else
d := Round((py-p.IncCam-(gPlayerScreenSize.Y div 2))/(gMapInfo.Height-gPlayerScreenSize.Y)*(gBackSize.Y-gPlayerScreenSize.Y));
+ xprofBeginSection('map background');
g_Map_DrawBack(-c, -d);
+ xprofEndSection();
sX := -a;
sY := -(b+p.IncCam);
glTranslatef(a, b+p.IncCam, 0);
+ xprofBeginSection('map rendering');
+
+ xprofBeginSection('panel_back');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_BACK);
+ xprofEndSection();
+
+ xprofBeginSection('panel_step');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_STEP);
+ xprofEndSection();
+
+ xprofBeginSection('items');
g_Items_Draw();
+ xprofEndSection();
+
+ xprofBeginSection('weapons');
g_Weapon_Draw();
+ xprofEndSection();
+
+ xprofBeginSection('shells');
g_Player_DrawShells();
+ xprofEndSection();
+
+ xprofBeginSection('drawall');
g_Player_DrawAll();
+ xprofEndSection();
+
+ xprofBeginSection('corpses');
g_Player_DrawCorpses();
+ xprofEndSection();
+
+ xprofBeginSection('panel_wall');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WALL);
+ xprofEndSection();
+
+ xprofBeginSection('monsters');
g_Monsters_Draw();
+ xprofEndSection();
+
+ xprofBeginSection('panel_closedoor');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_CLOSEDOOR);
+ xprofEndSection();
+
+ xprofBeginSection('gfx');
g_GFX_Draw();
+ xprofEndSection();
+
+ xprofBeginSection('flags');
g_Map_DrawFlags();
+ xprofEndSection();
+
+ xprofBeginSection('panel_acid1');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID1);
+ xprofEndSection();
+
+ xprofBeginSection('panel_acid2');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_ACID2);
+ xprofEndSection();
+
+ xprofBeginSection('panel_water');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_WATER);
+ xprofEndSection();
//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
+ xprofBeginSection('dynlights');
+
// setup OpenGL parameters
glStencilMask($FFFFFFFF);
glStencilFunc(GL_ALWAYS, 0, $FFFFFFFF);
glDisable(GL_BLEND);
glDisable(GL_SCISSOR_TEST);
glScissor(0, 0, sWidth, sHeight);
+
+ xprofEndSection();
+ end
+ else
+ begin
+ xprofBeginSection('dynlights');
+ xprofEndSection();
end;
+ xprofBeginSection('panel_fore');
g_Map_DrawPanels(sX, sY, sWidth, sHeight, PANEL_FORE);
+ xprofEndSection();
+
if g_debug_HealthBar then
begin
+ xprofBeginSection('monster health');
g_Monsters_DrawHealth();
+ xprofEndSection();
+
+ xprofBeginSection('player health');
g_Player_DrawHealth();
+ xprofEndSection();
end;
if p.FSpectator then
glPopMatrix();
+ xprofEndSection(); // map rendering
+
p.DrawPain();
p.DrawPickup();
p.DrawRulez();
FPSTime := Time;
end;
+ xprofBegin(g_profile_frame_draw);
+
if gGameOn or (gState = STATE_FOLD) then
begin
if (gPlayer1 <> nil) and (gPlayer2 <> nil) then
e_TextureFontPrint(gScreenWidth-72, 0,
Format('%d:%.2d:%.2d', [gTime div 1000 div 3600, (gTime div 1000 div 60) mod 60, gTime div 1000 mod 60]),
gStdFont);
+
+ xprofEnd();
+ if g_profile_frame_draw then drawProfiles(0, 0, 'MAP RENDER');
end;
procedure g_Game_Quit();
end;
end;
+// profiler console commands
+procedure ProfilerCommands (P: SArray);
+var
+ cmd: string;
+begin
+ //if not gDebugMode then exit;
+ cmd := LowerCase(P[0]);
+ if cmd = 'dpp' then
+ begin
+ g_profile_frame_draw := not g_profile_frame_draw;
+ exit;
+ end;
+ if cmd = 'dpu' then
+ begin
+ g_profile_frame_update := not g_profile_frame_update;
+ exit;
+ end;
+end;
+
procedure DebugCommands(P: SArray);
var
a, b: Integer;