From c68b9c75f405b3a71cfecc44a2bf6a81cba61117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 20 May 2013 03:13:08 -0300 Subject: [PATCH] Fixed context initialization on Android. --- projects/android-project/AndroidManifest.xml | 6 +++ projects/linux/ee.creator.user | 2 +- src/eepp/graphics/renderer/cgl.cpp | 4 ++ src/eepp/window/backend/SDL2/cwindowsdl2.cpp | 43 ++++++++++++++------ src/test/eetest.cpp | 2 +- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/projects/android-project/AndroidManifest.xml b/projects/android-project/AndroidManifest.xml index 574b52bd3..bc7551938 100644 --- a/projects/android-project/AndroidManifest.xml +++ b/projects/android-project/AndroidManifest.xml @@ -19,4 +19,10 @@ + + + + + + diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index d0f016c07..120c17e45 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/src/eepp/graphics/renderer/cgl.cpp b/src/eepp/graphics/renderer/cgl.cpp index aad9f3a22..7700da88e 100644 --- a/src/eepp/graphics/renderer/cgl.cpp +++ b/src/eepp/graphics/renderer/cgl.cpp @@ -15,7 +15,11 @@ cGL * cGL::CreateSingleton( EEGL_version ver ) { ver = GLv_2; #else if ( GLv_default == ver ) + #ifdef EE_GLES1 ver = GLv_ES1; + #else + ver = GLv_ES2; + #endif #endif switch ( ver ) { diff --git a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp index f91c24e26..1122cac0e 100644 --- a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp @@ -155,20 +155,39 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { mWindow.WindowConfig.Height = h; mWindow.WindowSize = eeSize( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ); - #if EE_PLAFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS - if ( GLv_default == Context.Version || GLv_ES1 == Context.Version || GLv_2 == Context.Version ) { - #ifdef EE_GLES1 - if ( GLv_2 == Context.Version ) - mWindow.ContextConfig.Version = GLv_default; + cLog::instance()->Write( "Creating Context" ); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - #endif + #if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS + if ( GLv_default != Context.Version ) { + if ( GLv_ES1 == Context.Version || GLv_2 == Context.Version ) { + #ifdef EE_GLES1 + if ( GLv_2 == Context.Version ) + mWindow.ContextConfig.Version = GLv_default; + + cLog::instance()->Write( "Starting GLES1" ); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + #endif + } else { + #ifdef EE_GLES2 + cLog::instance()->Write( "Starting GLES2" ); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + #endif + } } else { - #ifdef EE_GLES2 - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); - #endif + #if defined( EE_GLES2 ) && !defined( EE_GLES1 ) + cLog::instance()->Write( "Starting GLES2 default" ); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + #else + cLog::instance()->Write( "Starting GLES1 default" ); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + #endif } #endif diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index a4f56d7f4..023523ebb 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -39,7 +39,7 @@ void cEETest::Init() { cIniFile Ini( MyPath + "ee.ini" ); Ini.ReadFile(); - PartsNum = Ini.GetValueI( "EEPP", "ParticlesNum", 1000); + PartsNum = Ini.GetValueI( "EEPP", "ParticlesNum", 1000 ); mUseShaders = Ini.GetValueB( "EEPP", "UseShaders", false ); mJoyEnabled = Ini.GetValueB( "EEPP", "JoystickEnabled", false ); mMusEnabled = Ini.GetValueB( "EEPP", "Music", false );