From 652d0962d87cf4ee274b6522697b14f01feee5bc Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 13 Apr 2022 22:55:28 +0300 Subject: [PATCH] renders: add stub render --- src/game/Doom2DF.lpr | 54 +++++---- src/game/renders/stub/r_render.pas | 188 +++++++++++++++++++++++++++++ src/shared/a_modes.inc | 19 ++- 3 files changed, 233 insertions(+), 28 deletions(-) create mode 100644 src/game/renders/stub/r_render.pas diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index a93c9bb..ff748ec 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -167,30 +167,36 @@ uses {$ENDIF} {$IFDEF ENABLE_RENDER} - {$I ../shared/vampimg.inc} - r_animations in 'opengl/r_animations.pas', - r_console in 'opengl/r_console.pas', - r_game in 'opengl/r_game.pas', - {$IFDEF ENABLE_GFX} - r_gfx in 'opengl/r_gfx.pas', - {$ENDIF} - r_graphics in 'opengl/r_graphics.pas', - r_items in 'opengl/r_items.pas', - r_map in 'opengl/r_map.pas', - r_monsters in 'opengl/r_monsters.pas', - r_netmaster in 'opengl/r_netmaster.pas', - r_player in 'opengl/r_player.pas', - r_playermodel in 'opengl/r_playermodel.pas', - r_render in 'opengl/r_render.pas', - r_texture in 'opengl/r_texture.pas', - r_textures in 'opengl/r_textures.pas', - r_weapons in 'opengl/r_weapons.pas', - r_window in 'opengl/r_window.pas', - {$IFDEF ENABLE_TOUCH} - r_touch in 'opengl/r_touch.pas', - {$ENDIF} - {$IFDEF ENABLE_MENU} - r_gui in 'opengl/r_gui.pas', + {$IF DEFINED(USE_OPENGL) OR DEFINED(USE_GLES1) OR DEFINED(USE_GLSTUB)} + {$I ../shared/vampimg.inc} + r_animations in 'opengl/r_animations.pas', + r_console in 'opengl/r_console.pas', + r_game in 'opengl/r_game.pas', + {$IFDEF ENABLE_GFX} + r_gfx in 'opengl/r_gfx.pas', + {$ENDIF} + r_graphics in 'opengl/r_graphics.pas', + r_items in 'opengl/r_items.pas', + r_map in 'opengl/r_map.pas', + r_monsters in 'opengl/r_monsters.pas', + r_netmaster in 'opengl/r_netmaster.pas', + r_player in 'opengl/r_player.pas', + r_playermodel in 'opengl/r_playermodel.pas', + r_render in 'opengl/r_render.pas', + r_texture in 'opengl/r_texture.pas', + r_textures in 'opengl/r_textures.pas', + r_weapons in 'opengl/r_weapons.pas', + r_window in 'opengl/r_window.pas', + {$IFDEF ENABLE_TOUCH} + r_touch in 'opengl/r_touch.pas', + {$ENDIF} + {$IFDEF ENABLE_MENU} + r_gui in 'opengl/r_gui.pas', + {$ENDIF} + {$ELSEIF DEFINED(USE_STUBRENDER)} + r_render in 'renders/stub/r_render.pas', + {$ELSE} + {$FATAL render driver not selected} {$ENDIF} {$ENDIF} diff --git a/src/game/renders/stub/r_render.pas b/src/game/renders/stub/r_render.pas new file mode 100644 index 0000000..0075fef --- /dev/null +++ b/src/game/renders/stub/r_render.pas @@ -0,0 +1,188 @@ +(* Copyright (C) Doom 2D: Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE ../../../shared/a_modes.inc} +unit r_render; + +interface + + uses + {$IFDEF ENABLE_MENU} + g_gui, + {$ENDIF} + g_base // TRectWH + ; + + procedure r_Render_Initialize; + procedure r_Render_Finalize; + + procedure r_Render_Load; + procedure r_Render_Free; + + procedure r_Render_LoadTextures; + procedure r_Render_FreeTextures; + + procedure r_Render_Update; + procedure r_Render_Draw; + + procedure r_Render_Resize (w, h: Integer); + procedure r_Render_Apply; + + function r_Render_WriteScreenShot (filename: String): Boolean; + + {$IFDEF ENABLE_GIBS} + function r_Render_GetGibRect (m, id: Integer): TRectWH; + {$ENDIF} + + {$IFDEF ENABLE_GFX} + procedure r_Render_QueueEffect (AnimType, X, Y: Integer); + {$ENDIF} + + {$IFDEF ENABLE_TOUCH} + // touch screen button location and size + procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean); + {$ENDIF} + + {$IFDEF ENABLE_MENU} + procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer); + procedure r_Render_GetLogoSize (out w, h: Integer); + procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); + {$ENDIF} + + procedure r_Render_DrawLoading (force: Boolean); // !!! remove it + +implementation + + uses + {$IFDEF ENABLE_SYSTEM} + g_system, + {$ENDIF} + SysUtils, Classes, Math, + e_log, utils, + g_game, g_options, g_console + ; + + procedure r_Render_LoadTextures; + begin + end; + + procedure r_Render_FreeTextures; + begin + end; + + procedure r_Render_Load; + begin + end; + + procedure r_Render_Free; + begin + end; + + procedure r_Render_Initialize; + begin + {$IFDEF ENABLE_SYSTEM} + if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then + raise Exception.Create('Failed to set videomode on startup.'); + {$ENDIF} + end; + + procedure r_Render_Finalize; + begin + end; + + procedure r_Render_Update; + begin + end; + + procedure r_Render_Draw; + begin + end; + + procedure r_Render_Resize (w, h: Integer); + begin + gWinSizeX := w; + gWinSizeY := h; + gRC_Width := w; + gRC_Height := h; + gScreenWidth := w; + gScreenHeight := h; + end; + + procedure r_Render_Apply; + begin + {$IFDEF ENABLE_SYSTEM} + if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then + e_LogWriteln('resolution changed') + else + e_LogWriteln('resolution not changed'); + sys_EnableVSync(gVSync) + {$ENDIF} + end; + + function r_Render_WriteScreenShot (filename: String): Boolean; + begin + Result := False; + end; + +{$IFDEF ENABLE_GIBS} + function r_Render_GetGibRect (m, id: Integer): TRectWH; + begin + Result.X := 16; + Result.Y := 16; + Result.Width := 16; + Result.Height := 16; + end; +{$ENDIF} + +{$IFDEF ENABLE_GFX} + procedure r_Render_QueueEffect (AnimType, X, Y: Integer); + begin + end; +{$ENDIF} + +{$IFDEF ENABLE_TOUCH} + procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean); + begin + founded := False; + end; +{$ENDIF} + +{$IFDEF ENABLE_MENU} + procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer); + begin + w := 0; h := 0; + end; + + procedure r_Render_GetLogoSize (out w, h: Integer); + begin + w := 0; h := 0; + end; + + procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + begin + w := 0; h := 0; + end; + + procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); + begin + w := 0; h := 0; + end; +{$ENDIF} + + procedure r_Render_DrawLoading (force: Boolean); + begin + end; + +end. diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc index 42c44dd..058f2b9 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -277,20 +277,31 @@ {$ENDIF} {$IF DEFINED(USE_GLSTUB)} - {$IF DEFINED(USE_GLES1) OR DEFINED(USE_OPENGL)} + {$IF DEFINED(USE_GLES1) OR DEFINED(USE_OPENGL) OR DEFINED(USE_STUBRENDER)} {$ERROR Only one render driver must be selected!} {$ENDIF} {$ELSEIF DEFINED(USE_GLES1)} - {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_OPENGL)} + {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_OPENGL) OR DEFINED(USE_STUBRENDER)} {$ERROR Only one render driver must be selected!} {$ENDIF} {$ELSEIF DEFINED(USE_OPENGL)} - {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_GLES1)} + {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_GLES1) OR DEFINED(USE_STUBRENDER)} + {$ERROR Only one render driver must be selected!} + {$ENDIF} +{$ELSEIF DEFINED(USE_STUBRENDER)} + {$IF DEFINED(USE_GLSTUB) OR DEFINED(USE_OPENGL) OR DEFINED(USE_GLES1)} {$ERROR Only one render driver must be selected!} {$ENDIF} {$ELSEIF DEFINED(ENABLE_RENDER)} {$DEFINE USE_OPENGL} - {.$ERROR Render driver not selected. Use -dUSE_GLSTUB or -dUSE_GLES1 or -dUSE_OPENGL} + {.$ERROR Render driver not selected. Use -dUSE_OPENGL or -dUSE_GLES1} +{$ENDIF} + +{$IFDEF DISABLE_RENDER} + {$UNDEF USE_GLSTUB} + {$UNDEF USE_GLES1} + {$UNDEF USE_OPENGL} + {$UNDEF USE_STUBRENDER} {$ENDIF} {$IFDEF ENABLE_HOLMES} -- 2.29.2