DEADSOFTWARE

render: separate panel logic and drawing
[d2df-sdl.git] / src / game / opengl / r_game.pas
index 6dd62a21839e82a8e581f1fbd742e8900bdb9cb7..8015bb4ca6740a2fb1704722aa461d19e7f53b0d 100644 (file)
@@ -18,8 +18,8 @@ unit r_game;
 interface
 
   procedure r_Game_Draw;
-  procedure DrawLoadingStat;
-  procedure DrawMenuBackground (tex: AnsiString);
+  procedure r_Game_DrawLoadingStat;
+  procedure r_Game_DrawMenuBackground (tex: AnsiString);
 
 implementation
 
@@ -32,7 +32,7 @@ implementation
     g_textures, e_input, e_sound,
     g_language, g_console, g_menu, g_triggers, g_player, g_options, g_monsters, g_map, g_panel, g_window,
     g_items, g_weapons, g_gfx, g_phys, g_net, g_gui, g_netmaster,
-    g_game, r_console
+    g_game, r_console, r_gfx, r_items, r_map, r_panel
   ;
 
   var
@@ -660,7 +660,7 @@ begin
     end;
 end;
 
-procedure DrawLoadingStat();
+procedure r_Game_DrawLoadingStat;
   procedure drawRect (x, y, w, h: Integer);
   begin
     if (w < 1) or (h < 1) then exit;
@@ -801,7 +801,7 @@ begin
   end;
 end;
 
-procedure DrawMenuBackground(tex: AnsiString);
+procedure r_Game_DrawMenuBackground (tex: AnsiString);
 var
   w, h: Word;
   ID: DWord;
@@ -1106,7 +1106,7 @@ begin
     glDisable(GL_TEXTURE_2D);
     glDisable(GL_BLEND);
     glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no need to modify color buffer
-    if (lrad > 4) then g_Map_DrawPanelShadowVolumes(lx, ly, lrad);
+    if (lrad > 4) then r_Map_DrawPanelShadowVolumes(lx, ly, lrad);
     // render light texture
     glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // modify color buffer
     glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); // draw light, and clear stencil buffer
@@ -1180,13 +1180,13 @@ var
       begin
         pan := TPanel(gDrawPanelList.front());
         if ((pan.tag and tagmask) = 0) then break;
-        if doDraw then pan.Draw(doAmbient, ambColor);
+        if doDraw then r_Panel_Draw(pan, doAmbient, ambColor);
         gDrawPanelList.popFront();
       end;
     end
     else
     begin
-      if doDraw then g_Map_DrawPanels(panType, hasAmbient, ambColor);
+      if doDraw then r_Map_DrawPanels(panType, hasAmbient, ambColor);
     end;
     if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
   end;
@@ -1206,12 +1206,12 @@ begin
   if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('collect');
   if gdbg_map_use_accel_render then
   begin
-    g_Map_CollectDrawPanels(sX, sY, sWidth, sHeight);
+    r_Map_CollectDrawPanels(sX, sY, sWidth, sHeight);
   end;
   if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
 
   if (profileFrameDraw <> nil) then profileFrameDraw.sectionBegin('skyback');
-  g_Map_DrawBack(backXOfs, backYOfs);
+  r_Map_DrawBack(backXOfs, backYOfs);
   if (profileFrameDraw <> nil) then profileFrameDraw.sectionEnd();
 
   if setTransMatrix then
@@ -1238,17 +1238,17 @@ begin
 
   drawPanelType('*back', PANEL_BACK, g_rlayer_back);
   drawPanelType('*step', PANEL_STEP, g_rlayer_step);
-  drawOther('items', @g_Items_Draw);
+  drawOther('items', @r_Items_Draw);
   drawOther('weapons', @g_Weapon_Draw);
   drawOther('shells', @g_Player_DrawShells);
   drawOther('drawall', @g_Player_DrawAll);
   drawOther('corpses', @g_Player_DrawCorpses);
   drawPanelType('*wall', PANEL_WALL, g_rlayer_wall);
   drawOther('monsters', @g_Monsters_Draw);
-  drawOther('itemdrop', @g_Items_DrawDrop);
+  drawOther('itemdrop', @r_Items_DrawDrop);
   drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door);
-  drawOther('gfx', @g_GFX_Draw);
-  drawOther('flags', @g_Map_DrawFlags);
+  drawOther('gfx', @r_GFX_Draw);
+  drawOther('flags', @r_Map_DrawFlags);
   drawPanelType('*acid1', PANEL_ACID1, g_rlayer_acid1);
   drawPanelType('*acid2', PANEL_ACID2, g_rlayer_acid2);
   drawPanelType('*water', PANEL_WATER, g_rlayer_water);
@@ -1304,7 +1304,7 @@ begin
   if (p = nil) or (p.FDummy) then
   begin
     glPushMatrix();
-    g_Map_DrawBack(0, 0);
+    r_Map_DrawBack(0, 0);
     glPopMatrix();
     Exit;
   end;
@@ -1716,7 +1716,7 @@ begin
   begin
     if (gState = STATE_MENU) then
     begin
-      if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then DrawMenuBackground('MENU_BACKGROUND');
+      if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then r_Game_DrawMenuBackground('MENU_BACKGROUND');
       // F3 at menu will show game loading dialog
       if e_KeyPressed(IK_F3) then g_Menu_Show_LoadMenu(true);
       if (g_ActiveWindow <> nil) then
@@ -1751,7 +1751,7 @@ begin
       else
         back := 'INTER';
 
-      DrawMenuBackground(back);
+      r_Game_DrawMenuBackground(back);
 
       DrawCustomStat();
 
@@ -1772,7 +1772,7 @@ begin
       begin
         back := 'INTER';
 
-        DrawMenuBackground(back);
+        r_Game_DrawMenuBackground(back);
 
         DrawSingleStat();
 
@@ -1787,8 +1787,8 @@ begin
     if gState = STATE_ENDPIC then
     begin
       ID := DWORD(-1);
-      if g_Texture_Get('TEXTURE_endpic', ID) then DrawMenuBackground('TEXTURE_endpic')
-      else DrawMenuBackground(_lc[I_TEXTURE_ENDPIC]);
+      if g_Texture_Get('TEXTURE_endpic', ID) then r_Game_DrawMenuBackground('TEXTURE_endpic')
+      else r_Game_DrawMenuBackground(_lc[I_TEXTURE_ENDPIC]);
 
       if g_ActiveWindow <> nil then
       begin
@@ -1804,7 +1804,7 @@ begin
 //        e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight);
 //        //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180);
 //      end;
-      DrawMenuBackground('MENU_BACKGROUND');
+      r_Game_DrawMenuBackground('MENU_BACKGROUND');
       e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150);
       g_Serverlist_Draw(slCurrent, slTable);
     end;