diff --git a/src/base.hpp b/src/base.hpp index 16941bfaa..5abe67e57 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -75,9 +75,8 @@ #define EE_32BIT #endif - -#define EE_LITTLE_ENDIAN 1 -#define EE_BIG_ENDIAN 2 +#define EE_LITTLE_ENDIAN 1 +#define EE_BIG_ENDIAN 2 #if defined(__386__) || defined(i386) || defined(__i386__) \ || defined(__X86) || defined(_M_IX86) \ @@ -93,10 +92,8 @@ #define EE_ENDIAN EE_BIG_ENDIAN #endif -#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX || !defined( EE_GLES ) +#if ( EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX ) && !defined( EE_GLES ) #define EE_GLEW_AVAILABLE -#else -#warning Platform not supported. #endif #ifdef EE_PLATFORM @@ -137,16 +134,6 @@ #define EE_API #endif -#ifdef EE_GLEW_AVAILABLE -#include "helper/glew/glew.h" -#endif - -#if EE_PLATFORM == EE_PLATFORM_MACOSX -#include -#else -#include -#endif - #define eeARRAY_SIZE(__array) ( sizeof(__array) / sizeof(__array[0]) ) #define eeSAFE_DELETE(p) { if(p) { eeDelete (p); (p)=NULL; } } #define eeSAFE_FREE(p) { if(p) { eeFree ( (void*)p ); (p)=NULL; } } @@ -210,7 +197,7 @@ namespace EE { const eeFloat PI = 3.141592654; const eeFloat TwoPI = 6.283185308; const eeFloat PId180 = PI / 180; - const eeFloat d180PI = 180.f / PI; + const eeFloat d180PI = 180 / PI; } #include "base/base.hpp" diff --git a/src/graphics/base.hpp b/src/graphics/base.hpp index 986a5c18c..e275badff 100644 --- a/src/graphics/base.hpp +++ b/src/graphics/base.hpp @@ -3,6 +3,49 @@ #include "../base.hpp" +#if ( defined( EE_GLES2 ) || defined( EE_GLES1 ) ) && !defined( EE_GLES ) + #define EE_GLES +#endif + +#ifndef EE_GLES + //! GL2 and GL3 ( PC platform ) + + #ifdef EE_GLEW_AVAILABLE + #include "../helper/glew/glew.h" + #else + #define GL_GLEXT_PROTOTYPES + #endif + + #if EE_PLATFORM == EE_PLATFORM_MACOSX + #include + #else + #include + #endif + + #ifndef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_WIN + #include + #elif EE_PLATFORM == EE_PLATFORM_MACOSX + #include + #endif + + #include + #endif + +#else + //! Mobile platform ( Android / iPhone / Maemo ) + + //! GLES2 ( programmable pipeline ) + #ifdef EE_GLES2 + #include + #include + + //! GLES1 ( fixed pipeline ) + #elif defined( EE_GLES1 ) + #include + #endif +#endif + #include "../helper/SOIL/SOIL.h" #include "../utils/colors.hpp" diff --git a/src/graphics/cbatchrenderer.cpp b/src/graphics/cbatchrenderer.cpp index 979da55c6..5f3ac8f65 100755 --- a/src/graphics/cbatchrenderer.cpp +++ b/src/graphics/cbatchrenderer.cpp @@ -107,9 +107,11 @@ void cBatchRenderer::Flush() { cTextureFactory::instance()->SetPreBlendFunc( mBlend ); if ( mCurrentMode == DM_POINTS && NULL != mTexture ) { - GLi->Enable( GL_POINT_SPRITE_ARB ); - glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); + #ifndef EE_GLES2 + GLi->Enable( GL_POINT_SPRITE ); + glTexEnvf( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE ); GLi->PointSize( (GLfloat)mTexture->Width() ); + #endif } if ( CreateMatrix ) { @@ -150,7 +152,9 @@ void cBatchRenderer::Flush() { } if ( mCurrentMode == DM_POINTS && mTexture > 0 ) { - GLi->Disable( GL_POINT_SPRITE_ARB ); + #ifndef EE_GLES2 + GLi->Disable( GL_POINT_SPRITE ); + #endif } if ( mTexture == 0 ) { @@ -846,7 +850,7 @@ void cBatchRenderer::SetLineWidth( const eeFloat& lineWidth ) { } eeFloat cBatchRenderer::GetLineWidth() { - float lw; + float lw = 1; glGetFloatv( GL_LINE_WIDTH, &lw ); @@ -858,10 +862,10 @@ void cBatchRenderer::SetPointSize( const eeFloat& pointSize ) { } eeFloat cBatchRenderer::GetPointSize() { - float ps; - + float ps = 1; + #ifndef EE_GLES2 glGetFloatv( GL_POINT_SIZE, &ps ); - + #endif return ps; } diff --git a/src/graphics/cframebufferpbuffer.cpp b/src/graphics/cframebufferpbuffer.cpp index f97d365c1..f75a35d7d 100644 --- a/src/graphics/cframebufferpbuffer.cpp +++ b/src/graphics/cframebufferpbuffer.cpp @@ -5,6 +5,8 @@ namespace EE { namespace Graphics { cFrameBufferPBuffer::cFrameBufferPBuffer() +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN : cFrameBuffer(), mDeviceContext( NULL ), @@ -16,13 +18,17 @@ cFrameBufferPBuffer::cFrameBufferPBuffer() mPBuffer( 0 ), mContext( NULL ) #endif + +#endif { -#if EE_PLATFORM == EE_PLATFORM_LINUX +#if defined( EE_GLEW_AVAILABLE ) && EE_PLATFORM == EE_PLATFORM_LINUX mDisplay = XOpenDisplay(NULL); #endif } cFrameBufferPBuffer::cFrameBufferPBuffer( const Uint32& Width, const Uint32& Height, bool DepthBuffer ) +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN : cFrameBuffer(), mDeviceContext( NULL ), @@ -34,14 +40,18 @@ cFrameBufferPBuffer::cFrameBufferPBuffer( const Uint32& Width, const Uint32& Hei mPBuffer( 0 ), mContext( NULL ) #endif + +#endif { -#if EE_PLATFORM == EE_PLATFORM_LINUX +#if defined( EE_GLEW_AVAILABLE ) && EE_PLATFORM == EE_PLATFORM_LINUX mDisplay = XOpenDisplay(NULL); #endif Create( Width, Height, DepthBuffer ); } cFrameBufferPBuffer::~cFrameBufferPBuffer() { +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN if ( mContext ) wglDeleteContext( mContext ); @@ -61,11 +71,14 @@ cFrameBufferPBuffer::~cFrameBufferPBuffer() { XCloseDisplay( mDisplay ); #endif +#endif if ( Window::cEngine::ExistsSingleton() ) Window::cEngine::instance()->SetDefaultContext(); } bool cFrameBufferPBuffer::IsSupported() { +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN return WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format; #elif EE_PLATFORM == EE_PLATFORM_LINUX @@ -73,6 +86,10 @@ bool cFrameBufferPBuffer::IsSupported() { #else return false; #endif + +#else + return false; +#endif } bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height ) { @@ -87,6 +104,8 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo mHeight = Height; mHasDepthBuffer = DepthBuffer; +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN HDC currentDC = wglGetCurrentDC(); @@ -192,6 +211,8 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo XFree(configs); XFree(visual); +#endif + #endif if ( NULL == mTexture ) { @@ -210,6 +231,8 @@ bool cFrameBufferPBuffer::Create( const Uint32& Width, const Uint32& Height, boo void cFrameBufferPBuffer::Bind() { bool ChangeContext = false; +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN if ( mDeviceContext && mContext ) { if ( wglGetCurrentContext() != mContext ) { @@ -226,6 +249,8 @@ void cFrameBufferPBuffer::Bind() { } #endif +#endif + if ( ChangeContext ) { Window::cEngine::instance()->Setup2D( true ); SetBufferView(); diff --git a/src/graphics/cframebufferpbuffer.hpp b/src/graphics/cframebufferpbuffer.hpp index f49a48095..e36a5ee95 100644 --- a/src/graphics/cframebufferpbuffer.hpp +++ b/src/graphics/cframebufferpbuffer.hpp @@ -29,6 +29,8 @@ #include "base.hpp" #include "cframebuffer.hpp" +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN #include "../helper/glew/wglew.h" #elif EE_PLATFORM == EE_PLATFORM_LINUX @@ -41,6 +43,8 @@ #warning No PBuffer implemented on this platform #endif +#endif + namespace EE { namespace Graphics { class EE_API cFrameBufferPBuffer : public cFrameBuffer { @@ -63,6 +67,8 @@ class EE_API cFrameBufferPBuffer : public cFrameBuffer { static bool IsSupported(); protected: + #ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN HDC mDeviceContext; HPBUFFERARB mPBuffer; @@ -72,6 +78,8 @@ class EE_API cFrameBufferPBuffer : public cFrameBuffer { GLXPbuffer mPBuffer; GLXContext mContext; #endif + + #endif }; }} diff --git a/src/graphics/cparticlesystem.cpp b/src/graphics/cparticlesystem.cpp index 70bf5a632..52390ae3e 100755 --- a/src/graphics/cparticlesystem.cpp +++ b/src/graphics/cparticlesystem.cpp @@ -266,13 +266,16 @@ void cParticleSystem::Draw() { if ( mPointsSup ) { if ( GLi->Version() == GLv_3 ) { GLi->GetRendererGL3()->SetShader( EEGL_SHADER_POINT_SPRITE ); + #ifndef EE_GLES2 GLi->Enable( GL_VERTEX_PROGRAM_POINT_SIZE ); + #endif } - GLi->Enable( GL_POINT_SPRITE_ARB ); + #ifndef EE_GLES2 + GLi->Enable( GL_POINT_SPRITE ); GLi->PointSize( mSize ); - - glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); + glTexEnvf( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE ); + #endif Uint32 alloc = mPCount * sizeof(cParticle); @@ -281,7 +284,9 @@ void cParticleSystem::Draw() { GLi->DrawArrays( GL_POINTS, 0, (GLsizei)mPCount ); - GLi->Disable( GL_POINT_SPRITE_ARB ); + #ifndef EE_GLES2 + GLi->Disable( GL_POINT_SPRITE ); + #endif if ( GLi->Version() == GLv_3 ) { GLi->GetRendererGL3()->SetShader( EEGL_SHADER_BASE_TEX ); diff --git a/src/graphics/cshader.cpp b/src/graphics/cshader.cpp index 210957e2b..97943e712 100644 --- a/src/graphics/cshader.cpp +++ b/src/graphics/cshader.cpp @@ -136,7 +136,11 @@ bool cShader::Compile() { mCompileLog.resize( logarraysize - 1 ); + #ifndef EE_GLES2 glGetShaderInfoLog( GetId(), logarraysize, &logsize, reinterpret_cast( &mCompileLog[0] ) ); + #else + glGetShaderInfoLog( GetId(), logarraysize, &logsize, reinterpret_cast( &mCompileLog[0] ) ); + #endif cLog::instance()->Write( "Couldn't compile shader. Log follows:" ); cLog::instance()->Write( mCompileLog ); diff --git a/src/graphics/cshaderprogram.cpp b/src/graphics/cshaderprogram.cpp index b0ecdff35..bed8d54f9 100644 --- a/src/graphics/cshaderprogram.cpp +++ b/src/graphics/cshaderprogram.cpp @@ -191,7 +191,11 @@ bool cShaderProgram::Link() { glGetProgramiv( Handler(), GL_INFO_LOG_LENGTH, &logarraysize ); mLinkLog.resize(logarraysize); + #ifndef EE_GLES2 glGetProgramInfoLog( Handler(), logarraysize, &logsize, reinterpret_cast( &mLinkLog[0] ) ); + #else + glGetProgramInfoLog( Handler(), logarraysize, &logsize, reinterpret_cast( &mLinkLog[0] ) ); + #endif if ( !mValid ) { cLog::instance()->Write( "cShaderProgram::Link(): Couldn't link program. Log follows:" + mLinkLog ); diff --git a/src/graphics/ctexture.cpp b/src/graphics/ctexture.cpp index 75d8fce5f..16aec57e7 100755 --- a/src/graphics/ctexture.cpp +++ b/src/graphics/ctexture.cpp @@ -98,6 +98,7 @@ void cTexture::Create( const Uint32& texture, const eeUint& width, const eeUint& } Uint8 * cTexture::iLock( const bool& ForceRGBA, const bool& KeepFormat ) { + #ifndef EE_GLES if ( !( mFlags & TEX_FLAG_LOCKED ) ) { if ( ForceRGBA ) mChannels = 4; @@ -109,8 +110,8 @@ Uint8 * cTexture::iLock( const bool& ForceRGBA, const bool& KeepFormat ) { glBindTexture(GL_TEXTURE_2D, mTexture); Int32 width = 0, height = 0; - glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); - glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); + glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width ); + glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height ); mWidth = (eeUint)width; mHeight = (eeUint)height; @@ -145,6 +146,9 @@ Uint8 * cTexture::iLock( const bool& ForceRGBA, const bool& KeepFormat ) { } return &mPixels[0]; + #else + return NULL; + #endif } Uint8 * cTexture::Lock( const bool& ForceRGBA ) { @@ -152,6 +156,7 @@ Uint8 * cTexture::Lock( const bool& ForceRGBA ) { } bool cTexture::Unlock( const bool& KeepData, const bool& Modified ) { + #ifndef EE_GLES if ( ( mFlags & TEX_FLAG_LOCKED ) ) { Int32 width = mWidth, height = mHeight; GLuint NTexId = 0; @@ -189,6 +194,9 @@ bool cTexture::Unlock( const bool& KeepData, const bool& Modified ) { } return false; + #else + return false; + #endif } const Uint8 * cTexture::GetPixelsPtr() { diff --git a/src/graphics/ctexturefactory.cpp b/src/graphics/ctexturefactory.cpp index 49a9e6b9f..9ccf8f13f 100755 --- a/src/graphics/ctexturefactory.cpp +++ b/src/graphics/ctexturefactory.cpp @@ -253,7 +253,7 @@ void cTextureFactory::SetPreBlendFunc( const EE_PRE_BLEND_FUNC& blend, bool forc } void cTextureFactory::SetActiveTextureUnit( const Uint32& Unit ) { - GLi->ActiveTexture( GL_TEXTURE0_ARB + Unit ); + GLi->ActiveTexture( GL_TEXTURE0 + Unit ); } void cTextureFactory::SetTextureConstantColor( const eeColorA& Color ) { @@ -261,10 +261,13 @@ void cTextureFactory::SetTextureConstantColor( const eeColorA& Color ) { } void cTextureFactory::SetTextureConstantColor( const eeColorAf& Color ) { + #ifndef EE_GLES2 glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const GLfloat*)(&Color.Red) ); + #endif } void cTextureFactory::SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& Val ) { + #ifndef EE_GLES2 GLenum lParam = (GLenum)GLi->GetTextureParamEnum( Param ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); @@ -278,6 +281,7 @@ void cTextureFactory::SetTextureEnv( const EE_TEXTURE_PARAM& Param, const Int32& } else { glTexEnvi( GL_TEXTURE_ENV, lParam, Val ); } + #endif } const EE_PRE_BLEND_FUNC& cTextureFactory::GetPreBlendFunc() const { diff --git a/src/graphics/renderer/base.hpp b/src/graphics/renderer/base.hpp index b461a9064..5767b8c8d 100644 --- a/src/graphics/renderer/base.hpp +++ b/src/graphics/renderer/base.hpp @@ -4,6 +4,24 @@ #include "../base.hpp" #include "../renders.hpp" -#define EE_GL3_ENABLED 1 +#if !defined( EE_GLES2 ) || !defined( EE_GLES1 ) + #define EE_GL3_ENABLED 1 +#endif + +#ifdef EE_GLES2 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LIGHTING 0x0B50 +#endif #endif diff --git a/src/graphics/renderer/cgl.cpp b/src/graphics/renderer/cgl.cpp index cc4443500..d86ca5f19 100644 --- a/src/graphics/renderer/cgl.cpp +++ b/src/graphics/renderer/cgl.cpp @@ -9,17 +9,28 @@ cGL * GLi = NULL; cGL * cGL::ms_singleton = NULL; cGL * cGL::CreateSingleton( EEGL_version ver ) { + #ifndef EE_GLES2 + if ( GLv_default == ver ) + ver = GLv_2; + #else + if ( GLv_default == ver ) + ver = GLv_3; + #endif + switch ( ver ) { + case GLv_ES2: case GLv_3: - #ifdef EE_GL3_ENABLED + #if defined( EE_GL3_ENABLED ) || defined( EE_GLES2 ) ms_singleton = eeNew( cRendererGL3, () ); break; #endif case GLv_2: - case GLv_ES: + case GLv_ES1: case GLv_default: default: + #ifndef EE_GLES2 ms_singleton = eeNew( cRendererGL, () ); + #endif } return ms_singleton; @@ -27,13 +38,19 @@ cGL * cGL::CreateSingleton( EEGL_version ver ) { cGL * cGL::CreateSingleton() { if ( ms_singleton == 0 ) { - #ifdef EE_GL3_ENABLED - /** Implement an OpenGL3 compilant renderer */ - if ( '3' == glGetString(GL_VERSION)[0] ) + #ifdef EE_GLES2 ms_singleton = eeNew( cRendererGL3, () ); - else - #endif + #elif EE_GLES1 ms_singleton = eeNew( cRendererGL, () ); + #else + #ifdef EE_GL3_ENABLED + /** Implement an OpenGL3 compilant renderer */ + if ( '3' == glGetString(GL_VERSION)[0] ) + ms_singleton = eeNew( cRendererGL3, () ); + else + #endif + ms_singleton = eeNew( cRendererGL, () ); + #endif } return ms_singleton; @@ -109,6 +126,8 @@ void cGL::Init() { WriteExtension( EEGL_ARB_multitexture , GetExtension( "GL_ARB_multitexture" ) ); WriteExtension( EEGL_EXT_texture_compression_s3tc , GetExtension( "GL_EXT_texture_compression_s3tc" ) ); WriteExtension( EEGL_ARB_vertex_buffer_object , GetExtension( "GL_ARB_vertex_buffer_object" ) ); + + glewOn = false; /// avoid compiler warning } } diff --git a/src/graphics/renderer/cgl.hpp b/src/graphics/renderer/cgl.hpp index ae06cec14..f72b8529f 100644 --- a/src/graphics/renderer/cgl.hpp +++ b/src/graphics/renderer/cgl.hpp @@ -42,7 +42,8 @@ enum EEGL_SHADERS { enum EEGL_version { GLv_2, GLv_3, - GLv_ES, + GLv_ES1, + GLv_ES2, GLv_default }; @@ -52,10 +53,10 @@ class cRendererGL3; class cGL { static cGL * ms_singleton; public: - static cGL * CreateSingleton(); - static cGL * CreateSingleton( EEGL_version ver ); + static cGL * CreateSingleton(); + static cGL * ExistsSingleton(); static cGL * instance(); diff --git a/src/graphics/renderer/crenderergl.cpp b/src/graphics/renderer/crenderergl.cpp index eb5c59295..a3c4e9ff6 100644 --- a/src/graphics/renderer/crenderergl.cpp +++ b/src/graphics/renderer/crenderergl.cpp @@ -2,6 +2,8 @@ namespace EE { namespace Graphics { +#ifndef EE_GLES2 + cRendererGL::cRendererGL() { } @@ -105,4 +107,6 @@ void cRendererGL::ClipPlaneDisable() { GLi->Disable(GL_CLIP_PLANE3); } +#endif + }} diff --git a/src/graphics/renderer/crenderergl.hpp b/src/graphics/renderer/crenderergl.hpp index aea5a3b2d..d48a31727 100644 --- a/src/graphics/renderer/crenderergl.hpp +++ b/src/graphics/renderer/crenderergl.hpp @@ -5,6 +5,9 @@ namespace EE { namespace Graphics { +//! Avoid compilling the fixed pipeline renderer for GLES2, because it's not supported. +#ifndef EE_GLES2 + class cRendererGL : public cGL { public: cRendererGL(); @@ -52,6 +55,8 @@ class cRendererGL : public cGL { }; +#endif + }} #endif diff --git a/src/physics/physicshelper.hpp b/src/physics/physicshelper.hpp index 832230f10..a2b42a9cc 100644 --- a/src/physics/physicshelper.hpp +++ b/src/physics/physicshelper.hpp @@ -1,6 +1,8 @@ #ifndef EE_PHYSICS_HELPER #define EE_PHYSICS_HELPER +#include "../graphics/base.hpp" + CP_NAMESPACE_BEGIN const cpFloat cpPI = 3.141592654; diff --git a/src/window/base.hpp b/src/window/base.hpp index b1b219591..6a4daa26d 100644 --- a/src/window/base.hpp +++ b/src/window/base.hpp @@ -9,22 +9,25 @@ inline BOOL WIN_ShowWindow( HWND hWnd, int nCmdShow ) { return ShowWindow( hWnd, nCmdShow ); } -#include "../helper/glew/wglew.h" - -typedef HGLRC eeWindowContex; -typedef HWND eeWindowHandler; typedef UINT eeScrapType; +typedef HWND eeWindowHandler; +#elif EE_PLATFORM == EE_PLATFORM_LINUX +#include +typedef Atom eeScrapType; +typedef Window X11Window; +typedef Display * eeWindowHandler; +#endif + +#ifdef EE_GLEW_AVAILABLE + +#if EE_PLATFORM == EE_PLATFORM_WIN +#include "../helper/glew/wglew.h" +typedef HGLRC eeWindowContex; #elif EE_PLATFORM == EE_PLATFORM_LINUX #include "../helper/glew/glxew.h" -#include - -typedef Window X11Window; - typedef GLXContext eeWindowContex; -typedef Display * eeWindowHandler; -typedef Atom eeScrapType; #elif EE_PLATFORM == EE_PLATFORM_MACOSX //#include @@ -34,6 +37,12 @@ typedef Atom eeScrapType; typedef Uint32 eeScrapType; #endif +#else + +typedef Uint32 eeWindowContex; //! Fallback + +#endif + #include "../utils/colors.hpp" #include "../utils/rect.hpp" #include "../utils/vector2.hpp" diff --git a/src/window/cengine.cpp b/src/window/cengine.cpp index bc448509f..5d15e875c 100755 --- a/src/window/cengine.cpp +++ b/src/window/cengine.cpp @@ -29,7 +29,7 @@ static int clipboard_filter(const SDL_Event *event) { return(1); } - Display* curDisplay = cEngine::instance()->GetWindowHandler(); + Display * curDisplay = cEngine::instance()->GetWindowHandler(); /* Handle window-manager specific clipboard events */ switch ( event->syswm.msg->event.xevent.type ) { @@ -280,8 +280,10 @@ void cEngine::Setup2D( const bool& KeepView ) { cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL ); if ( GLv_3 != GLi->Version() ) { + #ifndef EE_GLES2 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glShadeModel( GL_SMOOTH ); + #endif } GLi->EnableClientState( GL_VERTEX_ARRAY ); @@ -1018,6 +1020,8 @@ std::wstring cEngine::GetClipboardTextWStr() { void cEngine::SetCurrentContext( eeWindowContex Context ) { if ( mInit ) { + #ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN wglMakeCurrent( GetDC( mVideoInfo.info.window ), Context ); #elif EE_PLATFORM == EE_PLATFORM_LINUX @@ -1029,14 +1033,22 @@ void cEngine::SetCurrentContext( eeWindowContex Context ) { #else #warning No context supported on this platform #endif + + #endif } } eeWindowContex cEngine::GetContext() const { + #if defined( EE_GLEW_AVAILABLE ) && ( EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX ) return mContext; + #else + return 0; + #endif } void cEngine::GetMainContext() { +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN mContext = wglGetCurrentContext(); #elif EE_PLATFORM == EE_PLATFORM_LINUX @@ -1044,9 +1056,13 @@ void cEngine::GetMainContext() { #elif EE_PLATFORM == EE_PLATFORM_MACOSX //mContext = aglGetCurrentContext(); #endif + +#endif } eeWindowHandler cEngine::GetWindowHandler() { +#ifdef EE_GLEW_AVAILABLE + #if EE_PLATFORM == EE_PLATFORM_WIN return mVideoInfo.info.window; #elif EE_PLATFORM == EE_PLATFORM_LINUX @@ -1054,10 +1070,14 @@ eeWindowHandler cEngine::GetWindowHandler() { #elif EE_PLATFORM == EE_PLATFORM_MACOSX //return mVideoInfo.info.cocoa.window; #endif + +#else + return 0; +#endif } void cEngine::SetDefaultContext() { - #if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX + #if defined( EE_GLEW_AVAILABLE ) && ( EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX ) SetCurrentContext( mContext ); #endif } diff --git a/src/window/cengine.hpp b/src/window/cengine.hpp index b7c5771c0..678072460 100755 --- a/src/window/cengine.hpp +++ b/src/window/cengine.hpp @@ -224,7 +224,7 @@ class EE_API cEngine : public tSingleton { /** Set the size of the window for a windowed window */ void SetWindowSize( const Uint32& Width, const Uint32& Height ); - #if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX + #if ( EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX ) void SetCurrentContext( eeWindowContex Context ); eeWindowContex GetContext() const; @@ -258,7 +258,7 @@ class EE_API cEngine : public tSingleton { cView mDefaultView; const cView * mCurrentView; - #if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX + #if defined( EE_GLEW_AVAILABLE ) && ( EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_LINUX ) eeWindowContex mContext; #endif