diff --git a/Descent3/config.cpp b/Descent3/config.cpp index bcdbedb50..bb63cb7c8 100644 --- a/Descent3/config.cpp +++ b/Descent3/config.cpp @@ -343,6 +343,7 @@ std::vector Video_res_list = {{512, 384}, int Default_resolution_id = 7; // 1280x720 in the default list int Current_video_resolution_id = Default_resolution_id; float Render_FOV_setting = 72.0f; +bool Game_fullscreen = true; int Display_id = 0; void ConfigureDisplayResolutions() { @@ -424,10 +425,18 @@ void ConfigureDisplayResolutions() { if (current_res_id != Video_res_list.end()) { Default_resolution_id = static_cast(current_res_id - Video_res_list.begin()); } else { - Default_resolution_id = 0; // default to the highest supported resolution + Default_resolution_id = Video_res_list.size() - 1; // default to the highest supported resolution } - Current_video_resolution_id = Default_resolution_id; + int tmp; + if (!Database->read_int("RS_resolution", &tmp)) { + // Only override resolution id if the value was not found in the settings + Current_video_resolution_id = Default_resolution_id; + } + + LOG_DEBUG << "Resolution configured to w=" << Video_res_list[Current_video_resolution_id].width + << "h=" << Video_res_list[Current_video_resolution_id].height << " (id " << Current_video_resolution_id + << ")"; } tDetailSettings Detail_settings; @@ -758,10 +767,12 @@ struct video_menu { // settings bool *filtering = nullptr; + bool *fullscreen = nullptr; bool *mipmapping = nullptr; bool *vsync = nullptr; char *resolution_string = nullptr; short *fov = nullptr; + bool resolution_changed = false; int *bitdepth = nullptr; // bitdepths @@ -777,6 +788,8 @@ struct video_menu { snprintf(resolution_string, res.size() + 1, res.c_str()); sheet->AddLongButton("Change", IDV_CHANGE_RES_WINDOW); + fullscreen = sheet->AddLongCheckBox("Fullscreen", Game_fullscreen); + // FOV setting 72deg -> 90deg tSliderSettings settings = {}; settings.min_val.f = D3_DEFAULT_FOV; @@ -834,11 +847,14 @@ struct video_menu { if (bitdepth) Render_preferred_bitdepth = (*bitdepth) == 1 ? 32 : 16; #endif - if (GetScreenMode() == SM_GAME) { - Render_preferred_state.bit_depth = Render_preferred_bitdepth; - rend_SetPreferredState(&Render_preferred_state); + if (*fullscreen != Game_fullscreen || Render_preferred_state.bit_depth != Render_preferred_bitdepth || + resolution_changed) { + resolution_changed = false; + Game_fullscreen = *fullscreen; SetScreenMode(GetScreenMode(), true); + Render_preferred_state.bit_depth = Render_preferred_bitdepth; + rend_SetPreferredState(&Render_preferred_state, true); int temp_w = Video_res_list[Current_video_resolution_id].width; int temp_h = Video_res_list[Current_video_resolution_id].height; @@ -885,7 +901,8 @@ struct video_menu { if (res == UID_OK) { int newindex = resolution_list->GetCurrentIndex(); - if (static_cast(newindex) < Video_res_list.size()) { + if (static_cast(newindex) < Video_res_list.size() && Current_video_resolution_id != newindex) { + resolution_changed = true; Current_video_resolution_id = newindex; std::string res = Video_res_list[Current_video_resolution_id].getName(); snprintf(resolution_string, res.size() + 1, res.c_str()); diff --git a/Descent3/config.h b/Descent3/config.h index 8086a3b2f..3ffe50dec 100644 --- a/Descent3/config.h +++ b/Descent3/config.h @@ -166,6 +166,8 @@ extern std::vector Video_res_list; extern int Default_resolution_id; extern int Current_video_resolution_id; extern int Display_id; +extern bool Game_fullscreen; + /** * List all unique resolutions for the detected displays, diff --git a/Descent3/game.cpp b/Descent3/game.cpp index 787796f2e..82300b537 100644 --- a/Descent3/game.cpp +++ b/Descent3/game.cpp @@ -957,6 +957,7 @@ void SetScreenMode(int sm, bool force_res_change) { Render_preferred_state.width = scr_width; Render_preferred_state.height = scr_height; Render_preferred_state.bit_depth = scr_bitdepth; + Render_preferred_state.fullscreen = Game_fullscreen; rend_initted = rend_Init(PreferredRenderer, Descent, &Render_preferred_state); rend_width = rend_height = 0; @@ -987,10 +988,12 @@ void SetScreenMode(int sm, bool force_res_change) { scr_height = 480; } - if (rend_width != scr_width || rend_height != scr_height) { + if (rend_width != scr_width || rend_height != scr_height || + Game_fullscreen != Render_preferred_state.fullscreen) { Render_preferred_state.width = scr_width; Render_preferred_state.height = scr_height; Render_preferred_state.bit_depth = scr_bitdepth; + Render_preferred_state.fullscreen = Game_fullscreen; LOG_INFO.printf("Setting rend_width=%d height=%d", scr_width, scr_height); int retval = rend_SetPreferredState(&Render_preferred_state); diff --git a/Descent3/gamesequence.cpp b/Descent3/gamesequence.cpp index 9a62f9478..622f3e584 100644 --- a/Descent3/gamesequence.cpp +++ b/Descent3/gamesequence.cpp @@ -1231,7 +1231,7 @@ bool GameSequencer() { SetFunctionMode(MENU_MODE); } else { SetGameState(GAMESTATE_LVLPLAYING); - SetScreenMode(SM_GAME); + SetScreenMode(SM_GAME, true); SetHUDMode(GetHUDMode()); } ResumeGame(); @@ -1513,7 +1513,7 @@ void StartLevel() { #endif // Set screen mode - SetScreenMode(SM_GAME); + SetScreenMode(SM_GAME, true); // Init HUD and cockpit int ship_index; diff --git a/Descent3/init.cpp b/Descent3/init.cpp index a54d2417a..2bd4c1191 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1159,6 +1159,7 @@ void SaveGameSettings() { Database->write("RS_resolution", Current_video_resolution_id); Database->write("RS_fov", static_cast(Render_FOV_setting)); + Database->write("RS_fullscreen", static_cast(Game_fullscreen)); Database->write("RS_bitdepth", Render_preferred_bitdepth); Database->write("RS_bilear", Render_preferred_state.filtering); @@ -1291,13 +1292,16 @@ void LoadGameSettings() { Database->read("Specmapping", &Detail_settings.Specular_lighting); Database->read("RS_bitdepth", &Render_preferred_bitdepth, sizeof(Render_preferred_bitdepth)); Database->read_int("RS_resolution", &Current_video_resolution_id); - - int tempfov = 0; - Database->read_int("RS_fov", &tempfov); - tempfov = std::clamp(tempfov, static_cast(D3_DEFAULT_FOV), 90); - Render_FOV_setting = static_cast(tempfov); + + int tempval = 0; + Database->read_int("RS_fov", &tempval); + tempval = std::clamp(tempval, static_cast(D3_DEFAULT_FOV), 90); + Render_FOV_setting = static_cast(tempval); Render_FOV = Render_FOV_setting; + Database->read_int("RS_fullscreen", &tempval); + Game_fullscreen = tempval != 0; + Database->read_int("RS_bilear", &Render_preferred_state.filtering); Database->read_int("RS_mipping", &Render_preferred_state.mipping); Database->read_int("RS_color_model", &Render_state.cur_color_model); @@ -1575,6 +1579,9 @@ void InitGraphics(bool editor) { if (!InitTextures()) Error("Failed to initialize texture system."); + // Init fullscreen/windowed mode from CLI arguments + rend_InitWindowMode(); + #ifdef EDITOR char *driver = "GDIX"; @@ -1719,6 +1726,7 @@ void InitMessage(const char *c, float progress) { } EndFrame(); + Descent->defer(); rend_Flip(); } diff --git a/Descent3/menu.cpp b/Descent3/menu.cpp index 21df635a4..779c59d77 100644 --- a/Descent3/menu.cpp +++ b/Descent3/menu.cpp @@ -731,7 +731,7 @@ int MainMenu() { } // setup screen - SetScreenMode(SM_MENU); + SetScreenMode(SM_MENU, true); // create interface main_menu.Create(); main_menu.AddItem(IDV_NEWGAME, KEY_N, TXT_MENUNEWGAME, MM_STARTMENU_TYPE); diff --git a/Descent3/sdlmain.cpp b/Descent3/sdlmain.cpp index 29a0080c0..92974f5d1 100644 --- a/Descent3/sdlmain.cpp +++ b/Descent3/sdlmain.cpp @@ -44,6 +44,7 @@ #include "dedicated_server.h" #include "init.h" #include "log.h" +#include "config.h" #ifdef WIN32 #include "debug.h" @@ -253,14 +254,6 @@ int main(int argc, char *argv[]) { SDL_SetEventFilter(d3SDLEventFilter, nullptr); install_signal_handlers(); - int winArg = FindArgChar("-windowed", 'w'); - int fsArg = FindArgChar("-fullscreen", 'f'); - - if ((fsArg) && (winArg)) { - LOG_FATAL.printf("ERROR: %s AND %s specified!", GameArgs[winArg], GameArgs[fsArg]); - return (0); - } - // Initialize our OS Object. This could be a game dependant OS object, or a default OS object. // Once we create it, if successful, we can start the game. int flags = 0; diff --git a/ddio/lnxkey_sdl.cpp b/ddio/lnxkey_sdl.cpp index f8403e439..c8888747f 100644 --- a/ddio/lnxkey_sdl.cpp +++ b/ddio/lnxkey_sdl.cpp @@ -68,6 +68,8 @@ #include "ddio.h" #include "pserror.h" +#include "renderer.h" +#include "config.h" extern volatile struct tLnxKeys { union { @@ -362,14 +364,8 @@ bool sdlKeyFilter(const SDL_Event *event) { else if (event->key.mod & SDL_KMOD_ALT) { if ((kc == KEY_ENTER) || (kc == KEY_PADENTER)) { - extern SDL_Window *GSDLWindow; - Uint32 flags = SDL_GetWindowFlags(GSDLWindow); - if (flags & SDL_WINDOW_FULLSCREEN) { - flags &= ~SDL_WINDOW_FULLSCREEN; - } else { - flags |= SDL_WINDOW_FULLSCREEN; - } - SDL_SetWindowFullscreen(GSDLWindow, flags); + Game_fullscreen = !Game_fullscreen; + rend_SetFullScreen(Game_fullscreen); return false; } // if } // else if diff --git a/lib/lnxscreenmode.h b/lib/lnxscreenmode.h deleted file mode 100644 index 96e950008..000000000 --- a/lib/lnxscreenmode.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* 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, either version 3 of the License, or -* (at your option) any later version. -* -* 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 . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/Main/renderer/lnxscreenmode.h $ - * $Revision: 1.3 $ - * $Date: 2004/02/09 04:14:52 $ - * $Author: kevinb $ - * - * - * - * $Log: lnxscreenmode.h,v $ - * Revision 1.3 2004/02/09 04:14:52 kevinb - * Added newlines to all headers to reduce number of warnings printed - * - * Made some small changes to get everything compiling. - * - * All Ready to merge the 1.5 tree. - * - * Revision 1.2 2000/04/28 20:25:51 icculus - * Updates, cleanups, and SDLification. - * - * Revision 1.1.1.1 2000/04/18 00:00:49 icculus - * initial checkin - * - * - * 3 9/06/99 9:21p Jeff - * lock video mode switching, don't set viewport when restoring (causing a - * bunch of screen garbage) - * - * 2 9/05/99 9:41p Jeff - * first checkin of Linux Screen manager - * - * $NoKeywords: $ - */ - -#ifndef __LNXVIDEOMODE_H__ -#define __LNXVIDEOMODE_H__ - -#include - -#define MODE_OK 0 -#define MODE_HSYNC 1 /* hsync out of range */ -#define MODE_VSYNC 2 /* vsync out of range */ -#define MODE_BAD 255 /* unspecified reason */ - -class CLnxVideoModes { -public: - CLnxVideoModes(); - ~CLnxVideoModes(); - - bool Init(void); // Display *dpy,int screen); - void RestoreVideoMode(void); - - // bool QueryExtension(Display *dpy); - // void GetModeLine(Display *dpy,int screen,int *dotclock,XF86VidModeModeLine *modeline); - - bool SwitchResolution(int width, int height); - void Lock(bool lock); - - SDL_Rect **getModes(void) { return m_ModeInfoList; } - Uint32 getSDLFlags(void) { return (sdlflags); } - -private: - // bool SwitchToMode(XF86VidModeModeInfo *mode); - bool LoadLibraries(void); - - bool m_Inited; - bool m_VideoResolutionChanged; - int m_NumVideoModes; - // XF86VidModeModeInfo **m_ModeInfoList; - SDL_Rect **m_ModeInfoList; - Uint32 sdlflags; - // Display *m_Display; - // int m_Screen; -}; - -extern CLnxVideoModes LinuxVideoMode; - -#endif diff --git a/lib/renderer.h b/lib/renderer.h index 9a05bb85b..13aaf4702 100644 --- a/lib/renderer.h +++ b/lib/renderer.h @@ -425,6 +425,7 @@ struct renderer_preferred_state { uint8_t bit_depth; int width, height; uint8_t vsync_on; + bool fullscreen = false; }; struct renderer_lfb { @@ -583,11 +584,17 @@ void rend_DrawSpecialLine(g3Point *p0, g3Point *p1); // Sets some global preferences for the renderer // Returns -1 if it had to use the default resolution/bitdepth -int rend_SetPreferredState(renderer_preferred_state *pref_state); +int rend_SetPreferredState(renderer_preferred_state *pref_state, bool reinit = false); // Sets the gamma value void rend_SetGammaValue(float val); +// Enable or disable fullscreen +void rend_SetFullScreen(bool fullscreen); + +// Init window mode from CLI flags -w/-f +bool rend_InitWindowMode(); + // Fills in the passed in pointer with the current rendering state void rend_GetRenderState(rendering_state *rstate); diff --git a/renderer/CMakeLists.txt b/renderer/CMakeLists.txt index 9d58c029c..a24d2c005 100644 --- a/renderer/CMakeLists.txt +++ b/renderer/CMakeLists.txt @@ -27,7 +27,6 @@ set(CPPS HardwarePoints.cpp HardwareSetup.cpp HardwareTransforms.cpp - lnxscreenmode.cpp ) add_library(renderer STATIC ${HEADERS} ${CPPS}) diff --git a/renderer/HardwareBaseGPU.cpp b/renderer/HardwareBaseGPU.cpp index 80f016300..52305b71e 100644 --- a/renderer/HardwareBaseGPU.cpp +++ b/renderer/HardwareBaseGPU.cpp @@ -1,19 +1,19 @@ /* -* Descent 3 -* Copyright (C) 2024 Descent 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, either version 3 of the License, or -* (at your option) any later version. -* -* 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 . + * Descent 3 + * Copyright (C) 2024 Descent 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, either version 3 of the License, or + * (at your option) any later version. + * + * 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 . */ // TODO: This is missing a good way of overriding base behavior (like, you know, method overrides...) @@ -125,9 +125,7 @@ void rend_SetCharacterParameters(ddgr_color color1, ddgr_color color2, ddgr_colo void rend_SetSoftwareParameters(float aspect, int width, int height, int pitch, uint8_t *framebuffer) {} // Sets the state of bilinear filtering for our textures -void rend_SetFiltering(int8_t state) { - gpu_state.cur_bilinear_state = state; -} +void rend_SetFiltering(int8_t state) { gpu_state.cur_bilinear_state = state; } // Sets a bitmap as a overlay map to rendered on top of the next texture map // a -1 value indicates no overlay map @@ -135,7 +133,6 @@ void rend_SetOverlayMap(int handle) { gpu_Overlay_map = handle; } void rend_SetOverlayType(uint8_t type) { gpu_Overlay_type = type; } - void rend_FillCircle(ddgr_color col, int x, int y, int rad) {} void rend_DrawCircle(int x, int y, int rad) {} @@ -190,9 +187,7 @@ void rend_SetZBias(float z_bias) { // Sets the overall alpha scale factor (all alpha values are scaled by this value) // useful for motion blur effect -void rend_SetAlphaFactor(float val) { - gpu_Alpha_factor = std::clamp(val, 0.0f, 1.0f); -} +void rend_SetAlphaFactor(float val) { gpu_Alpha_factor = std::clamp(val, 0.0f, 1.0f); } // Returns the current Alpha factor float rend_GetAlphaFactor() { return gpu_Alpha_factor; } @@ -343,27 +338,26 @@ void rend_DrawScaledChunkedBitmap(chunked_bitmap *chunk, int x, int y, int neww, } // Sets some global preferences for the renderer -int rend_SetPreferredState(renderer_preferred_state *pref_state) { +int rend_SetPreferredState(renderer_preferred_state *pref_state, bool reinit) { int retval = 1; + renderer_preferred_state old_state = gpu_preferred_state; gpu_preferred_state = *pref_state; if (gpu_state.initted) { - int reinit = 0; LOG_DEBUG << "Inside pref state!"; - // Change gamma if needed + if (old_state.fullscreen != pref_state->fullscreen) { + rend_SetFullScreen(pref_state->fullscreen); + } + if (pref_state->width != gpu_state.screen_width || pref_state->height != gpu_state.screen_height || - old_state.bit_depth != pref_state->bit_depth) { - reinit = 1; + old_state.bit_depth != pref_state->bit_depth || reinit) { + rend_ReInit(); } - if (reinit) { - retval = rend_ReInit(); - } else { - if (old_state.gamma != pref_state->gamma) { - rend_SetGammaValue(pref_state->gamma); - } + if (old_state.gamma != pref_state->gamma) { + rend_SetGammaValue(pref_state->gamma); } } else { gpu_preferred_state = *pref_state; @@ -458,7 +452,8 @@ void rend_DrawPolygon2D(int handle, g3Point **p, int nv) { gpu_RenderPolygon(&vArray[0], nv); } -color_array DeterminePointColor(g3Point const* pnt, bool disableGouraud, bool checkTextureQuality, bool flatColorForNoLight) { +color_array DeterminePointColor(g3Point const *pnt, bool disableGouraud, bool checkTextureQuality, + bool flatColorForNoLight) { auto alpha = gpu_Alpha_multiplier * gpu_Alpha_factor; if (gpu_state.cur_alpha_type & ATF_VERTEX) { alpha *= pnt->p3_a; @@ -512,7 +507,7 @@ void rend_DrawPolygon3D(int handle, g3Point **p, int nv, int map_type) { ASSERT(pnt->p3_flags & PF_ORIGPOINT); vData->color = DeterminePointColor(pnt); - + vData->uv.s = pnt->p3_u; vData->uv.t = pnt->p3_v; vData->uv.r = 0.0f; diff --git a/renderer/HardwareOpenGL.cpp b/renderer/HardwareOpenGL.cpp index e17211a15..3f50525d0 100644 --- a/renderer/HardwareOpenGL.cpp +++ b/renderer/HardwareOpenGL.cpp @@ -1,20 +1,20 @@ /* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* 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, either version 3 of the License, or -* (at your option) any later version. -* -* 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 . -*/ + * Descent 3 + * Copyright (C) 2024 Parallax Software + * + * 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, either version 3 of the License, or + * (at your option) any later version. + * + * 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 #include @@ -69,12 +69,13 @@ extern uint8_t Renderer_initted; renderer_type Renderer_type = RENDERER_OPENGL; struct Renderer { - Renderer() : shader_{shaders::vertex, shaders::fragment, { - vertexAttrib(3, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::pos, "in_pos"), - vertexAttrib(4, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::color, "in_color"), - vertexAttrib(2, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::uv0, "in_uv0"), - vertexAttrib(2, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::uv1, "in_uv1") - }} { + Renderer() + : shader_{shaders::vertex, + shaders::fragment, + {vertexAttrib(3, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::pos, "in_pos"), + vertexAttrib(4, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::color, "in_color"), + vertexAttrib(2, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::uv0, "in_uv0"), + vertexAttrib(2, GL_FLOAT, GL_FALSE, &PosColorUV2Vertex::uv1, "in_uv1")}} { shader_.Use(); // these are effectively just constants, for now @@ -112,35 +113,30 @@ struct Renderer { shader_.setUniform1i("u_texture_enable", texture_enable_); } - template ::value_type, PosColorUV2Vertex>>> + template ::value_type, PosColorUV2Vertex>>> size_t addVertexData(VertexIter begin, VertexIter end) { return shader_.addVertexData(begin, end); } struct PosColorUVVertex_tag {}; - template ::value_type, PosColorUVVertex>>> + template ::value_type, PosColorUVVertex>>> size_t addVertexData(VertexIter begin, VertexIter end, PosColorUVVertex_tag = {}) { std::array converted; - std::transform(begin, end, converted.begin(), [](auto const& vtx) { - return PosColorUV2Vertex{vtx.pos, vtx.color, vtx.uv, {}}; - }); + std::transform(begin, end, converted.begin(), + [](auto const &vtx) { return PosColorUV2Vertex{vtx.pos, vtx.color, vtx.uv, {}}; }); return shader_.addVertexData(converted.cbegin(), converted.cend()); } - void setFogEnabled(bool enabled) { - shader_.setUniform1i("u_fog_enable", enabled); - } + void setFogEnabled(bool enabled) { shader_.setUniform1i("u_fog_enable", enabled); } void setFogBorders(float nearz, float farz) { shader_.setUniform1f("u_fog_start", nearz); shader_.setUniform1f("u_fog_end", farz); } - void setGammaCorrection(float gamma) { - shader_.setUniform1f("u_gamma", gamma); - } + void setGammaCorrection(float gamma) { shader_.setUniform1f("u_gamma", gamma); } void setFogColor(ddgr_color color) { shader_.setUniform4fv("u_fog_color", GR_COLOR_RED(color) / 255.0f, GR_COLOR_GREEN(color) / 255.0f, @@ -230,13 +226,12 @@ static GLuint GOpenGLRBODepth = 0; static GLuint GOpenGLFBOWidth = 0; static GLuint GOpenGLFBOHeight = 0; - // returns true if the passed in extension name is supported bool opengl_CheckExtension(std::string_view extName) { GLint numExtensions; dglGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); for (GLint i = 0; i < numExtensions; i++) { - if (extName == reinterpret_cast(dglGetStringi(GL_EXTENSIONS, i))) { + if (extName == reinterpret_cast(dglGetStringi(GL_EXTENSIONS, i))) { return true; } } @@ -369,8 +364,6 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { } } - bool fullscreen = FindArgChar("-windowed", 'w') == 0; - if (!Already_loaded) { char gl_library[256]; int arg; @@ -378,7 +371,7 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { if (arg != 0) { strcpy(gl_library, GameArgs[arg + 1]); } else { - gl_library[0] = 0; + gl_library[0] = 0; } LOG_INFO.printf("OpenGL: Attempting to use \"%s\" for OpenGL", @@ -410,7 +403,7 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { } // if } - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); @@ -424,24 +417,23 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { int display_arg = FindArg("-display"); int display_count = 0; - //High-DPI support + // High-DPI support { float scale = SDL_GetDisplayContentScale(Display_id); LOG_WARNING.printf("Using content scale %f", scale); - winw = std::floor(static_cast(winw)*scale); - winh = std::floor(static_cast(winh)*scale); + winw = std::floor(static_cast(winw) * scale); + winh = std::floor(static_cast(winh) * scale); } - SDL_PropertiesID props = SDL_CreateProperties(); SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "Descent 3"); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_UNDEFINED_DISPLAY(Display_id)); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_UNDEFINED_DISPLAY(Display_id)); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SDL_WINDOWPOS_UNDEFINED_DISPLAY(Display_id)); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, winw); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, winh); SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, SDL_WINDOW_OPENGL); GSDLWindow = SDL_CreateWindowWithProperties(props); - SDL_DestroyProperties(props); + SDL_DestroyProperties(props); if (!GSDLWindow) { LOG_ERROR.printf("OpenGL: SDL window creation failed: %s", SDL_GetError()); return 0; @@ -451,8 +443,8 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { SDL_SetWindowRelativeMouseMode(GSDLWindow, grabMouse); SDL_SetWindowKeyboardGrab(GSDLWindow, grabMouse); - SDL_SetWindowFullscreen(GSDLWindow, fullscreen); - } else { + rend_SetFullScreen(Game_fullscreen); + } else if (!Game_fullscreen) { SDL_SetWindowSize(GSDLWindow, winw, winh); } @@ -468,7 +460,7 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { try { LoadGLFnPtrs(); - } catch (std::exception const& ex) { + } catch (std::exception const &ex) { // TODO: more raii-esque construction and cleanup here SDL_GL_DestroyContext(GSDLGLContext); GSDLGLContext = nullptr; @@ -482,7 +474,7 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { // clear the window framebuffer to start. dglClearColor(0.0f, 0.0f, 0.0f, 1.0f); - dglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + dglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SDL_GL_SwapWindow(GSDLWindow); /* Tear down the backbuffer and rebuild at new dimensions... */ @@ -498,8 +490,8 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) { GOpenGLFBOWidth = GOpenGLFBOHeight = GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0; } - const GLsizei w = (GLsizei) *width; - const GLsizei h = (GLsizei) *height; + const GLsizei w = (GLsizei)*width; + const GLsizei h = (GLsizei)*height; GOpenGLFBOWidth = w; GOpenGLFBOHeight = h; @@ -723,18 +715,17 @@ void opengl_Close(const bool just_resizing) { gRenderer.reset(); if (GSDLGLContext) { - SDL_GL_MakeCurrent(nullptr, nullptr); - SDL_GL_DestroyContext(GSDLGLContext); - GSDLGLContext = nullptr; - GOpenGLFBOWidth = GOpenGLFBOHeight = GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0; + SDL_GL_MakeCurrent(nullptr, nullptr); + SDL_GL_DestroyContext(GSDLGLContext); + GSDLGLContext = nullptr; + GOpenGLFBOWidth = GOpenGLFBOHeight = GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0; } if (!just_resizing && GSDLWindow) { - SDL_DestroyWindow(GSDLWindow); - GSDLWindow = nullptr; + SDL_DestroyWindow(GSDLWindow); + GSDLWindow = nullptr; } - if (OpenGL_packed_pixels) { if (opengl_packed_Upload_data) { mem_free(opengl_packed_Upload_data); @@ -1128,15 +1119,12 @@ void gpu_DrawFlatPolygon3D(g3Point **p, int nv) { std::array vertices{}; std::transform(p, p + nv, std::begin(vertices), [](auto pnt) { - return PosColorUVVertex{ - pnt->p3_vecPreRot, - DeterminePointColor(pnt, true, false, true), - tex_array{ - // tex coord can be default-constructed, because it will ultimately be ignored - // because this function is only called when cur_texture_quality == 0, and anytime - // that is true, GL_TEXTURE_2D is also disabled - } - }; + return PosColorUVVertex{pnt->p3_vecPreRot, DeterminePointColor(pnt, true, false, true), + tex_array{ + // tex coord can be default-constructed, because it will ultimately be ignored + // because this function is only called when cur_texture_quality == 0, and anytime + // that is true, GL_TEXTURE_2D is also disabled + }}; }); gpu_RenderPolygon(vertices.data(), nv); @@ -1149,6 +1137,35 @@ void rend_SetGammaValue(float val) { LOG_DEBUG.printf("Setting gamma to %f", val); } +void rend_SetFullScreen(bool fullscreen) { + if (GSDLWindow) { + SDL_SetWindowFullscreen(GSDLWindow, fullscreen); + SDL_SyncWindow(GSDLWindow); + } + + if (fullscreen) { + LOG_DEBUG.printf("Entering fullscreen mode"); + } else { + LOG_DEBUG.printf("Exiting fullscreen mode"); + } +} + +bool rend_InitWindowMode() { + int winArg = FindArgChar("-windowed", 'w'); + int fsArg = FindArgChar("-fullscreen", 'f'); + + if ((fsArg) && (winArg)) { + LOG_FATAL.printf("ERROR: %s AND %s specified!", GameArgs[winArg], GameArgs[fsArg]); + return false; + } else if (winArg) { + // Override default value from database + Game_fullscreen = false; + } else if (fsArg) { + Game_fullscreen = true; + } + return true; +} + // Resets the texture cache void opengl_ResetCache() { if (OpenGL_cache_initted) { @@ -1255,7 +1272,7 @@ void opengl_ChangeChunkedBitmap(int bm_handle, chunked_bitmap *chunk) { } // end for d_y } // end for windex - } // end for hindex + } // end for hindex } // Tells the software renderer whether or not to use mipping @@ -1336,14 +1353,10 @@ void gpu_RenderPolygonUV2(PosColorUV2Vertex *vData, uint32_t nv) { void rend_SetFlatColor(ddgr_color color) { gpu_state.cur_color = color; } // Sets the fog state to TRUE or FALSE -void rend_SetFogState(int8_t state) { - gRenderer->setFogEnabled(state); -} +void rend_SetFogState(int8_t state) { gRenderer->setFogEnabled(state); } // Sets the near and far plane of fog -void rend_SetFogBorders(float nearz, float farz) { - gRenderer->setFogBorders(nearz, farz); -} +void rend_SetFogBorders(float nearz, float farz) { gRenderer->setFogBorders(nearz, farz); } void rend_SetRendererType(renderer_type state) { Renderer_type = state; @@ -1429,7 +1442,6 @@ void rend_StartFrame(int x1, int y1, int x2, int y2, int clear_flags) { gpu_state.clip_y2 = y2; } - // Flips the screen void rend_Flip() { #ifndef RELEASE @@ -1440,7 +1452,7 @@ void rend_Flip() { LOG_VERBOSE.printf("Uploads=%d Polys=%d Verts=%d", OpenGL_uploads, OpenGL_polys_drawn, OpenGL_verts_processed); LOG_VERBOSE.printf("Sets= 0:%d 1:%d 2:%d 3:%d", OpenGL_sets_this_frame[0], OpenGL_sets_this_frame[1], - OpenGL_sets_this_frame[2], OpenGL_sets_this_frame[3]); + OpenGL_sets_this_frame[2], OpenGL_sets_this_frame[3]); LOG_VERBOSE.printf("Sets= 4:%d 5:%d", OpenGL_sets_this_frame[4], OpenGL_sets_this_frame[5]); for (i = 0; i < 10; i++) { OpenGL_sets_this_frame[i] = 0; @@ -1463,21 +1475,20 @@ void rend_Flip() { int scaledHeight, scaledWidth; if (w < h) { scaledWidth = w; - scaledHeight = (int) (((((double)GOpenGLFBOHeight) / ((double)GOpenGLFBOWidth))) * ((double)w)); + scaledHeight = (int)(((((double)GOpenGLFBOHeight) / ((double)GOpenGLFBOWidth))) * ((double)w)); } else { scaledHeight = h; - scaledWidth = (int) (((((double)GOpenGLFBOWidth) / ((double)GOpenGLFBOHeight))) * ((double)h)); + scaledWidth = (int)(((((double)GOpenGLFBOWidth) / ((double)GOpenGLFBOHeight))) * ((double)h)); } const int centeredX = (w - scaledWidth) / 2; const int centeredY = (h - scaledHeight) / 2; dglBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - dglClearColor (0.0f, 0.0f, 0.0f, 1.0f); - dglClear(GL_COLOR_BUFFER_BIT); // in case the Steam Overlay wrote to places we don't blit over. - dglBlitFramebuffer(0, 0, GOpenGLFBOWidth, GOpenGLFBOHeight, - centeredX, centeredY, centeredX + scaledWidth, centeredY + scaledHeight, - GL_COLOR_BUFFER_BIT, GL_LINEAR); + dglClearColor(0.0f, 0.0f, 0.0f, 1.0f); + dglClear(GL_COLOR_BUFFER_BIT); // in case the Steam Overlay wrote to places we don't blit over. + dglBlitFramebuffer(0, 0, GOpenGLFBOWidth, GOpenGLFBOHeight, centeredX, centeredY, centeredX + scaledWidth, + centeredY + scaledHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); dglBindFramebuffer(GL_FRAMEBUFFER, 0); } @@ -1565,8 +1576,7 @@ void rend_SetPixel(ddgr_color color, int x, int y) { {static_cast(x), static_cast(y), 0}, {GR_COLOR_RED(color) / 255.0f, GR_COLOR_GREEN(color) / 255.0f, GR_COLOR_BLUE(color) / 255.0f, 1}, {}, - {} - }; + {}}; dglDrawArrays(GL_POINTS, gRenderer->addVertexData(&vtx, &vtx + 1), 1); } @@ -1600,18 +1610,9 @@ void rend_DrawLine(int x1, int y1, int x2, int y2) { }; std::array vertices{ PosColorUV2Vertex{ - {static_cast(x1 + gpu_state.clip_x1), static_cast(y1 + gpu_state.clip_y1), 0}, - color, - {}, - {} - }, + {static_cast(x1 + gpu_state.clip_x1), static_cast(y1 + gpu_state.clip_y1), 0}, color, {}, {}}, PosColorUV2Vertex{ - {static_cast(x2 + gpu_state.clip_x1), static_cast(y2 + gpu_state.clip_y1), 0}, - color, - {}, - {} - } - }; + {static_cast(x2 + gpu_state.clip_x1), static_cast(y2 + gpu_state.clip_y1), 0}, color, {}, {}}}; dglDrawArrays(GL_LINES, gRenderer->addVertexData(vertices.begin(), vertices.end()), vertices.size()); @@ -1621,9 +1622,7 @@ void rend_DrawLine(int x1, int y1, int x2, int y2) { } // Sets the color of fog -void rend_SetFogColor(ddgr_color color) { - gRenderer->setFogColor(color); -} +void rend_SetFogColor(ddgr_color color) { gRenderer->setFogColor(color); } void rend_SetAlphaType(int8_t atype) { if (atype == gpu_state.cur_alpha_type) @@ -1698,7 +1697,8 @@ void rend_DrawSpecialLine(g3Point *p0, g3Point *p1) { // Takes a screenshot of the current frame and puts it into the handle passed std::unique_ptr rend_Screenshot() { - auto result = std::make_unique(gpu_state.screen_width, gpu_state.screen_height, PixelDataFormat::RGBA32, true); + auto result = + std::make_unique(gpu_state.screen_width, gpu_state.screen_height, PixelDataFormat::RGBA32, true); if (!result || result->getData() == nullptr) { return nullptr; @@ -1713,7 +1713,7 @@ std::unique_ptr rend_Screenshot() { // Takes a screenshot of the current frame and puts it into the handle passed void rend_Screenshot(int bm_handle) { auto screenshot = rend_Screenshot(); - auto *temp_data = reinterpret_cast(screenshot->getData()); + auto *temp_data = reinterpret_cast(screenshot->getData()); uint32_t w, h; screenshot->getSize(w, h); @@ -1721,7 +1721,7 @@ void rend_Screenshot(int bm_handle) { ASSERT((bm_w(bm_handle, 0)) == gpu_state.screen_width); ASSERT((bm_h(bm_handle, 0)) == gpu_state.screen_height); - uint16_t* dest_data = bm_data(bm_handle, 0); + uint16_t *dest_data = bm_data(bm_handle, 0); for (std::size_t i = 0; i < h; i++) { for (std::size_t t = 0; t < w; t++) { diff --git a/renderer/lnxscreenmode.cpp b/renderer/lnxscreenmode.cpp deleted file mode 100644 index dbba3281b..000000000 --- a/renderer/lnxscreenmode.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* 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, either version 3 of the License, or -* (at your option) any later version. -* -* 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 . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/Main/renderer/lnxscreenmode.cpp $ - * $Revision: 1.6 $ - * $Date: 2000/06/29 18:48:13 $ - * $Author: icculus $ - * - * - * - * $Log: lnxscreenmode.cpp,v $ - * Revision 1.6 2000/06/29 18:48:13 icculus - * Dumb typo fixed. - * - * Revision 1.5 2000/06/29 06:41:24 icculus - * mad commits. - * - * Revision 1.4 2000/06/24 01:15:15 icculus - * patched to compile. - * - * Revision 1.3 2000/05/29 05:25:57 icculus - * Command line fix: Changed "--nofullscreen" to "--windowed" (or "-w"). - * - * Revision 1.2 2000/04/28 20:25:51 icculus - * Updates, cleanups, and SDLification. - * - * Revision 1.1.1.1 2000/04/18 00:00:49 icculus - * initial checkin - * - * - * 4 9/09/99 4:38p Jeff - * fixed crashes if lib not loaded - * - * 3 9/06/99 9:21p Jeff - * lock video mode switching, don't set viewport when restoring (causing a - * bunch of screen garbage) - * - * 2 9/05/99 9:41p Jeff - * first checkin of Linux Screen manager - * - * $NoKeywords: $ - */ - -#include -#include -#include -#include "lnxscreenmode.h" -#include "pserror.h" -#include "args.h" - -CLnxVideoModes LinuxVideoMode; - -/* -typedef Bool (*VidModeQueryExtension_fp)(Display* dpy,int* event_base,int* error_base); -typedef Bool (*VidModeGetAllModeLines_fp)(Display* dpy,int screen,int* modecount,XF86VidModeModeInfo*** modelinesPtr); -typedef Bool (*VidModeSwitchToMode_fp)(Display* dpy,int screen,XF86VidModeModeInfo* modeline); -typedef Bool (*VidModeSetViewPort_fp)(Display* dpy,int screen,int x,int y); -typedef void (*VidModeFreeData_fp)(int num_modes,XF86VidModeModeInfo** modelinePtr); -typedef Bool (*VidModeGetModeLine_fp)(Display* dpy,int screen,int* dotclock,XF86VidModeModeLine* modeline); -typedef Bool (*VidModeLockModeSwitch_fp)(Display* dpy,int screen,int lock); - -VidModeQueryExtension_fp VidModeQueryExtension; -VidModeGetAllModeLines_fp VidModeGetAllModeLines; -VidModeSwitchToMode_fp VidModeSwitchToMode; -VidModeSetViewPort_fp VidModeSetViewPort; -VidModeFreeData_fp VidModeFreeData; -VidModeGetModeLine_fp VidModeGetModeLine; -VidModeLockModeSwitch_fp VidModeLockModeSwitch; -*/ - -CLnxVideoModes::CLnxVideoModes() { - m_Inited = false; - m_NumVideoModes = 0; - m_ModeInfoList = NULL; - // m_Display = NULL; - m_VideoResolutionChanged = false; - /* - VidModeQueryExtension = NULL; - VidModeGetAllModeLines = NULL; - VidModeSwitchToMode = NULL; - VidModeSetViewPort = NULL; - VidModeFreeData = NULL; - VidModeGetModeLine = NULL; - VidModeLockModeSwitch = NULL; - */ -} - -CLnxVideoModes::~CLnxVideoModes() { - if (!m_Inited) - return; - - // shutdown and free the memory - RestoreVideoMode(); - - // VidModeFreeData(m_NumVideoModes,m_ModeInfoList); -} - -// enumerate all the possible video modes -bool CLnxVideoModes::Init(void) // Display *dpy,int screen) -{ -#if 0 // with SDL2, we'll just use FULLSCREEN_DESKTOP and never change the physical vidmode - if (m_Inited) - return true; - - // m_Display = dpy; - // m_Screen = screen; - m_NumVideoModes = 0; - m_ModeInfoList = NULL; - m_Inited = true; - sdlflags = 0; - /* - if(!LoadLibraries()) - { - m_Inited = false; - fprintf(stdout,"LoadLib: Unable to load VideoMode libraries\n"); - return false; - } - - int dummy; - if(!VidModeQueryExtension(dpy,&dummy,&dummy)) - return false; - - if(!VidModeGetAllModeLines(m_Display,m_Screen,&m_NumVideoModes,&m_ModeInfoList)) - { - m_NumVideoModes = 0; - }else - { - */ - - const SDL_VideoInfo *vidInfo = NULL; - - sdlflags = SDL_HWSURFACE | SDL_FULLSCREEN; - sdlflags = SDL_OPENGL | SDL_FULLSCREEN; - if (FindArgChar("-windowed", 'w')) - sdlflags &= ~SDL_FULLSCREEN; - - vidInfo = SDL_GetVideoInfo(); - - m_ModeInfoList = SDL_ListModes(vidInfo->vfmt, sdlflags); - if (m_ModeInfoList == NULL) { - sdlflags &= ~SDL_FULLSCREEN; - m_ModeInfoList = SDL_ListModes(vidInfo->vfmt, sdlflags); // try without fullscreen. - if (m_ModeInfoList == NULL) { - sdlflags = 0; - m_ModeInfoList = SDL_ListModes(vidInfo->vfmt, sdlflags); // give me ANYTHING. - if (m_ModeInfoList == NULL) { - fprintf(stderr, "SDL: SDL_ListModes() failed.\n"); - return -3; - } // if - } // if - } // if - - if (m_ModeInfoList == (SDL_Rect **)-1) // anything is fine. - { - mprintf(0, "Windowed surface is probably going to be used."); - m_NumVideoModes = 0; - } // if - else { - mprintf(0, "-------------------------\n"); - mprintf(0, "Supported Mode Lines:\n"); - for (int i = 0; m_ModeInfoList[i] != NULL; i++) { - //,m_ModeInfoList[i]->hdisplay,m_ModeInfoList[i]->vdisplay); - mprintf(0, " Mode %d: %dX%d\n", i, m_ModeInfoList[i]->w, m_ModeInfoList[i]->h); - m_NumVideoModes++; - } // for - mprintf(0, "-------------------------\n"); - } // else -#endif - - return true; -} - -bool CLnxVideoModes::SwitchResolution(int width, int height) { - /* - if(!m_Inited) - return false; - - int i; - for(i=0;ihdisplay==width && m_ModeInfoList[i]->vdisplay==height) - { - // found a matching resolution, try to change to it - if(SwitchToMode(m_ModeInfoList[i])) - { - fprintf(stdout,"Mode switch to %dX%d OK!\n",width,height); - m_VideoResolutionChanged = (i==0)?false:true; - return true; - } - } - } - - return false; - */ - return (true); -} - -void CLnxVideoModes::RestoreVideoMode(void) { - /* - if(!m_Inited) - return; - - if(!m_VideoResolutionChanged) - return; - - // index 0 is the original mode - if(m_NumVideoModes<=1) - return; - - m_VideoResolutionChanged = false; - - VidModeSwitchToMode(m_Display,m_Screen,m_ModeInfoList[0]); - */ - return; -} - -/* -bool CLnxVideoModes::SwitchToMode(XF86VidModeModeInfo *mode) -{ - if(!m_Inited) - return false; - - if(!VidModeSwitchToMode(m_Display,m_Screen,mode)) - { - fprintf(stdout,"Video: Unable to switch mode to %dX%d\n",mode->hdisplay,mode->vdisplay); - return false; - } - - VidModeSetViewPort(m_Display,m_Screen,0,0); - return true; -} - -bool CLnxVideoModes::QueryExtension(Display *dpy) -{ - if(!m_Inited) - return false; - - int dummy; - if(!VidModeQueryExtension(dpy,&dummy,&dummy)) - return false; - return true; -} - -void CLnxVideoModes::GetModeLine(Display *dpy,int screen,int *dotclock,XF86VidModeModeLine *modeline) -{ - if(!m_Inited) - return; - - VidModeGetModeLine(dpy,screen,dotclock,modeline); -} -*/ - -void CLnxVideoModes::Lock(bool lock) { - /* - if(!m_Inited) - return; - - VidModeLockModeSwitch(m_Display,m_Screen,(lock)?1:0); - */ -} - -bool CLnxVideoModes::LoadLibraries(void) { - /* - void *handle; - char *libname = "OutrageDynXLib.so"; - handle = dlopen(libname,RTLD_NOW|RTLD_GLOBAL); - if(!handle) - { - fprintf(stderr,"Library Load Failed: %s (%s)\n",libname,dlerror()); - return false; - } - - VidModeQueryExtension = (VidModeQueryExtension_fp)dlsym(handle,"VidModeQueryExtension"); - VidModeGetAllModeLines = (VidModeGetAllModeLines_fp)dlsym(handle,"VidModeGetAllModeLines"); - VidModeSwitchToMode = (VidModeSwitchToMode_fp)dlsym(handle,"VidModeSwitchToMode"); - VidModeSetViewPort = (VidModeSetViewPort_fp)dlsym(handle,"VidModeSetViewPort"); - VidModeFreeData = (VidModeFreeData_fp)dlsym(handle,"VidModeFreeData"); - VidModeGetModeLine = (VidModeGetModeLine_fp)dlsym(handle,"VidModeGetModeLine"); - VidModeLockModeSwitch = (VidModeLockModeSwitch_fp)dlsym(handle,"VidModeLockModeSwitch"); - - if( !VidModeQueryExtension || - !VidModeGetAllModeLines || - !VidModeSwitchToMode || - !VidModeSetViewPort || - !VidModeFreeData || - !VidModeGetModeLine || - !VidModeLockModeSwitch) - { - fprintf(stderr,"Symbol Resolve Error: %s\n",libname); - return false; - } - */ - return true; -}