diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-09 19:20:41 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-09 20:25:57 +0300 |
commit | 62a416d5585106c2ce8e2259036740e7ba2c70c7 (patch) | |
tree | 4036eb451cba39c6353658353cc80d42a6b9f044 /src | |
parent | 6e052536a2dfb7f877a356477bc86c904aae1e71 (diff) | |
download | plus-62a416d5585106c2ce8e2259036740e7ba2c70c7.tar.gz plus-62a416d5585106c2ce8e2259036740e7ba2c70c7.tar.bz2 plus-62a416d5585106c2ce8e2259036740e7ba2c70c7.tar.xz plus-62a416d5585106c2ce8e2259036740e7ba2c70c7.zip |
Improve initial OpenGL state.
Moved shared code into separate method.
Diffstat (limited to 'src')
-rw-r--r-- | src/render/graphics.cpp | 29 | ||||
-rw-r--r-- | src/render/graphics.h | 2 | ||||
-rw-r--r-- | src/render/mgldefines.h | 6 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.cpp | 13 | ||||
-rw-r--r-- | src/render/modernopenglgraphics.cpp | 19 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.cpp | 11 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.cpp | 8 |
7 files changed, 43 insertions, 45 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 4c5d1d282..2a835aeeb 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -80,6 +80,7 @@ #ifdef __APPLE__ #include <OpenGL/OpenGL.h> #endif +#include "render/mgldefines.h" #endif #include "debug.h" @@ -638,3 +639,31 @@ const ClipRect *Graphics::getCurrentClipArea() const return &mClipStack.top(); } + +#ifdef USE_OPENGL +void Graphics::setOpenGLFlags() +{ + glEnable(GL_SCISSOR_TEST); + + glDisable(GL_MULTISAMPLE); + glDisable(GL_DITHER); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POLYGON_SMOOTH); + glDisable(GL_STENCIL_TEST); + glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_DEPTH_BOUNDS_TEST_EXT); + glDisable(GL_DEPTH_CLAMP); + glDisable(GL_RASTERIZER_DISCARD); + glDisable(GL_SAMPLE_MASK); + +#ifndef ANDROID +#ifndef __MINGW32__ + glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); +#endif +#endif + glHint(GL_TEXTURE_COMPRESSION_HINT_ARB, GL_FASTEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} +#endif diff --git a/src/render/graphics.h b/src/render/graphics.h index 3a051ed55..e6fc44865 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -505,6 +505,8 @@ class Graphics notfinal #ifdef USE_OPENGL virtual void createGLContext(); + + void setOpenGLFlags(); #endif /** * Holds the clip area stack. diff --git a/src/render/mgldefines.h b/src/render/mgldefines.h index d42dca853..3185e856b 100644 --- a/src/render/mgldefines.h +++ b/src/render/mgldefines.h @@ -92,6 +92,12 @@ #define GL_INFO_LOG_LENGTH 0x8B84 #endif +#ifndef GL_DEPTH_CLAMP +#define GL_DEPTH_CLAMP 0x864F +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_SAMPLE_MASK 0x8E51 +#endif + #endif // USE_OPENGL #endif // RENDER_MGLDEFINES_H diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index a38a291be..b0e78c534 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -886,19 +886,13 @@ void MobileOpenGLGraphics::beginDraw() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glEnable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); + setOpenGLFlags(); glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); - glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_MATERIAL); - glDisable(GL_STENCIL_TEST); glShadeModel(GL_FLAT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -907,13 +901,8 @@ void MobileOpenGLGraphics::beginDraw() glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); -#ifndef __MINGW32__ - glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); -#endif #endif -// glScalef(0.5F, 0.5F, 0.5F); - pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp index 231f83a67..e8d0756cf 100644 --- a/src/render/modernopenglgraphics.cpp +++ b/src/render/modernopenglgraphics.cpp @@ -840,22 +840,9 @@ void ModernOpenGLGraphics::updateScreen() void ModernOpenGLGraphics::beginDraw() { - glEnable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); - glDisable(GL_DEPTH_TEST); - glDisable(GL_COLOR_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_POLYGON_SMOOTH); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -#ifndef ANDROID -#ifndef __MINGW32__ - glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); -#endif -#endif - + setOpenGLFlags(); + glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); + glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, GL_FASTEST); pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 43191d369..f32003d49 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1222,16 +1222,10 @@ void NormalOpenGLGraphics::beginDraw() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glEnable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); + setOpenGLFlags(); glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); - glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_MATERIAL); - glDisable(GL_STENCIL_TEST); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -1245,9 +1239,6 @@ void NormalOpenGLGraphics::beginDraw() glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); -#ifndef __MINGW32__ - glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); -#endif #endif pushClipArea(Rect(0, 0, w, h)); diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index c67b84377..1f381b2b9 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -492,19 +492,13 @@ void SafeOpenGLGraphics::beginDraw() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glEnable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); + setOpenGLFlags(); glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); glDisable(GL_FOG); - glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_MATERIAL); - glDisable(GL_STENCIL_TEST); glShadeModel(GL_FLAT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } |