X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fopengl%2Fr_game.pas;h=8acd51b104fcd4cc973f9d1b79f23ae7fd4996f6;hb=9615ae96661aed9886424c75479d322f555627a6;hp=d2ead67c0117c15fc2483501c54765c954dc973c;hpb=aab9c00a40aebab672c35d10258404b6eea517e7;p=d2df-sdl.git diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas index d2ead67..8acd51b 100644 --- a/src/game/opengl/r_game.pas +++ b/src/game/opengl/r_game.pas @@ -18,21 +18,24 @@ 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 uses {$INCLUDE ../nogl/noGLuses.inc} +{$IFDEF ENABLE_HOLMES} + g_holmes, +{$ENDIF} SysUtils, Classes, Math, - e_graphics, + g_base, r_graphics, g_system, g_touch, MAPDEF, xprofiler, utils, wadreader, 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, r_gfx + g_game, r_console, r_gfx, r_items, r_map, r_panel, r_monsters, r_weapons, r_netmaster, r_player ; var @@ -660,7 +663,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 +804,7 @@ begin end; end; -procedure DrawMenuBackground(tex: AnsiString); +procedure r_Game_DrawMenuBackground (tex: AnsiString); var w, h: Word; ID: DWord; @@ -820,7 +823,7 @@ begin else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); end; -procedure DrawMinimap(p: TPlayer; RenderRect: e_graphics.TRect); +procedure DrawMinimap(p: TPlayer; RenderRect: TRect); var a, aX, aY, aX2, aY2, Scale, ScaleSz: Integer; @@ -1025,6 +1028,65 @@ begin e_AmbientQuad(sX, sY, sWidth, sHeight, ambColor.r, ambColor.g, ambColor.b, ambColor.a); end; +// ////////////////////////////////////////////////////////////////////////// // +var + ltexid: GLuint = 0; + +function g_Texture_Light (): Integer; +const + Radius: Integer = 128; +var + tex, tpp: PByte; + x, y, a: Integer; + dist: Double; +begin + if ltexid = 0 then + begin + GetMem(tex, (Radius*2)*(Radius*2)*4); + tpp := tex; + for y := 0 to Radius*2-1 do + begin + for x := 0 to Radius*2-1 do + begin + dist := 1.0-sqrt((x-Radius)*(x-Radius)+(y-Radius)*(y-Radius))/Radius; + if (dist < 0) then + begin + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + tpp^ := 0; Inc(tpp); + end + else + begin + //tc.setPixel(x, y, Color(cast(int)(dist*255), cast(int)(dist*255), cast(int)(dist*255))); + if (dist > 0.5) then dist := 0.5; + a := round(dist*255); + if (a < 0) then a := 0 else if (a > 255) then a := 255; + tpp^ := 255; Inc(tpp); + tpp^ := 255; Inc(tpp); + tpp^ := 255; Inc(tpp); + tpp^ := Byte(a); Inc(tpp); + end; + end; + end; + + glGenTextures(1, @ltexid); + //if (tid == 0) assert(0, "VGL: can't create screen texture"); + + glBindTexture(GL_TEXTURE_2D, ltexid); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + //GLfloat[4] bclr = 0.0; + //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Radius*2, Radius*2, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex); + end; + + result := ltexid; +end; // setup sX, sY, sWidth, sHeight, and transformation matrix before calling this! //FIXME: broken for splitscreen mode @@ -1106,7 +1168,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 +1242,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 +1268,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 +1300,17 @@ begin drawPanelType('*back', PANEL_BACK, g_rlayer_back); drawPanelType('*step', PANEL_STEP, g_rlayer_step); - drawOther('items', @g_Items_Draw); - drawOther('weapons', @g_Weapon_Draw); - drawOther('shells', @g_Player_DrawShells); - drawOther('drawall', @g_Player_DrawAll); - drawOther('corpses', @g_Player_DrawCorpses); + drawOther('items', @r_Items_Draw); + drawOther('weapons', @r_Weapon_Draw); + drawOther('shells', @r_Player_DrawShells); + drawOther('drawall', @r_Player_DrawAll); + drawOther('corpses', @r_Player_DrawCorpses); drawPanelType('*wall', PANEL_WALL, g_rlayer_wall); - drawOther('monsters', @g_Monsters_Draw); - drawOther('itemdrop', @g_Items_DrawDrop); + drawOther('monsters', @r_Monsters_Draw); + drawOther('itemdrop', @r_Items_DrawDrop); drawPanelType('*door', PANEL_CLOSEDOOR, g_rlayer_door); drawOther('gfx', @r_GFX_Draw); - drawOther('flags', @g_Map_DrawFlags); + 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); @@ -1265,8 +1327,8 @@ begin if g_debug_HealthBar then begin - g_Monsters_DrawHealth(); - g_Player_DrawHealth(); + r_Monsters_DrawHealth(); + r_Player_DrawHealth(); end; if (profileFrameDraw <> nil) then profileFrameDraw.mainEnd(); // map rendering @@ -1304,7 +1366,7 @@ begin if (p = nil) or (p.FDummy) then begin glPushMatrix(); - g_Map_DrawBack(0, 0); + r_Map_DrawBack(0, 0); glPopMatrix(); Exit; end; @@ -1436,16 +1498,18 @@ begin if (gGameSettings.GameMode <> GM_SINGLE) and (gPlayerIndicator > 0) then case gPlayerIndicator of 1: - p.DrawIndicator(_RGB(255, 255, 255)); + r_Player_DrawIndicator(p, _RGB(255, 255, 255)); 2: for i := 0 to High(gPlayers) do if gPlayers[i] <> nil then - if gPlayers[i] = p then p.DrawIndicator(_RGB(255, 255, 255)) + if gPlayers[i] = p then + r_Player_DrawIndicator(p, _RGB(255, 255, 255)) else if (gPlayers[i].Team = p.Team) and (gPlayers[i].Team <> TEAM_NONE) then if gPlayerIndicatorStyle = 1 then - gPlayers[i].DrawIndicator(_RGB(192, 192, 192)) - else gPlayers[i].DrawIndicator(gPlayers[i].GetColor); + r_Player_DrawIndicator(gPlayers[i], _RGB(192, 192, 192)) + else + r_Player_DrawIndicator(gPlayers[i], gPlayers[i].GetColor); end; { @@ -1468,13 +1532,13 @@ begin glPopMatrix(); - p.DrawPain(); - p.DrawPickup(); - p.DrawRulez(); + r_Player_DrawPain(p); + r_Player_DrawPickup(p); + r_Player_DrawRulez(p); if gShowMap then DrawMinimap(p, _TRect(0, 0, 128, 128)); if g_Debug_Player then - g_Player_DrawDebug(p); - p.DrawGUI(); + r_Player_DrawDebug(p); + r_Player_DrawGUI(p); end; procedure drawProfilers (); @@ -1716,7 +1780,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 +1815,7 @@ begin else back := 'INTER'; - DrawMenuBackground(back); + r_Game_DrawMenuBackground(back); DrawCustomStat(); @@ -1772,7 +1836,7 @@ begin begin back := 'INTER'; - DrawMenuBackground(back); + r_Game_DrawMenuBackground(back); DrawSingleStat(); @@ -1787,8 +1851,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,9 +1868,9 @@ 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); + r_Serverlist_Draw(slCurrent, slTable); end; end;