diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-17 21:32:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:11 +0300 |
commit | adca09b643d05572321b5015809245493b8dd762 (patch) | |
tree | fa61cbe97396f0fc2a6c52e3e77caba30e0db6ef /source/blender/gpu/opengl/gl_state.cc | |
parent | a9f2ebb215084debae70099b3d2e58195d9a9e32 (diff) |
GPUState: Port default state to StateManager constructor
Diffstat (limited to 'source/blender/gpu/opengl/gl_state.cc')
-rw-r--r-- | source/blender/gpu/opengl/gl_state.cc | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index f85fb804317..3e3695e0b48 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -34,6 +34,32 @@ using namespace blender::gpu; /** \name GLStateManager * \{ */ +GLStateManager::GLStateManager(void) : GPUStateManager() +{ + /* Set other states that never change. */ + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + glEnable(GL_MULTISAMPLE); + glEnable(GL_PRIMITIVE_RESTART); + + glDisable(GL_DITHER); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + + glPrimitiveRestartIndex((GLuint)0xFFFFFFFF); + /* TODO: Should become default. But needs at least GL 4.3 */ + if (GLEW_ARB_ES3_compatibility) { + /* Takes predecence over GL_PRIMITIVE_RESTART */ + glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); + } + + /* Force update using default state. */ + current_ = ~state; + current_mutable_ = ~mutable_state; + set_state(state); + set_mutable_state(mutable_state); +} + void GLStateManager::set_state(const GPUState &state) { GPUState changed = state ^ current_; @@ -276,12 +302,12 @@ void GLStateManager::set_facing(const bool invert) void GLStateManager::set_backface_culling(const eGPUFaceCullTest test) { if (test != GPU_CULL_NONE) { - glDisable(GL_CULL_FACE); - } - else { glEnable(GL_CULL_FACE); glCullFace((test == GPU_CULL_FRONT) ? GL_FRONT : GL_BACK); } + else { + glDisable(GL_CULL_FACE); + } } void GLStateManager::set_provoking_vert(const eGPUProvokingVertex vert) |