diff options
Diffstat (limited to 'git-c915049.patch')
-rw-r--r-- | git-c915049.patch | 1119 |
1 files changed, 0 insertions, 1119 deletions
diff --git a/git-c915049.patch b/git-c915049.patch deleted file mode 100644 index accd958c5ea1..000000000000 --- a/git-c915049.patch +++ /dev/null @@ -1,1119 +0,0 @@ -From c9150497e3472e1057ed8286237fcf07106a075d Mon Sep 17 00:00:00 2001 -From: Edoardo Prezioso <edo88@email.it> -Date: Wed, 7 Jan 2015 21:07:40 +0100 -Subject: [PATCH] - Move sdlglvideo code from sdl to posix/sdl. - -Re-add sdlglvideo.cpp path in CMakeLists.txt . Warning: it won't compile yet. ---- - src/CMakeLists.txt | 6 +- - src/posix/sdl/sdlglvideo.cpp | 448 +++++++++++++++++++++++++++++++++++++++++++ - src/posix/sdl/sdlglvideo.h | 82 ++++++++ - src/sdl/sdlglvideo.cpp | 448 ------------------------------------------- - src/sdl/sdlglvideo.h | 82 -------- - 5 files changed, 532 insertions(+), 534 deletions(-) - create mode 100644 src/posix/sdl/sdlglvideo.cpp - create mode 100644 src/posix/sdl/sdlglvideo.h - delete mode 100644 src/sdl/sdlglvideo.cpp - delete mode 100644 src/sdl/sdlglvideo.h - -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 4803006..3edcbaf 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -584,7 +584,8 @@ set( PLAT_SDL_SOURCES - posix/sdl/i_joystick.cpp - posix/sdl/i_main.cpp - posix/sdl/i_timer.cpp -- posix/sdl/sdlvideo.cpp ) -+ posix/sdl/sdlvideo.cpp -+ posix/sdl/sdlglvideo.cpp ) - set( PLAT_OSX_SOURCES - posix/osx/iwadpicker_cocoa.mm - posix/osx/zdoom.icns ) -diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp -new file mode 100644 -index 0000000..649989e ---- /dev/null -+++ b/src/posix/sdl/sdlglvideo.cpp -@@ -0,0 +1,448 @@ -+ -+// HEADER FILES ------------------------------------------------------------ -+ -+#include <iostream> -+ -+#include "doomtype.h" -+ -+#include "templates.h" -+#include "i_system.h" -+#include "i_video.h" -+#include "v_video.h" -+#include "v_pfx.h" -+#include "stats.h" -+#include "version.h" -+#include "c_console.h" -+ -+#include "sdlglvideo.h" -+#include "gl/system/gl_system.h" -+#include "r_defs.h" -+#include "gl/gl_functions.h" -+//#include "gl/gl_intern.h" -+ -+#include "gl/renderer/gl_renderer.h" -+#include "gl/system/gl_framebuffer.h" -+#include "gl/shaders/gl_shader.h" -+#include "gl/utility/gl_templates.h" -+#include "gl/textures/gl_material.h" -+#include "gl/system/gl_cvars.h" -+ -+// MACROS ------------------------------------------------------------------ -+ -+// TYPES ------------------------------------------------------------------- -+ -+IMPLEMENT_ABSTRACT_CLASS(SDLGLFB) -+ -+struct MiniModeInfo -+{ -+ WORD Width, Height; -+}; -+ -+// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- -+ -+// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -+ -+// EXTERNAL DATA DECLARATIONS ---------------------------------------------- -+ -+extern IVideo *Video; -+// extern int vid_renderer; -+ -+EXTERN_CVAR (Float, Gamma) -+EXTERN_CVAR (Int, vid_displaybits) -+EXTERN_CVAR (Int, vid_renderer) -+ -+ -+// PUBLIC DATA DEFINITIONS ------------------------------------------------- -+ -+CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) -+{ -+ Printf("This won't take effect until " GAMENAME " is restarted.\n"); -+} -+ -+// PRIVATE DATA DEFINITIONS ------------------------------------------------ -+ -+// Dummy screen sizes to pass when windowed -+static MiniModeInfo WinModes[] = -+{ -+ { 320, 200 }, -+ { 320, 240 }, -+ { 400, 225 }, // 16:9 -+ { 400, 300 }, -+ { 480, 270 }, // 16:9 -+ { 480, 360 }, -+ { 512, 288 }, // 16:9 -+ { 512, 384 }, -+ { 640, 360 }, // 16:9 -+ { 640, 400 }, -+ { 640, 480 }, -+ { 720, 480 }, // 16:10 -+ { 720, 540 }, -+ { 800, 450 }, // 16:9 -+ { 800, 500 }, // 16:10 -+ { 800, 600 }, -+ { 848, 480 }, // 16:9 -+ { 960, 600 }, // 16:10 -+ { 960, 720 }, -+ { 1024, 576 }, // 16:9 -+ { 1024, 600 }, // 17:10 -+ { 1024, 640 }, // 16:10 -+ { 1024, 768 }, -+ { 1088, 612 }, // 16:9 -+ { 1152, 648 }, // 16:9 -+ { 1152, 720 }, // 16:10 -+ { 1152, 864 }, -+ { 1280, 720 }, // 16:9 -+ { 1280, 800 }, // 16:10 -+ { 1280, 960 }, -+ { 1344, 756 }, // 16:9 -+ { 1360, 768 }, // 16:9 -+ { 1400, 787 }, // 16:9 -+ { 1400, 875 }, // 16:10 -+ { 1440, 900 }, -+ { 1400, 1050 }, -+ { 1600, 900 }, // 16:9 -+ { 1600, 1000 }, // 16:10 -+ { 1600, 1200 }, -+ { 1680, 1050 }, // 16:10 -+ { 1920, 1080 }, // 16:9 -+ { 1920, 1200 }, // 16:10 -+ { 2054, 1536 }, -+ { 2560, 1440 }, // 16:9 -+ { 2880, 1800 } // 16:10 -+}; -+ -+// CODE -------------------------------------------------------------------- -+ -+SDLGLVideo::SDLGLVideo (int parm) -+{ -+ IteratorBits = 0; -+ IteratorFS = false; -+ if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { -+ fprintf( stderr, "Video initialization failed: %s\n", -+ SDL_GetError( ) ); -+ } -+#ifndef _WIN32 -+ // mouse cursor is visible by default on linux systems, we disable it by default -+ SDL_ShowCursor (0); -+#endif -+} -+ -+SDLGLVideo::~SDLGLVideo () -+{ -+ if (GLRenderer != NULL) GLRenderer->FlushTextures(); -+} -+ -+void SDLGLVideo::StartModeIterator (int bits, bool fs) -+{ -+ IteratorMode = 0; -+ IteratorBits = bits; -+ IteratorFS = fs; -+} -+ -+bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) -+{ -+ if (IteratorBits != 8) -+ return false; -+ -+ if (!IteratorFS) -+ { -+ if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) -+ { -+ *width = WinModes[IteratorMode].Width; -+ *height = WinModes[IteratorMode].Height; -+ ++IteratorMode; -+ return true; -+ } -+ } -+ else -+ { -+ SDL_Rect **modes = SDL_ListModes (NULL, SDL_FULLSCREEN|SDL_HWSURFACE); -+ if (modes != NULL && modes[IteratorMode] != NULL) -+ { -+ *width = modes[IteratorMode]->w; -+ *height = modes[IteratorMode]->h; -+ ++IteratorMode; -+ return true; -+ } -+ } -+ return false; -+} -+ -+DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) -+{ -+ static int retry = 0; -+ static int owidth, oheight; -+ -+ PalEntry flashColor; -+// int flashAmount; -+ -+ if (old != NULL) -+ { // Reuse the old framebuffer if its attributes are the same -+ SDLGLFB *fb = static_cast<SDLGLFB *> (old); -+ if (fb->Width == width && -+ fb->Height == height) -+ { -+ bool fsnow = (fb->Screen->flags & SDL_FULLSCREEN) != 0; -+ -+ if (fsnow != fullscreen) -+ { -+ SDL_WM_ToggleFullScreen (fb->Screen); -+ } -+ return old; -+ } -+// old->GetFlash (flashColor, flashAmount); -+ delete old; -+ } -+ else -+ { -+ flashColor = 0; -+// flashAmount = 0; -+ } -+ -+ SDLGLFB *fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); -+ retry = 0; -+ -+ // If we could not create the framebuffer, try again with slightly -+ // different parameters in this order: -+ // 1. Try with the closest size -+ // 2. Try in the opposite screen mode with the original size -+ // 3. Try in the opposite screen mode with the closest size -+ // This is a somewhat confusing mass of recursion here. -+ -+ while (fb == NULL || !fb->IsValid ()) -+ { -+ if (fb != NULL) -+ { -+ delete fb; -+ } -+ -+ switch (retry) -+ { -+ case 0: -+ owidth = width; -+ oheight = height; -+ case 2: -+ // Try a different resolution. Hopefully that will work. -+ I_ClosestResolution (&width, &height, 8); -+ break; -+ -+ case 1: -+ // Try changing fullscreen mode. Maybe that will work. -+ width = owidth; -+ height = oheight; -+ fullscreen = !fullscreen; -+ break; -+ -+ default: -+ // I give up! -+ I_FatalError ("Could not create new screen (%d x %d)", owidth, oheight); -+ -+ fprintf( stderr, "!!! [SDLGLVideo::CreateFrameBuffer] Got beyond I_FatalError !!!" ); -+ return NULL; //[C] actually this shouldn't be reached; probably should be replaced with an ASSERT -+ } -+ -+ ++retry; -+ fb = static_cast<SDLGLFB *>(CreateFrameBuffer (width, height, fullscreen, NULL)); -+ } -+ -+// fb->SetFlash (flashColor, flashAmount); -+ return fb; -+} -+ -+void SDLGLVideo::SetWindowedScale (float scale) -+{ -+} -+ -+bool SDLGLVideo::SetResolution (int width, int height, int bits) -+{ -+ // FIXME: Is it possible to do this without completely destroying the old -+ // interface? -+#ifndef NO_GL -+ -+ if (GLRenderer != NULL) GLRenderer->FlushTextures(); -+ I_ShutdownGraphics(); -+ -+ Video = new SDLGLVideo(0); -+ if (Video == NULL) I_FatalError ("Failed to initialize display"); -+ -+#if (defined(WINDOWS)) || defined(WIN32) -+ bits=32; -+#else -+ bits=24; -+#endif -+ -+ V_DoModeSetup(width, height, bits); -+#endif -+ return true; // We must return true because the old video context no longer exists. -+} -+ -+//========================================================================== -+// -+// -+// -+//========================================================================== -+ -+bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) -+{ -+ 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_ALPHA_SIZE, 8 ); -+ SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); -+ SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); -+// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); -+ if (multisample > 0) { -+ SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); -+ SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); -+ } -+ return true; -+} -+ -+//========================================================================== -+// -+// -+// -+//========================================================================== -+ -+bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) -+{ -+ if (!SetupPixelFormat(allowsoftware, multisample)) -+ { -+ Printf ("R_OPENGL: Reverting to software mode...\n"); -+ return false; -+ } -+ return true; -+} -+ -+ -+// FrameBuffer implementation ----------------------------------------------- -+ -+SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) -+ : DFrameBuffer (width, height) -+{ -+ static int localmultisample=-1; -+ -+ if (localmultisample<0) localmultisample=gl_vid_multisample; -+ -+ int i; -+ -+ m_Lock=0; -+ -+ UpdatePending = false; -+ -+ if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, localmultisample)) -+ { -+ vid_renderer = 0; -+ return; -+ } -+ -+ -+ Screen = SDL_SetVideoMode (width, height, -+ 32, -+ SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT| -+ (fullscreen ? SDL_FULLSCREEN : 0)); -+ -+ if (Screen == NULL) -+ return; -+ -+ m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); -+ -+#if defined(__APPLE__) -+ // Need to set title here because a window is not created yet when calling the same function from main() -+ char caption[100]; -+ mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); -+ SDL_WM_SetCaption(caption, NULL); -+#endif // __APPLE__ -+} -+ -+SDLGLFB::~SDLGLFB () -+{ -+ if (m_supportsGamma) -+ { -+ SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); -+ } -+} -+ -+ -+ -+ -+void SDLGLFB::InitializeState() -+{ -+} -+ -+bool SDLGLFB::CanUpdate () -+{ -+ if (m_Lock != 1) -+ { -+ if (m_Lock > 0) -+ { -+ UpdatePending = true; -+ --m_Lock; -+ } -+ return false; -+ } -+ return true; -+} -+ -+void SDLGLFB::SetGammaTable(WORD *tbl) -+{ -+ SDL_SetGammaRamp(&tbl[0], &tbl[256], &tbl[512]); -+} -+ -+bool SDLGLFB::Lock(bool buffered) -+{ -+ m_Lock++; -+ Buffer = MemBuffer; -+ return true; -+} -+ -+bool SDLGLFB::Lock () -+{ -+ return Lock(false); -+} -+ -+void SDLGLFB::Unlock () -+{ -+ if (UpdatePending && m_Lock == 1) -+ { -+ Update (); -+ } -+ else if (--m_Lock <= 0) -+ { -+ m_Lock = 0; -+ } -+} -+ -+bool SDLGLFB::IsLocked () -+{ -+ return m_Lock>0;// true; -+} -+ -+bool SDLGLFB::IsFullscreen () -+{ -+ return (Screen->flags & SDL_FULLSCREEN) != 0; -+} -+ -+ -+bool SDLGLFB::IsValid () -+{ -+ return DFrameBuffer::IsValid() && Screen != NULL; -+} -+ -+void SDLGLFB::SetVSync( bool vsync ) -+{ -+#if defined (__APPLE__) -+ const GLint value = vsync ? 1 : 0; -+ CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); -+#endif -+} -+ -+void SDLGLFB::NewRefreshRate () -+{ -+} -+ -+void SDLGLFB::SwapBuffers() -+{ -+ SDL_GL_SwapBuffers (); -+} -+ -diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h -new file mode 100644 -index 0000000..205e416 ---- /dev/null -+++ b/src/posix/sdl/sdlglvideo.h -@@ -0,0 +1,82 @@ -+#ifndef __SDLGLVIDEO_H__ -+#define __SDLGLVIDEO_H__ -+ -+#include "hardware.h" -+#include "v_video.h" -+#include <SDL.h> -+#include "gl/system/gl_system.h" -+ -+EXTERN_CVAR (Float, dimamount) -+EXTERN_CVAR (Color, dimcolor) -+ -+struct FRenderer; -+FRenderer *gl_CreateInterface(); -+ -+class SDLGLVideo : public IVideo -+{ -+ public: -+ SDLGLVideo (int parm); -+ ~SDLGLVideo (); -+ -+ EDisplayType GetDisplayType () { return DISPLAY_Both; } -+ void SetWindowedScale (float scale); -+ -+ DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); -+ -+ void StartModeIterator (int bits, bool fs); -+ bool NextMode (int *width, int *height, bool *letterbox); -+ bool SetResolution (int width, int height, int bits); -+ -+ bool SetupPixelFormat(bool allowsoftware, int multisample); -+ bool InitHardware (bool allowsoftware, int multisample); -+ -+private: -+ int IteratorMode; -+ int IteratorBits; -+ bool IteratorFS; -+}; -+class SDLGLFB : public DFrameBuffer -+{ -+ DECLARE_CLASS(SDLGLFB, DFrameBuffer) -+public: -+ // this must have the same parameters as the Windows version, even if they are not used! -+ SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen); -+ ~SDLGLFB (); -+ -+ void ForceBuffering (bool force); -+ bool Lock(bool buffered); -+ bool Lock (); -+ void Unlock(); -+ bool IsLocked (); -+ -+ bool IsValid (); -+ bool IsFullscreen (); -+ -+ virtual void SetVSync( bool vsync ); -+ void SwapBuffers(); -+ -+ void NewRefreshRate (); -+ -+ friend class SDLGLVideo; -+ -+//[C] -+ int GetTrueHeight() { return GetHeight();} -+ -+protected: -+ bool CanUpdate(); -+ void SetGammaTable(WORD *tbl); -+ void InitializeState(); -+ -+ SDLGLFB () {} -+ BYTE GammaTable[3][256]; -+ bool UpdatePending; -+ -+ SDL_Surface *Screen; -+ -+ void UpdateColors (); -+ -+ int m_Lock; -+ Uint16 m_origGamma[3][256]; -+ bool m_supportsGamma; -+}; -+#endif -diff --git a/src/sdl/sdlglvideo.cpp b/src/sdl/sdlglvideo.cpp -deleted file mode 100644 -index 649989e..0000000 ---- a/src/sdl/sdlglvideo.cpp -+++ /dev/null -@@ -1,448 +0,0 @@ -- --// HEADER FILES ------------------------------------------------------------ -- --#include <iostream> -- --#include "doomtype.h" -- --#include "templates.h" --#include "i_system.h" --#include "i_video.h" --#include "v_video.h" --#include "v_pfx.h" --#include "stats.h" --#include "version.h" --#include "c_console.h" -- --#include "sdlglvideo.h" --#include "gl/system/gl_system.h" --#include "r_defs.h" --#include "gl/gl_functions.h" --//#include "gl/gl_intern.h" -- --#include "gl/renderer/gl_renderer.h" --#include "gl/system/gl_framebuffer.h" --#include "gl/shaders/gl_shader.h" --#include "gl/utility/gl_templates.h" --#include "gl/textures/gl_material.h" --#include "gl/system/gl_cvars.h" -- --// MACROS ------------------------------------------------------------------ -- --// TYPES ------------------------------------------------------------------- -- --IMPLEMENT_ABSTRACT_CLASS(SDLGLFB) -- --struct MiniModeInfo --{ -- WORD Width, Height; --}; -- --// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- -- --// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -- --// EXTERNAL DATA DECLARATIONS ---------------------------------------------- -- --extern IVideo *Video; --// extern int vid_renderer; -- --EXTERN_CVAR (Float, Gamma) --EXTERN_CVAR (Int, vid_displaybits) --EXTERN_CVAR (Int, vid_renderer) -- -- --// PUBLIC DATA DEFINITIONS ------------------------------------------------- -- --CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) --{ -- Printf("This won't take effect until " GAMENAME " is restarted.\n"); --} -- --// PRIVATE DATA DEFINITIONS ------------------------------------------------ -- --// Dummy screen sizes to pass when windowed --static MiniModeInfo WinModes[] = --{ -- { 320, 200 }, -- { 320, 240 }, -- { 400, 225 }, // 16:9 -- { 400, 300 }, -- { 480, 270 }, // 16:9 -- { 480, 360 }, -- { 512, 288 }, // 16:9 -- { 512, 384 }, -- { 640, 360 }, // 16:9 -- { 640, 400 }, -- { 640, 480 }, -- { 720, 480 }, // 16:10 -- { 720, 540 }, -- { 800, 450 }, // 16:9 -- { 800, 500 }, // 16:10 -- { 800, 600 }, -- { 848, 480 }, // 16:9 -- { 960, 600 }, // 16:10 -- { 960, 720 }, -- { 1024, 576 }, // 16:9 -- { 1024, 600 }, // 17:10 -- { 1024, 640 }, // 16:10 -- { 1024, 768 }, -- { 1088, 612 }, // 16:9 -- { 1152, 648 }, // 16:9 -- { 1152, 720 }, // 16:10 -- { 1152, 864 }, -- { 1280, 720 }, // 16:9 -- { 1280, 800 }, // 16:10 -- { 1280, 960 }, -- { 1344, 756 }, // 16:9 -- { 1360, 768 }, // 16:9 -- { 1400, 787 }, // 16:9 -- { 1400, 875 }, // 16:10 -- { 1440, 900 }, -- { 1400, 1050 }, -- { 1600, 900 }, // 16:9 -- { 1600, 1000 }, // 16:10 -- { 1600, 1200 }, -- { 1680, 1050 }, // 16:10 -- { 1920, 1080 }, // 16:9 -- { 1920, 1200 }, // 16:10 -- { 2054, 1536 }, -- { 2560, 1440 }, // 16:9 -- { 2880, 1800 } // 16:10 --}; -- --// CODE -------------------------------------------------------------------- -- --SDLGLVideo::SDLGLVideo (int parm) --{ -- IteratorBits = 0; -- IteratorFS = false; -- if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { -- fprintf( stderr, "Video initialization failed: %s\n", -- SDL_GetError( ) ); -- } --#ifndef _WIN32 -- // mouse cursor is visible by default on linux systems, we disable it by default -- SDL_ShowCursor (0); --#endif --} -- --SDLGLVideo::~SDLGLVideo () --{ -- if (GLRenderer != NULL) GLRenderer->FlushTextures(); --} -- --void SDLGLVideo::StartModeIterator (int bits, bool fs) --{ -- IteratorMode = 0; -- IteratorBits = bits; -- IteratorFS = fs; --} -- --bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) --{ -- if (IteratorBits != 8) -- return false; -- -- if (!IteratorFS) -- { -- if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) -- { -- *width = WinModes[IteratorMode].Width; -- *height = WinModes[IteratorMode].Height; -- ++IteratorMode; -- return true; -- } -- } -- else -- { -- SDL_Rect **modes = SDL_ListModes (NULL, SDL_FULLSCREEN|SDL_HWSURFACE); -- if (modes != NULL && modes[IteratorMode] != NULL) -- { -- *width = modes[IteratorMode]->w; -- *height = modes[IteratorMode]->h; -- ++IteratorMode; -- return true; -- } -- } -- return false; --} -- --DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) --{ -- static int retry = 0; -- static int owidth, oheight; -- -- PalEntry flashColor; --// int flashAmount; -- -- if (old != NULL) -- { // Reuse the old framebuffer if its attributes are the same -- SDLGLFB *fb = static_cast<SDLGLFB *> (old); -- if (fb->Width == width && -- fb->Height == height) -- { -- bool fsnow = (fb->Screen->flags & SDL_FULLSCREEN) != 0; -- -- if (fsnow != fullscreen) -- { -- SDL_WM_ToggleFullScreen (fb->Screen); -- } -- return old; -- } --// old->GetFlash (flashColor, flashAmount); -- delete old; -- } -- else -- { -- flashColor = 0; --// flashAmount = 0; -- } -- -- SDLGLFB *fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); -- retry = 0; -- -- // If we could not create the framebuffer, try again with slightly -- // different parameters in this order: -- // 1. Try with the closest size -- // 2. Try in the opposite screen mode with the original size -- // 3. Try in the opposite screen mode with the closest size -- // This is a somewhat confusing mass of recursion here. -- -- while (fb == NULL || !fb->IsValid ()) -- { -- if (fb != NULL) -- { -- delete fb; -- } -- -- switch (retry) -- { -- case 0: -- owidth = width; -- oheight = height; -- case 2: -- // Try a different resolution. Hopefully that will work. -- I_ClosestResolution (&width, &height, 8); -- break; -- -- case 1: -- // Try changing fullscreen mode. Maybe that will work. -- width = owidth; -- height = oheight; -- fullscreen = !fullscreen; -- break; -- -- default: -- // I give up! -- I_FatalError ("Could not create new screen (%d x %d)", owidth, oheight); -- -- fprintf( stderr, "!!! [SDLGLVideo::CreateFrameBuffer] Got beyond I_FatalError !!!" ); -- return NULL; //[C] actually this shouldn't be reached; probably should be replaced with an ASSERT -- } -- -- ++retry; -- fb = static_cast<SDLGLFB *>(CreateFrameBuffer (width, height, fullscreen, NULL)); -- } -- --// fb->SetFlash (flashColor, flashAmount); -- return fb; --} -- --void SDLGLVideo::SetWindowedScale (float scale) --{ --} -- --bool SDLGLVideo::SetResolution (int width, int height, int bits) --{ -- // FIXME: Is it possible to do this without completely destroying the old -- // interface? --#ifndef NO_GL -- -- if (GLRenderer != NULL) GLRenderer->FlushTextures(); -- I_ShutdownGraphics(); -- -- Video = new SDLGLVideo(0); -- if (Video == NULL) I_FatalError ("Failed to initialize display"); -- --#if (defined(WINDOWS)) || defined(WIN32) -- bits=32; --#else -- bits=24; --#endif -- -- V_DoModeSetup(width, height, bits); --#endif -- return true; // We must return true because the old video context no longer exists. --} -- --//========================================================================== --// --// --// --//========================================================================== -- --bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) --{ -- 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_ALPHA_SIZE, 8 ); -- SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); -- SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); --// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); -- if (multisample > 0) { -- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); -- SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); -- } -- return true; --} -- --//========================================================================== --// --// --// --//========================================================================== -- --bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) --{ -- if (!SetupPixelFormat(allowsoftware, multisample)) -- { -- Printf ("R_OPENGL: Reverting to software mode...\n"); -- return false; -- } -- return true; --} -- -- --// FrameBuffer implementation ----------------------------------------------- -- --SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) -- : DFrameBuffer (width, height) --{ -- static int localmultisample=-1; -- -- if (localmultisample<0) localmultisample=gl_vid_multisample; -- -- int i; -- -- m_Lock=0; -- -- UpdatePending = false; -- -- if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, localmultisample)) -- { -- vid_renderer = 0; -- return; -- } -- -- -- Screen = SDL_SetVideoMode (width, height, -- 32, -- SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT| -- (fullscreen ? SDL_FULLSCREEN : 0)); -- -- if (Screen == NULL) -- return; -- -- m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); -- --#if defined(__APPLE__) -- // Need to set title here because a window is not created yet when calling the same function from main() -- char caption[100]; -- mysnprintf(caption, countof(caption), GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); -- SDL_WM_SetCaption(caption, NULL); --#endif // __APPLE__ --} -- --SDLGLFB::~SDLGLFB () --{ -- if (m_supportsGamma) -- { -- SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]); -- } --} -- -- -- -- --void SDLGLFB::InitializeState() --{ --} -- --bool SDLGLFB::CanUpdate () --{ -- if (m_Lock != 1) -- { -- if (m_Lock > 0) -- { -- UpdatePending = true; -- --m_Lock; -- } -- return false; -- } -- return true; --} -- --void SDLGLFB::SetGammaTable(WORD *tbl) --{ -- SDL_SetGammaRamp(&tbl[0], &tbl[256], &tbl[512]); --} -- --bool SDLGLFB::Lock(bool buffered) --{ -- m_Lock++; -- Buffer = MemBuffer; -- return true; --} -- --bool SDLGLFB::Lock () --{ -- return Lock(false); --} -- --void SDLGLFB::Unlock () --{ -- if (UpdatePending && m_Lock == 1) -- { -- Update (); -- } -- else if (--m_Lock <= 0) -- { -- m_Lock = 0; -- } --} -- --bool SDLGLFB::IsLocked () --{ -- return m_Lock>0;// true; --} -- --bool SDLGLFB::IsFullscreen () --{ -- return (Screen->flags & SDL_FULLSCREEN) != 0; --} -- -- --bool SDLGLFB::IsValid () --{ -- return DFrameBuffer::IsValid() && Screen != NULL; --} -- --void SDLGLFB::SetVSync( bool vsync ) --{ --#if defined (__APPLE__) -- const GLint value = vsync ? 1 : 0; -- CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); --#endif --} -- --void SDLGLFB::NewRefreshRate () --{ --} -- --void SDLGLFB::SwapBuffers() --{ -- SDL_GL_SwapBuffers (); --} -- -diff --git a/src/sdl/sdlglvideo.h b/src/sdl/sdlglvideo.h -deleted file mode 100644 -index 205e416..0000000 ---- a/src/sdl/sdlglvideo.h -+++ /dev/null -@@ -1,82 +0,0 @@ --#ifndef __SDLGLVIDEO_H__ --#define __SDLGLVIDEO_H__ -- --#include "hardware.h" --#include "v_video.h" --#include <SDL.h> --#include "gl/system/gl_system.h" -- --EXTERN_CVAR (Float, dimamount) --EXTERN_CVAR (Color, dimcolor) -- --struct FRenderer; --FRenderer *gl_CreateInterface(); -- --class SDLGLVideo : public IVideo --{ -- public: -- SDLGLVideo (int parm); -- ~SDLGLVideo (); -- -- EDisplayType GetDisplayType () { return DISPLAY_Both; } -- void SetWindowedScale (float scale); -- -- DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); -- -- void StartModeIterator (int bits, bool fs); -- bool NextMode (int *width, int *height, bool *letterbox); -- bool SetResolution (int width, int height, int bits); -- -- bool SetupPixelFormat(bool allowsoftware, int multisample); -- bool InitHardware (bool allowsoftware, int multisample); -- --private: -- int IteratorMode; -- int IteratorBits; -- bool IteratorFS; --}; --class SDLGLFB : public DFrameBuffer --{ -- DECLARE_CLASS(SDLGLFB, DFrameBuffer) --public: -- // this must have the same parameters as the Windows version, even if they are not used! -- SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen); -- ~SDLGLFB (); -- -- void ForceBuffering (bool force); -- bool Lock(bool buffered); -- bool Lock (); -- void Unlock(); -- bool IsLocked (); -- -- bool IsValid (); -- bool IsFullscreen (); -- -- virtual void SetVSync( bool vsync ); -- void SwapBuffers(); -- -- void NewRefreshRate (); -- -- friend class SDLGLVideo; -- --//[C] -- int GetTrueHeight() { return GetHeight();} -- --protected: -- bool CanUpdate(); -- void SetGammaTable(WORD *tbl); -- void InitializeState(); -- -- SDLGLFB () {} -- BYTE GammaTable[3][256]; -- bool UpdatePending; -- -- SDL_Surface *Screen; -- -- void UpdateColors (); -- -- int m_Lock; -- Uint16 m_origGamma[3][256]; -- bool m_supportsGamma; --}; --#endif --- -2.3.2 - |