mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-05-31 00:41:38 +00:00
Added support for SDL 2.0
This commit is contained in:
parent
202c54ffff
commit
d7888cf99d
6 changed files with 261 additions and 12 deletions
|
@ -9,6 +9,9 @@ option(USE_MFC_TOOLS
|
||||||
option(MONOLITH
|
option(MONOLITH
|
||||||
"Embed game logic into main executable" ON)
|
"Embed game logic into main executable" ON)
|
||||||
|
|
||||||
|
option(SDL2
|
||||||
|
"Use SDL2 instead of SDL1.2" OFF)
|
||||||
|
|
||||||
#option(STANDALONE
|
#option(STANDALONE
|
||||||
# "Skip Doom 3 base/ folder" ON)
|
# "Skip Doom 3 base/ folder" ON)
|
||||||
|
|
||||||
|
@ -1050,9 +1053,15 @@ else()
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
|
||||||
find_package(SDL REQUIRED)
|
if(SDL2)
|
||||||
include_directories(${SDL_INCLUDE_DIR})
|
find_package(SDL2 REQUIRED)
|
||||||
set(SDLx_LIBRARY ${SDL_LIBRARY})
|
include_directories(${SDL2_INCLUDE_DIR})
|
||||||
|
set(SDLx_LIBRARY ${SDL2_LIBRARY})
|
||||||
|
else()
|
||||||
|
find_package(SDL REQUIRED)
|
||||||
|
include_directories(${SDL_INCLUDE_DIR})
|
||||||
|
set(SDLx_LIBRARY ${SDL_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND RBDOOM3_SOURCES
|
list(APPEND RBDOOM3_SOURCES
|
||||||
${POSIX_INCLUDES} ${POSIX_SOURCES}
|
${POSIX_INCLUDES} ${POSIX_SOURCES}
|
||||||
|
|
163
neo/cmake/FindSDL2.cmake
Normal file
163
neo/cmake/FindSDL2.cmake
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
# Locate SDL2 library
|
||||||
|
# This module defines
|
||||||
|
# SDL2_LIBRARY, the name of the library to link against
|
||||||
|
# SDL2_FOUND, if false, do not try to link to SDL2
|
||||||
|
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||||
|
#
|
||||||
|
# This module responds to the the flag:
|
||||||
|
# SDL2_BUILDING_LIBRARY
|
||||||
|
# If this is defined, then no SDL2main will be linked in because
|
||||||
|
# only applications need main().
|
||||||
|
# Otherwise, it is assumed you are building an application and this
|
||||||
|
# module will attempt to locate and set the the proper link flags
|
||||||
|
# as part of the returned SDL2_LIBRARY variable.
|
||||||
|
#
|
||||||
|
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||||
|
# OS X framework based version. (Other versions link to -lSDL2main which
|
||||||
|
# this module will try to find on your behalf.) Also for OS X, this
|
||||||
|
# module will automatically add the -framework Cocoa on your behalf.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
|
||||||
|
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
|
||||||
|
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
|
||||||
|
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
||||||
|
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
||||||
|
# as appropriate. These values are used to generate the final SDL2_LIBRARY
|
||||||
|
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# $SDL2DIR is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SDL2DIR
|
||||||
|
# used in building SDL2.
|
||||||
|
# l.e.galup 9-20-02
|
||||||
|
#
|
||||||
|
# Modified by Eric Wing.
|
||||||
|
# Added code to assist with automated building by using environmental variables
|
||||||
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
# Added new modifications to recognize OS X frameworks and
|
||||||
|
# additional Unix paths (FreeBSD, etc).
|
||||||
|
# Also corrected the header search path to follow "proper" SDL guidelines.
|
||||||
|
# Added a search for SDL2main which is needed by some platforms.
|
||||||
|
# Added a search for threads which is needed by some platforms.
|
||||||
|
# Added needed compile switches for MinGW.
|
||||||
|
#
|
||||||
|
# On OSX, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SDL2_LIBRARY to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
#
|
||||||
|
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
|
||||||
|
# This needed to change because "proper" SDL convention
|
||||||
|
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
|
||||||
|
# reasons because not all systems place things in SDL2/ (see FreeBSD).
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2003-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
SET(SDL2_SEARCH_PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES include/SDL2 include
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(SDL2_LIBRARY_TEMP
|
||||||
|
NAMES SDL2
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
# Non-OS X framework versions expect you to also dynamically link to
|
||||||
|
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||||
|
# seem to provide SDL2main for compatibility even though they don't
|
||||||
|
# necessarily need it.
|
||||||
|
FIND_LIBRARY(SDL2MAIN_LIBRARY
|
||||||
|
NAMES SDL2main
|
||||||
|
HINTS
|
||||||
|
$ENV{SDL2DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS ${SDL2_SEARCH_PATHS}
|
||||||
|
)
|
||||||
|
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# SDL2 may require threads on your system.
|
||||||
|
# The Apple build may not need an explicit flag because one of the
|
||||||
|
# frameworks may already provide it.
|
||||||
|
# But for non-OSX systems, I will use the CMake Threads package.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
FIND_PACKAGE(Threads)
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# MinGW needs an additional library, mwindows
|
||||||
|
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
|
||||||
|
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||||
|
IF(MINGW)
|
||||||
|
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
IF(SDL2_LIBRARY_TEMP)
|
||||||
|
# For SDL2main
|
||||||
|
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
IF(SDL2MAIN_LIBRARY)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(SDL2MAIN_LIBRARY)
|
||||||
|
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||||
|
|
||||||
|
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||||
|
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||||
|
# though it actually is there if I modify a pre-used variable.
|
||||||
|
# I think it has something to do with the CACHE STRING.
|
||||||
|
# So I use a temporary variable until the end so I can set the
|
||||||
|
# "real" variable in one-shot.
|
||||||
|
IF(APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||||
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
# For threads, as mentioned Apple doesn't need this.
|
||||||
|
# In fact, there seems to be a problem if I used the Threads package
|
||||||
|
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||||
|
IF(NOT APPLE)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
ENDIF(NOT APPLE)
|
||||||
|
|
||||||
|
# For MinGW library
|
||||||
|
IF(MINGW)
|
||||||
|
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||||
|
ENDIF(MINGW)
|
||||||
|
|
||||||
|
# Set the final string here so the GUI reflects the final state.
|
||||||
|
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||||
|
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||||
|
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||||
|
ENDIF(SDL2_LIBRARY_TEMP)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
|
@ -80,7 +80,7 @@ idCVar r_useStateCaching( "r_useStateCaching", "1", CVAR_RENDERER | CVAR_BOOL, "
|
||||||
|
|
||||||
idCVar r_znear( "r_znear", "3", CVAR_RENDERER | CVAR_FLOAT, "near Z clip plane distance", 0.001f, 200.0f );
|
idCVar r_znear( "r_znear", "3", CVAR_RENDERER | CVAR_FLOAT, "near Z clip plane distance", 0.001f, 200.0f );
|
||||||
|
|
||||||
idCVar r_ignoreGLErrors( "r_ignoreGLErrors", "1", CVAR_RENDERER | CVAR_BOOL, "ignore GL errors" );
|
idCVar r_ignoreGLErrors( "r_ignoreGLErrors", "0", CVAR_RENDERER | CVAR_BOOL, "ignore GL errors" );
|
||||||
idCVar r_swapInterval( "r_swapInterval", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "0 = tear, 1 = swap-tear where available, 2 = always v-sync" );
|
idCVar r_swapInterval( "r_swapInterval", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER, "0 = tear, 1 = swap-tear where available, 2 = always v-sync" );
|
||||||
|
|
||||||
idCVar r_gamma( "r_gamma", "1.0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT, "changes gamma tables", 0.5f, 3.0f );
|
idCVar r_gamma( "r_gamma", "1.0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT, "changes gamma tables", 0.5f, 3.0f );
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
Doom 3 BFG Edition GPL Source Code
|
Doom 3 BFG Edition GPL Source Code
|
||||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||||
|
Copyright (C) 2012 Robert Beckebans
|
||||||
|
|
||||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||||
|
|
||||||
|
@ -1028,6 +1029,22 @@ struct vidMode_t
|
||||||
int height;
|
int height;
|
||||||
int displayHz;
|
int displayHz;
|
||||||
|
|
||||||
|
// RB begin
|
||||||
|
vidMode_t()
|
||||||
|
{
|
||||||
|
width = 640;
|
||||||
|
height = 480;
|
||||||
|
displayHz = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
vidMode_t( int widht, int height, int displayHz )
|
||||||
|
{
|
||||||
|
this->width = width;
|
||||||
|
this->height = height;
|
||||||
|
this->displayHz = displayHz;
|
||||||
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
bool operator==( const vidMode_t& a )
|
bool operator==( const vidMode_t& a )
|
||||||
{
|
{
|
||||||
return a.width == width && a.height == height && a.displayHz == displayHz;
|
return a.width == width && a.height == height && a.displayHz == displayHz;
|
||||||
|
|
|
@ -462,6 +462,7 @@ sysEvent_t Sys_GetEvent()
|
||||||
switch( ev.window.event )
|
switch( ev.window.event )
|
||||||
{
|
{
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
|
{
|
||||||
// unset modifier, in case alt-tab was used to leave window and ALT is still set
|
// unset modifier, in case alt-tab was used to leave window and ALT is still set
|
||||||
// as that can cause fullscreen-toggling when pressing enter...
|
// as that can cause fullscreen-toggling when pressing enter...
|
||||||
SDL_Keymod currentmod = SDL_GetModState();
|
SDL_Keymod currentmod = SDL_GetModState();
|
||||||
|
@ -473,6 +474,8 @@ sysEvent_t Sys_GetEvent()
|
||||||
|
|
||||||
GLimp_GrabInput( GRAB_ENABLE | GRAB_REENABLE | GRAB_HIDECURSOR );
|
GLimp_GrabInput( GRAB_ENABLE | GRAB_REENABLE | GRAB_HIDECURSOR );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
GLimp_GrabInput( 0 );
|
GLimp_GrabInput( 0 );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,8 +37,14 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
#include "sdl_local.h"
|
#include "sdl_local.h"
|
||||||
|
|
||||||
idCVar in_nograb( "in_nograb", "0", CVAR_SYSTEM | CVAR_NOCHEAT, "prevents input grabbing" );
|
idCVar in_nograb( "in_nograb", "0", CVAR_SYSTEM | CVAR_NOCHEAT, "prevents input grabbing" );
|
||||||
|
|
||||||
|
// RB: FIXME this shit. We need the OpenGL alpha channel for advanced rendering effects
|
||||||
idCVar r_waylandcompat( "r_waylandcompat", "0", CVAR_SYSTEM | CVAR_NOCHEAT | CVAR_ARCHIVE, "wayland compatible framebuffer" );
|
idCVar r_waylandcompat( "r_waylandcompat", "0", CVAR_SYSTEM | CVAR_NOCHEAT | CVAR_ARCHIVE, "wayland compatible framebuffer" );
|
||||||
|
|
||||||
|
// RB: only relevant if using SDL 2.0
|
||||||
|
idCVar r_useOpenGL32( "r_useOpenGL32", "1", CVAR_INTEGER, "0 = OpenGL 2.0, 1 = OpenGL 3.2 compatibility profile, 2 = OpenGL 3.2 core profile", 0, 2 );
|
||||||
|
// RB end
|
||||||
|
|
||||||
static bool grabbed = false;
|
static bool grabbed = false;
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
@ -155,7 +161,6 @@ bool GLimp_Init( glimpParms_t parms )
|
||||||
if( tcolorbits == 24 )
|
if( tcolorbits == 24 )
|
||||||
channelcolorbits = 8;
|
channelcolorbits = 8;
|
||||||
|
|
||||||
#if 1
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, channelcolorbits );
|
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, channelcolorbits );
|
||||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, channelcolorbits );
|
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, channelcolorbits );
|
||||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, channelcolorbits );
|
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, channelcolorbits );
|
||||||
|
@ -172,9 +177,22 @@ bool GLimp_Init( glimpParms_t parms )
|
||||||
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, parms.multiSamples ? 1 : 0 );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, parms.multiSamples ? 1 : 0 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples );
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
|
||||||
|
// RB begin
|
||||||
|
if( r_useOpenGL32.GetInteger() > 0 )
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
|
||||||
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( r_useOpenGL32.GetInteger() > 1 )
|
||||||
|
{
|
||||||
|
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
|
||||||
|
}
|
||||||
|
// RB end
|
||||||
|
|
||||||
window = SDL_CreateWindow( GAME_NAME,
|
window = SDL_CreateWindow( GAME_NAME,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
@ -251,7 +269,7 @@ GLimp_SetScreenParms
|
||||||
*/
|
*/
|
||||||
bool GLimp_SetScreenParms( glimpParms_t parms )
|
bool GLimp_SetScreenParms( glimpParms_t parms )
|
||||||
{
|
{
|
||||||
common->DPrintf( "TODO: GLimp_ActivateContext\n" );
|
common->DPrintf( "TODO: GLimp_SetScreenParms\n" );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,6 +399,33 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// RB: resolutions supported by XreaL
|
||||||
|
static void FillStaticVidModes( idList<vidMode_t>& modeList )
|
||||||
|
{
|
||||||
|
modeList.AddUnique( vidMode_t( 320, 240, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 400, 300, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 512, 384, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 640, 480, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 800, 600, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 960, 720, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1024, 768, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1152, 864, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1280, 720, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1280, 768, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1280, 800, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1280, 1024, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1360, 768, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1440, 900, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1680, 1050, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1600, 1200, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1920, 1080, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 1920, 1200, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 2048, 1536, 60 ) );
|
||||||
|
modeList.AddUnique( vidMode_t( 2560, 1600, 60 ) );
|
||||||
|
|
||||||
|
modeList.SortWithTemplate( idSort_VidMode() );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
R_GetModeListForDisplay
|
R_GetModeListForDisplay
|
||||||
|
@ -390,13 +435,22 @@ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>&
|
||||||
{
|
{
|
||||||
modeList.Clear();
|
modeList.Clear();
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
// RB: TODO didn't find SDL_ListModes API
|
||||||
|
FillStaticVidModes( modeList );
|
||||||
|
return true;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
|
|
||||||
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
|
||||||
if( videoInfo == NULL )
|
if( videoInfo == NULL )
|
||||||
{
|
{
|
||||||
// DG: yes, this can actually fail, e.g. if SDL_Init( SDL_INIT_VIDEO ) wasn't called
|
// DG: yes, this can actually fail, e.g. if SDL_Init( SDL_INIT_VIDEO ) wasn't called
|
||||||
common->Error( "Can't get Video Info!\n" );
|
common->Warning( "Can't get Video Info!\n" );
|
||||||
|
FillStaticVidModes( modeList );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect** modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN );
|
SDL_Rect** modes = SDL_ListModes( videoInfo->vfmt, SDL_OPENGL | SDL_FULLSCREEN );
|
||||||
|
@ -404,13 +458,15 @@ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>&
|
||||||
if( !modes )
|
if( !modes )
|
||||||
{
|
{
|
||||||
common->Warning( "Can't get list of available modes\n" );
|
common->Warning( "Can't get list of available modes\n" );
|
||||||
return false;
|
FillStaticVidModes( modeList );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( modes == ( SDL_Rect** ) - 1 )
|
if( modes == ( SDL_Rect** ) - 1 )
|
||||||
{
|
{
|
||||||
common->Printf( "Display supports any resolution\n" );
|
common->Printf( "Display supports any resolution\n" );
|
||||||
return false; // can set any resolution
|
FillStaticVidModes( modeList );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numModes;
|
int numModes;
|
||||||
|
@ -426,12 +482,13 @@ bool R_GetModeListForDisplay( const int requestedDisplayNum, idList<vidMode_t>&
|
||||||
mode.displayHz = 60; // FIXME;
|
mode.displayHz = 60; // FIXME;
|
||||||
modeList.AddUnique( mode );
|
modeList.AddUnique( mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort with lowest resolution first
|
// sort with lowest resolution first
|
||||||
modeList.SortWithTemplate( idSort_VidMode() );
|
modeList.SortWithTemplate( idSort_VidMode() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue