From ba4522f4b9b6d864c202d7c4a0b3114b7dc4f747 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 10 Jan 2015 18:41:18 +0100 Subject: [PATCH] Changed: More aliases for OpenGL ES functions and defines to simplify code --- .../src/3d/driver/opengl/driver_opengl.cpp | 8 --- .../opengl/driver_opengl_extension_def.h | 43 +++++++++++++++ .../3d/driver/opengl/driver_opengl_matrix.cpp | 8 --- .../3d/driver/opengl/driver_opengl_states.cpp | 29 ---------- .../driver/opengl/driver_opengl_texture.cpp | 54 ++----------------- .../driver_opengl_vertex_buffer_hard.cpp | 51 +++--------------- 6 files changed, 54 insertions(+), 139 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index d129f3aa2..35cf9c094 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -435,11 +435,7 @@ bool CDriverGL::setupDisplay() glViewport(0,0,_CurrentMode.Width,_CurrentMode.Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); -#ifdef USE_OPENGLES - glOrthof(0.f,_CurrentMode.Width,_CurrentMode.Height,0.f,-1.0f,1.0f); -#else glOrtho(0,_CurrentMode.Width,_CurrentMode.Height,0,-1.0f,1.0f); -#endif glMatrixMode(GL_MODELVIEW); glLoadIdentity(); #ifndef USE_OPENGLES @@ -725,11 +721,7 @@ bool CDriverGL::activeFrameBufferObject(ITexture * tex) } else { -#ifdef USE_OPENGLES - nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); -#else nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -#endif return true; } } diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h index 41d2c1366..31ca00961 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h @@ -40,6 +40,24 @@ extern "C" { #define GL_ADD_SIGNED_EXT GL_ADD_SIGNED #define GL_INTERPOLATE_EXT GL_INTERPOLATE #define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE +#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES +#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES +#define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES +#define GL_DEPTH_COMPONENT24 GL_DEPTH_COMPONENT24_OES +#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0_OES +#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT_OES +#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_OES +#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER +#define GL_TEXTURE0_ARB GL_TEXTURE0 + +#define GL_ALPHA8 GL_ALPHA +#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE_ALPHA +#define GL_LUMINANCE8 GL_LUMINANCE +#define GL_RGBA8 GL_RGBA +#define GL_RGB8 GL_RGB + +#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW +#define GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_DRAW #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES @@ -48,6 +66,31 @@ extern "C" { #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES +#define nglGenRenderbuffersEXT nglGenRenderbuffersOES +#define nglBindRenderbufferEXT nglBindRenderbufferOES +#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES +#define nglRenderbufferStorageEXT nglRenderbufferStorageOES +#define nglGenFramebuffersEXT nglGenFramebuffersOES +#define nglBindFramebufferEXT nglBindFramebufferOES +#define nglFramebufferTexture2DEXT nglFramebufferTexture2DOES +#define nglFramebufferRenderbufferEXT nglFramebufferRenderbufferOES +#define nglCheckFramebufferStatusEXT nglCheckFramebufferStatusOES +#define nglDeleteBuffersARB glDeleteBuffers +#define nglIsBufferARB glIsBuffer +#define nglDeleteRenderbuffersEXT nglDeleteRenderbuffersOES +#define nglBindFramebufferEXT nglBindFramebufferOES +#define nglDeleteFramebuffersEXT nglDeleteFramebuffersOES +#define nglUnmapBufferARB nglUnmapBufferOES +#define nglActiveTextureARB glActiveTexture +#define nglClientActiveTextureARB glClientActiveTexture +#define nglBindBufferARB glBindBuffer +#define nglGenBuffersARB glGenBuffers +#define nglBufferDataARB glBufferData + +#define glFrustum glFrustumf +#define glOrtho glOrthof +#define glDepthRange glDepthRangef + #else #if defined(NL_OS_MAC) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp index 855c10c21..41575024c 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_matrix.cpp @@ -37,19 +37,11 @@ void CDriverGL::setFrustum(float left, float right, float bottom, float top, flo if (perspective) { -#ifdef USE_OPENGLES - glFrustumf(left,right,bottom,top,znear,zfar); -#else glFrustum(left,right,bottom,top,znear,zfar); -#endif } else { -#ifdef USE_OPENGLES - glOrthof(left,right,bottom,top,znear,zfar); -#else glOrtho(left,right,bottom,top,znear,zfar); -#endif } _ProjMatDirty = true; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp index 9bf53592f..8ec7a6bc8 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_states.cpp @@ -155,11 +155,7 @@ void CDriverGLStates::forceDefaults(uint nbStages) for(stage=0;stage_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID); @@ -1259,11 +1255,7 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff } if (glGetError() != GL_NO_ERROR) { -#ifdef USE_OPENGLES - glDeleteBuffers(1, &vertexBufferID); -#else nglDeleteBuffersARB(1, &vertexBufferID); -#endif return NULL; } @@ -1306,13 +1298,10 @@ void CVertexArrayRangeARB::updateLostBuffers() { nlassert((*it)->_VertexObjectId); GLuint id = (GLuint) (*it)->_VertexObjectId; -#ifdef USE_OPENGLES - nlassert(glIsBuffer(id)); - glDeleteBuffers(1, &id); -#else + nlassert(nglIsBufferARB(id)); nglDeleteBuffersARB(1, &id); -#endif + (*it)->_VertexObjectId = 0; (*it)->VB->setLocation(CVertexBuffer::NotResident); } @@ -1361,13 +1350,8 @@ CVertexBufferHardARB::~CVertexBufferHardARB() if (_VertexObjectId) { GLuint id = (GLuint) _VertexObjectId; -#ifdef USE_OPENGLES - nlassert(glIsBuffer(id)); - glDeleteBuffers(1, &id); -#else nlassert(nglIsBufferARB(id)); nglDeleteBuffersARB(1, &id); -#endif } if (_VertexArrayRange) { @@ -1412,12 +1396,7 @@ void *CVertexBufferHardARB::lock() } // recreate a vb GLuint vertexBufferID; - -#ifdef USE_OPENGLES - glGenBuffers(1, &vertexBufferID); -#else nglGenBuffersARB(1, &vertexBufferID); -#endif if (glGetError() != GL_NO_ERROR) { @@ -1436,35 +1415,23 @@ void *CVertexBufferHardARB::lock() break; case CVertexBuffer::StaticPreferred: if (_Driver->getStaticMemoryToVRAM()) -#ifdef USE_OPENGLES - glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW); -#else nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); -#endif else -#ifdef USE_OPENGLES glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW); -#else nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); -#endif break; // case CVertexBuffer::AGPPreferred: default: -#ifdef USE_OPENGLES - glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW); -#else nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); -#endif + break; } if (glGetError() != GL_NO_ERROR) { _Driver->incrementResetCounter(); -#ifdef USE_OPENGLES - glDeleteBuffers(1, &vertexBufferID); -#else + nglDeleteBuffersARB(1, &vertexBufferID); -#endif + return &_DummyVB[0];; } _VertexObjectId = vertexBufferID; @@ -1567,12 +1534,10 @@ void CVertexBufferHardARB::unlock() #ifdef USE_OPENGLES if (_Driver->_Extensions.OESMapBuffer) - { - unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER); - } -#else - unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); #endif + { + unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); + } #ifdef NL_DEBUG _Unmapping = false;