mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Make shared gl context optional.
--HG-- branch : dev
This commit is contained in:
@@ -8,6 +8,7 @@ Resizeable = 1
|
||||
WinIcon = assets/icon/ee.png
|
||||
VSync = 1
|
||||
GLVersion = Default
|
||||
SharedGLContext = 0
|
||||
Backend = Default
|
||||
JoystickEnabled = 0
|
||||
ParticlesNum = 1000
|
||||
|
||||
@@ -79,13 +79,14 @@ class WindowSettings {
|
||||
class ContextSettings {
|
||||
public:
|
||||
|
||||
inline ContextSettings( bool vsync, EEGL_version version = GLv_default, bool doubleBuffering = true, Uint32 depthBufferSize = 24, Uint32 stencilBufferSize = 1, Uint32 multisamples = 0 ) :
|
||||
inline ContextSettings( bool vsync, EEGL_version version = GLv_default, bool doubleBuffering = true, Uint32 depthBufferSize = 24, Uint32 stencilBufferSize = 1, Uint32 multisamples = 0, bool sharedGLContext = true ) :
|
||||
Version( version ),
|
||||
DepthBufferSize( depthBufferSize ),
|
||||
StencilBufferSize( stencilBufferSize ),
|
||||
Multisamples( multisamples ),
|
||||
VSync( vsync ),
|
||||
DoubleBuffering( doubleBuffering )
|
||||
DoubleBuffering( doubleBuffering ),
|
||||
SharedGLContext( sharedGLContext )
|
||||
{}
|
||||
|
||||
inline ContextSettings() :
|
||||
@@ -94,7 +95,8 @@ class ContextSettings {
|
||||
StencilBufferSize( 1 ),
|
||||
Multisamples( 0 ),
|
||||
VSync( false ),
|
||||
DoubleBuffering( true )
|
||||
DoubleBuffering( true ),
|
||||
SharedGLContext( true )
|
||||
{}
|
||||
|
||||
EEGL_version Version;
|
||||
@@ -103,6 +105,7 @@ class ContextSettings {
|
||||
Uint32 Multisamples;
|
||||
bool VSync;
|
||||
bool DoubleBuffering;
|
||||
bool SharedGLContext;
|
||||
};
|
||||
|
||||
/** @brief WindowInfo Contains the window state information */
|
||||
|
||||
@@ -220,17 +220,21 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
#endif
|
||||
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 );
|
||||
if ( mWindow.ContextConfig.SharedGLContext ) {
|
||||
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 );
|
||||
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
mGLContextThread = SDL_GL_CreateContext( mSDLWindow );
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
mGLContextThread = SDL_GL_CreateContext( mSDLWindow );
|
||||
} else {
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
}
|
||||
#else
|
||||
mGLContext = SDL_GL_CreateContext( mSDLWindow );
|
||||
#endif
|
||||
|
||||
if ( NULL == mGLContext
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
|| NULL == mGLContextThread
|
||||
|| ( mWindow.ContextConfig.SharedGLContext && NULL == mGLContextThread )
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -281,7 +285,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
|
||||
bool WindowSDL::isThreadedGLContext() {
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
return true;
|
||||
return mWindow.ContextConfig.SharedGLContext;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -307,8 +307,9 @@ ContextSettings Engine::createContextSettings( IniFile * ini, std::string iniKey
|
||||
int depthBufferSize = ini->getValueI( iniKeyName, "DepthBufferSize", 24 );
|
||||
int stencilBufferSize = ini->getValueI( iniKeyName, "StencilBufferSize", 1 );
|
||||
int multisamples = ini->getValueI( iniKeyName, "Multisamples", 0 );
|
||||
bool sharedGLContext = ini->getValueB( iniKeyName, "SharedGLContext", false );
|
||||
|
||||
return ContextSettings( VSync, GLVer, doubleBuffering, depthBufferSize, stencilBufferSize, multisamples );
|
||||
return ContextSettings( VSync, GLVer, doubleBuffering, depthBufferSize, stencilBufferSize, multisamples, sharedGLContext );
|
||||
}
|
||||
|
||||
ContextSettings Engine::createContextSettings( std::string iniPath, std::string iniKeyName ) {
|
||||
@@ -326,7 +327,7 @@ void Engine::disableSharedGLContext() {
|
||||
}
|
||||
|
||||
bool Engine::isSharedGLContextEnabled() {
|
||||
return mSharedGLContext;
|
||||
return mSharedGLContext && mWindow->isThreadedGLContext();
|
||||
}
|
||||
|
||||
Uint32 Engine::getMainThreadId() {
|
||||
|
||||
Reference in New Issue
Block a user