mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-15 00:51:24 +00:00
Merge branch 'SDL2_gz' of https://github.com/edward-san/zdoom
This commit is contained in:
commit
df93d1a9f1
3 changed files with 61 additions and 62 deletions
|
@ -584,13 +584,11 @@ set( PLAT_SDL_SOURCES
|
||||||
posix/sdl/i_joystick.cpp
|
posix/sdl/i_joystick.cpp
|
||||||
posix/sdl/i_main.cpp
|
posix/sdl/i_main.cpp
|
||||||
posix/sdl/i_timer.cpp
|
posix/sdl/i_timer.cpp
|
||||||
posix/sdl/sdlvideo.cpp )
|
posix/sdl/sdlvideo.cpp
|
||||||
|
posix/sdl/sdlglvideo.cpp )
|
||||||
set( PLAT_OSX_SOURCES
|
set( PLAT_OSX_SOURCES
|
||||||
posix/osx/iwadpicker_cocoa.mm
|
posix/osx/iwadpicker_cocoa.mm
|
||||||
posix/osx/zdoom.icns )
|
posix/osx/zdoom.icns )
|
||||||
|
|
||||||
# Fixme: This must be adjusted to the new way of doing things:
|
|
||||||
# sdl/sdlglvideo.cpp
|
|
||||||
set( PLAT_COCOA_SOURCES
|
set( PLAT_COCOA_SOURCES
|
||||||
posix/cocoa/critsec.cpp
|
posix/cocoa/critsec.cpp
|
||||||
posix/cocoa/i_input.mm
|
posix/cocoa/i_input.mm
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
// HEADER FILES ------------------------------------------------------------
|
// HEADER FILES ------------------------------------------------------------
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
|
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
|
@ -48,6 +46,7 @@ extern IVideo *Video;
|
||||||
// extern int vid_renderer;
|
// extern int vid_renderer;
|
||||||
|
|
||||||
EXTERN_CVAR (Float, Gamma)
|
EXTERN_CVAR (Float, Gamma)
|
||||||
|
EXTERN_CVAR (Int, vid_adapter)
|
||||||
EXTERN_CVAR (Int, vid_displaybits)
|
EXTERN_CVAR (Int, vid_displaybits)
|
||||||
EXTERN_CVAR (Int, vid_renderer)
|
EXTERN_CVAR (Int, vid_renderer)
|
||||||
|
|
||||||
|
@ -78,6 +77,7 @@ static MiniModeInfo WinModes[] =
|
||||||
{ 720, 480 }, // 16:10
|
{ 720, 480 }, // 16:10
|
||||||
{ 720, 540 },
|
{ 720, 540 },
|
||||||
{ 800, 450 }, // 16:9
|
{ 800, 450 }, // 16:9
|
||||||
|
{ 800, 480 },
|
||||||
{ 800, 500 }, // 16:10
|
{ 800, 500 }, // 16:10
|
||||||
{ 800, 600 },
|
{ 800, 600 },
|
||||||
{ 848, 480 }, // 16:9
|
{ 848, 480 }, // 16:9
|
||||||
|
@ -92,23 +92,33 @@ static MiniModeInfo WinModes[] =
|
||||||
{ 1152, 720 }, // 16:10
|
{ 1152, 720 }, // 16:10
|
||||||
{ 1152, 864 },
|
{ 1152, 864 },
|
||||||
{ 1280, 720 }, // 16:9
|
{ 1280, 720 }, // 16:9
|
||||||
|
{ 1280, 854 },
|
||||||
{ 1280, 800 }, // 16:10
|
{ 1280, 800 }, // 16:10
|
||||||
{ 1280, 960 },
|
{ 1280, 960 },
|
||||||
{ 1344, 756 }, // 16:9
|
{ 1280, 1024 }, // 5:4
|
||||||
{ 1360, 768 }, // 16:9
|
{ 1360, 768 }, // 16:9
|
||||||
|
{ 1366, 768 },
|
||||||
{ 1400, 787 }, // 16:9
|
{ 1400, 787 }, // 16:9
|
||||||
{ 1400, 875 }, // 16:10
|
{ 1400, 875 }, // 16:10
|
||||||
{ 1440, 900 },
|
|
||||||
{ 1400, 1050 },
|
{ 1400, 1050 },
|
||||||
|
{ 1440, 900 },
|
||||||
|
{ 1440, 960 },
|
||||||
|
{ 1440, 1080 },
|
||||||
{ 1600, 900 }, // 16:9
|
{ 1600, 900 }, // 16:9
|
||||||
{ 1600, 1000 }, // 16:10
|
{ 1600, 1000 }, // 16:10
|
||||||
{ 1600, 1200 },
|
{ 1600, 1200 },
|
||||||
{ 1680, 1050 }, // 16:10
|
{ 1920, 1080 },
|
||||||
{ 1920, 1080 }, // 16:9
|
{ 1920, 1200 },
|
||||||
{ 1920, 1200 }, // 16:10
|
{ 2048, 1536 },
|
||||||
{ 2054, 1536 },
|
{ 2560, 1440 },
|
||||||
{ 2560, 1440 }, // 16:9
|
{ 2560, 1600 },
|
||||||
{ 2880, 1800 } // 16:10
|
{ 2560, 2048 },
|
||||||
|
{ 2880, 1800 },
|
||||||
|
{ 3200, 1800 },
|
||||||
|
{ 3840, 2160 },
|
||||||
|
{ 3840, 2400 },
|
||||||
|
{ 4096, 2160 },
|
||||||
|
{ 5120, 2880 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CODE --------------------------------------------------------------------
|
// CODE --------------------------------------------------------------------
|
||||||
|
@ -116,7 +126,6 @@ static MiniModeInfo WinModes[] =
|
||||||
SDLGLVideo::SDLGLVideo (int parm)
|
SDLGLVideo::SDLGLVideo (int parm)
|
||||||
{
|
{
|
||||||
IteratorBits = 0;
|
IteratorBits = 0;
|
||||||
IteratorFS = false;
|
|
||||||
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
|
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
|
||||||
fprintf( stderr, "Video initialization failed: %s\n",
|
fprintf( stderr, "Video initialization failed: %s\n",
|
||||||
SDL_GetError( ) );
|
SDL_GetError( ) );
|
||||||
|
@ -136,7 +145,6 @@ void SDLGLVideo::StartModeIterator (int bits, bool fs)
|
||||||
{
|
{
|
||||||
IteratorMode = 0;
|
IteratorMode = 0;
|
||||||
IteratorBits = bits;
|
IteratorBits = bits;
|
||||||
IteratorFS = fs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
||||||
|
@ -144,26 +152,12 @@ bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
||||||
if (IteratorBits != 8)
|
if (IteratorBits != 8)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!IteratorFS)
|
if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0]))
|
||||||
{
|
{
|
||||||
if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0]))
|
*width = WinModes[IteratorMode].Width;
|
||||||
{
|
*height = WinModes[IteratorMode].Height;
|
||||||
*width = WinModes[IteratorMode].Width;
|
++IteratorMode;
|
||||||
*height = WinModes[IteratorMode].Height;
|
return true;
|
||||||
++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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -182,11 +176,11 @@ DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscr
|
||||||
if (fb->Width == width &&
|
if (fb->Width == width &&
|
||||||
fb->Height == height)
|
fb->Height == height)
|
||||||
{
|
{
|
||||||
bool fsnow = (fb->Screen->flags & SDL_FULLSCREEN) != 0;
|
bool fsnow = (SDL_GetWindowFlags (fb->Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;
|
||||||
|
|
||||||
if (fsnow != fullscreen)
|
if (fsnow != fullscreen)
|
||||||
{
|
{
|
||||||
SDL_WM_ToggleFullScreen (fb->Screen);
|
SDL_SetWindowFullscreen (fb->Screen, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
}
|
}
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +284,7 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
|
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
|
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
|
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
|
||||||
// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||||
if (multisample > 0) {
|
if (multisample > 0) {
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample );
|
||||||
|
@ -336,30 +330,37 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString caption;
|
||||||
Screen = SDL_SetVideoMode (width, height,
|
caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime());
|
||||||
32,
|
Screen = SDL_CreateWindow (caption,
|
||||||
SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT|
|
SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter),
|
||||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
width, height, (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)|SDL_WINDOW_OPENGL);
|
||||||
|
|
||||||
if (Screen == NULL)
|
if (Screen == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_supportsGamma = -1 != SDL_GetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
GLContext = SDL_GL_CreateContext(Screen);
|
||||||
|
if (GLContext == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
m_supportsGamma = -1 != SDL_GetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
||||||
// 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 ()
|
SDLGLFB::~SDLGLFB ()
|
||||||
{
|
{
|
||||||
if (m_supportsGamma)
|
if (Screen)
|
||||||
{
|
{
|
||||||
SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
if (m_supportsGamma)
|
||||||
|
{
|
||||||
|
SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_DeleteContext(GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyWindow(Screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +387,7 @@ bool SDLGLFB::CanUpdate ()
|
||||||
|
|
||||||
void SDLGLFB::SetGammaTable(WORD *tbl)
|
void SDLGLFB::SetGammaTable(WORD *tbl)
|
||||||
{
|
{
|
||||||
SDL_SetGammaRamp(&tbl[0], &tbl[256], &tbl[512]);
|
SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLGLFB::Lock(bool buffered)
|
bool SDLGLFB::Lock(bool buffered)
|
||||||
|
@ -420,7 +421,7 @@ bool SDLGLFB::IsLocked ()
|
||||||
|
|
||||||
bool SDLGLFB::IsFullscreen ()
|
bool SDLGLFB::IsFullscreen ()
|
||||||
{
|
{
|
||||||
return (Screen->flags & SDL_FULLSCREEN) != 0;
|
return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,6 +444,6 @@ void SDLGLFB::NewRefreshRate ()
|
||||||
|
|
||||||
void SDLGLFB::SwapBuffers()
|
void SDLGLFB::SwapBuffers()
|
||||||
{
|
{
|
||||||
SDL_GL_SwapBuffers ();
|
SDL_GL_SwapWindow (Screen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include <SDL.h>
|
|
||||||
#include "gl/system/gl_system.h"
|
#include "gl/system/gl_system.h"
|
||||||
|
|
||||||
EXTERN_CVAR (Float, dimamount)
|
EXTERN_CVAR (Float, dimamount)
|
||||||
|
@ -33,7 +32,6 @@ class SDLGLVideo : public IVideo
|
||||||
private:
|
private:
|
||||||
int IteratorMode;
|
int IteratorMode;
|
||||||
int IteratorBits;
|
int IteratorBits;
|
||||||
bool IteratorFS;
|
|
||||||
};
|
};
|
||||||
class SDLGLFB : public DFrameBuffer
|
class SDLGLFB : public DFrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -71,7 +69,9 @@ protected:
|
||||||
BYTE GammaTable[3][256];
|
BYTE GammaTable[3][256];
|
||||||
bool UpdatePending;
|
bool UpdatePending;
|
||||||
|
|
||||||
SDL_Surface *Screen;
|
SDL_Window *Screen;
|
||||||
|
|
||||||
|
SDL_GLContext GLContext;
|
||||||
|
|
||||||
void UpdateColors ();
|
void UpdateColors ();
|
||||||
|
|
Loading…
Reference in a new issue