mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- Implement SDL2 into GZDoom (needs improvements).
Make also minor fixes. Now it compiles and runs fine for me, except for the invisible cursor in the menu (no idea why).
This commit is contained in:
parent
c9150497e3
commit
37321d1d48
2 changed files with 44 additions and 32 deletions
|
@ -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)
|
||||||
|
|
||||||
|
@ -156,15 +155,20 @@ bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_Rect **modes = SDL_ListModes (NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
|
SDL_DisplayMode mode = {}, oldmode = {};
|
||||||
if (modes != NULL && modes[IteratorMode] != NULL)
|
if(IteratorMode != 0)
|
||||||
|
SDL_GetDisplayMode(vid_adapter, IteratorMode-1, &oldmode);
|
||||||
|
do
|
||||||
{
|
{
|
||||||
*width = modes[IteratorMode]->w;
|
if (SDL_GetDisplayMode(vid_adapter, IteratorMode, &mode) != 0)
|
||||||
*height = modes[IteratorMode]->h;
|
return false;
|
||||||
++IteratorMode;
|
++IteratorMode;
|
||||||
|
} while(mode.w == oldmode.w && mode.h == oldmode.h);
|
||||||
|
|
||||||
|
*width = mode.w;
|
||||||
|
*height = mode.h;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,11 +186,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;
|
||||||
}
|
}
|
||||||
|
@ -336,30 +340,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 (Screen)
|
||||||
|
{
|
||||||
if (m_supportsGamma)
|
if (m_supportsGamma)
|
||||||
{
|
{
|
||||||
SDL_SetGammaRamp(m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GLContext)
|
||||||
|
{
|
||||||
|
SDL_GL_DeleteContext(GLContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_DestroyWindow(Screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +397,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 +431,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 +454,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)
|
||||||
|
@ -71,7 +70,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