From: DeaDDooMER Date: Mon, 17 Jan 2022 16:11:35 +0000 (+0300) Subject: render: load sky in render X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=c7f0b67e60e7e48d12889ad331ee5d24d289a81e;p=d2df-sdl.git render: load sky in render --- diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 400e777..1be6b0c 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -916,7 +916,6 @@ end; fuiScrWdt := w; fuiScrHgt := h; {$ENDIF} - g_Game_SetupScreenSize; {$IFNDEF ANDROID} (* This will fix menu reset on keyboard showing *) g_Menu_Reset; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 2ce5d95..17c9fda 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -86,7 +86,6 @@ procedure g_Game_FreeData(); procedure g_Game_Update(); procedure g_Game_PreUpdate(); procedure g_Game_Quit(); -procedure g_Game_SetupScreenSize(); function g_Game_ModeToText(Mode: Byte): string; function g_Game_TextToMode(Mode: string): Byte; procedure g_Game_ExecuteEvent(Name: String); @@ -2561,45 +2560,6 @@ begin e_WriteLog(Format(_lc[I_SIMPLE_ERROR], [Text]), TMsgType.Warning); end; -procedure g_Game_SetupScreenSize(); -const - RES_FACTOR = 4.0 / 3.0; -var - s: Single; - rf: Single; - bw, bh: Word; -begin -// Размер экранов игроков: - gPlayerScreenSize.X := gScreenWidth-196; - if (gPlayer1 <> nil) and (gPlayer2 <> nil) then - gPlayerScreenSize.Y := gScreenHeight div 2 - else - gPlayerScreenSize.Y := gScreenHeight; - -// Размер заднего плана: - if BackID <> DWORD(-1) then - begin - s := SKY_STRETCH; - if (gScreenWidth*s > gMapInfo.Width) or - (gScreenHeight*s > gMapInfo.Height) then - begin - gBackSize.X := gScreenWidth; - gBackSize.Y := gScreenHeight; - end - else - begin - e_GetTextureSize(BackID, @bw, @bh); - rf := Single(bw) / Single(bh); - if (rf > RES_FACTOR) then bw := Round(Single(bh) * RES_FACTOR) - else if (rf < RES_FACTOR) then bh := Round(Single(bw) / RES_FACTOR); - s := Max(gScreenWidth / bw, gScreenHeight / bh); - if (s < 1.0) then s := 1.0; - gBackSize.X := Round(bw*s); - gBackSize.Y := Round(bh*s); - end; - end; -end; - procedure g_Game_AddPlayer(Team: Byte = TEAM_NONE); begin if ((not gGameOn) and (gState <> STATE_INTERCUSTOM)) @@ -2761,9 +2721,6 @@ begin g_Game_ExecuteEvent('ongamestart'); -// Установка размеров окон игроков: - g_Game_SetupScreenSize(); - // Создание первого игрока: gPlayer1 := g_Player_Get(g_Player_Create(gPlayer1Settings.Model, gPlayer1Settings.Color, @@ -2845,9 +2802,6 @@ begin g_Game_ExecuteEvent('ongamestart'); -// Установка размеров окон игроков: - g_Game_SetupScreenSize(); - // Режим наблюдателя: if nPlayers = 0 then begin @@ -2949,9 +2903,6 @@ begin g_Game_ExecuteEvent('ongamestart'); -// Установка размеров окна игрока - g_Game_SetupScreenSize(); - // Режим наблюдателя: if nPlayers = 0 then begin @@ -3063,9 +3014,6 @@ begin g_Game_ExecuteEvent('ongamestart'); -// Установка размеров окон игроков: - g_Game_SetupScreenSize(); - NetState := NET_STATE_AUTH; g_Game_SetLoadingText(_lc[I_LOAD_CONNECT], 0, False); diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 2ca5bb6..c5afc78 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -31,6 +31,7 @@ type Author: String; MusicName: String; SkyName: String; + SkyFullName: String; // used by render Height: Word; Width: Word; end; @@ -214,11 +215,9 @@ var gFlags: array [FLAG_RED..FLAG_BLUE] of TFlag; //gDOMFlags: array of TFlag; gMapInfo: TMapInfo; - gBackSize: TDFPoint; gDoorMap: array of array of DWORD; gLiftMap: array of array of DWORD; gWADHash: TMD5Digest; - BackID: DWORD = DWORD(-1); gExternalResources: array of TDiskFileInfo = nil; gMovingWallIds: array of Integer = nil; @@ -1869,15 +1868,12 @@ begin //mapReader := nil; // Çàãðóçêà íåáà + gMapInfo.SkyFullName := ''; if (gMapInfo.SkyName <> '') then begin e_WriteLog(' Loading sky: ' + gMapInfo.SkyName, TMsgType.Notify); g_Game_SetLoadingText(_lc[I_LOAD_SKY], 0, False); - s := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res)); - if g_Texture_CreateWAD(BackID, s, gTextureFilter) then - g_Game_SetupScreenSize - else - g_FatalError(Format(_lc[I_GAME_ERROR_SKY], [s])) + gMapInfo.SkyFullName := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res)); end; // Çàãðóçêà ìóçûêè @@ -2137,14 +2133,6 @@ begin FreePanelArray(gBlockMon); gMovingWallIds := nil; - if BackID <> DWORD(-1) then - begin - gBackSize.X := 0; - gBackSize.Y := 0; - e_DeleteTexture(BackID); - BackID := DWORD(-1); - end; - g_Game_StopAllSounds(False); gMusic.FreeSound(); g_Sound_Delete(gMapInfo.MusicName); diff --git a/src/game/g_saveload.pas b/src/game/g_saveload.pas index 32f6821..d603440 100644 --- a/src/game/g_saveload.pas +++ b/src/game/g_saveload.pas @@ -398,9 +398,6 @@ begin end; g_Game_ExecuteEvent('ongamestart'); - // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ - g_Game_SetupScreenSize(); - // Çàãðóçêà è çàïóñê êàðòû //FIXME: save/load `asMegawad` if not g_Game_StartMap(false{asMegawad}, WAD_Path+':\'+Map_Name, True, curmapfile) then diff --git a/src/game/opengl/r_game.pas b/src/game/opengl/r_game.pas index af6fa38..a31c4af 100644 --- a/src/game/opengl/r_game.pas +++ b/src/game/opengl/r_game.pas @@ -27,6 +27,8 @@ interface procedure r_Game_DrawLoadingStat; procedure r_Game_DrawMenuBackground (tex: AnsiString); + procedure r_Game_SetupScreenSize; + var gStdFont: DWORD; @@ -56,6 +58,9 @@ implementation FPSTime: LongWord; hasPBarGfx: Boolean; + BackID: DWORD = DWORD(-1); + gBackSize: TDFPoint; + procedure r_Game_Load; var wl, hl: Integer; @@ -124,16 +129,73 @@ implementation g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA'); end; +procedure r_Game_SetupScreenSize; +const + RES_FACTOR = 4.0 / 3.0; +var + s: Single; + rf: Single; + bw, bh: Word; +begin +// Размер экранов игроков: + gPlayerScreenSize.X := gScreenWidth-196; + if (gPlayer1 <> nil) and (gPlayer2 <> nil) then + gPlayerScreenSize.Y := gScreenHeight div 2 + else + gPlayerScreenSize.Y := gScreenHeight; + +// Размер заднего плана: + if BackID <> DWORD(-1) then + begin + s := SKY_STRETCH; + if (gScreenWidth*s > gMapInfo.Width) or + (gScreenHeight*s > gMapInfo.Height) then + begin + gBackSize.X := gScreenWidth; + gBackSize.Y := gScreenHeight; + end + else + begin + e_GetTextureSize(BackID, @bw, @bh); + rf := Single(bw) / Single(bh); + if (rf > RES_FACTOR) then bw := Round(Single(bh) * RES_FACTOR) + else if (rf < RES_FACTOR) then bh := Round(Single(bw) / RES_FACTOR); + s := Max(gScreenWidth / bw, gScreenHeight / bh); + if (s < 1.0) then s := 1.0; + gBackSize.X := Round(bw*s); + gBackSize.Y := Round(bh*s); + end; + end; +end; + procedure r_Game_LoadTextures; begin g_Texture_CreateWADEx('TEXTURE_endpic', EndPicPath, gTextureFilter); + if gMapInfo.SkyFullName <> '' then + g_Texture_CreateWAD(BackID, gMapInfo.SkyFullName, gTextureFilter); + r_Game_SetupScreenSize; end; procedure r_Game_FreeTextures; begin - g_Texture_Delete('TEXTURE_endpic') + g_Texture_Delete('TEXTURE_endpic'); + if BackID <> DWORD(-1) then + begin + gBackSize.X := 0; + gBackSize.Y := 0; + e_DeleteTexture(BackID); + BackID := DWORD(-1); + end end; +procedure r_Map_DrawBack(dx, dy: Integer); +begin + if gDrawBackGround and (BackID <> DWORD(-1)) then + e_DrawSize(BackID, dx, dy, 0, False, False, gBackSize.X, gBackSize.Y) + else + e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); +end; + function GetActivePlayer_ByID(ID: Integer): TPlayer; var a: Integer; diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas index 9efb062..b3efdc3 100644 --- a/src/game/opengl/r_map.pas +++ b/src/game/opengl/r_map.pas @@ -30,7 +30,6 @@ interface procedure r_Map_Update; - procedure r_Map_DrawBack (dx, dy: Integer); procedure r_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor); // unaccelerated procedure r_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer); procedure r_Map_DrawPanelShadowVolumes (lightX: Integer; lightY: Integer; radius: Integer); @@ -43,7 +42,7 @@ implementation uses {$INCLUDE ../nogl/noGLuses.inc} - SysUtils, Classes, Math, e_log, wadreader, CONFIG, utils, + SysUtils, Classes, Math, e_log, wadreader, CONFIG, utils, g_language, r_graphics, r_animations, r_textures, g_textures, g_base, g_basic, g_game, g_options, g_map @@ -249,14 +248,6 @@ begin it.release(); end; -procedure r_Map_DrawBack(dx, dy: Integer); -begin - if gDrawBackGround and (BackID <> DWORD(-1)) then - e_DrawSize(BackID, dx, dy, 0, False, False, gBackSize.X, gBackSize.Y) - else - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); -end; - procedure r_Map_DrawFlags; var i, dx: Integer; Mirror: TMirrorType; f: PFlag; begin diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index d4af4b5..1e5dec0 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -47,7 +47,7 @@ implementation {$IFDEF ENABLE_HOLMES} g_holmes, {$ENDIF} - r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game + r_playermodel, r_graphics, r_animations, r_textures, r_items, r_game, r_map ; var diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 2eec521..90bda3b 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -165,7 +165,8 @@ implementation gScreenWidth := w; gScreenHeight := h; e_ResizeWindow(w, h); - e_InitGL + e_InitGL; + r_Game_SetupScreenSize; end; procedure r_Render_Apply;