Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-08-29 16:17:13 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-30 14:11:03 +0300
commit8527d84d3588563123bfad7ccbdeeff62ee90bdb (patch)
tree51ccbaa3c129c62a54af5aed43b55b9c89b901e6 /source/blender/gpu/opengl/gl_state.cc
parent4f395c84fe9f05b59b81be36b464521bcf92331e (diff)
GPUState: Move Scissor and Viewport state to framebuffer
This way it is way clearer what each viewport state is. There is no more save and reset. The scissor test is also saved per framebuffer. The only rule to remember is that the viewport state (size and origin) is reset for both the viewport and scissor when a texture is attached or detached from an attachment slot.
Diffstat (limited to 'source/blender/gpu/opengl/gl_state.cc')
-rw-r--r--source/blender/gpu/opengl/gl_state.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc
index 7dc3e44c516..84824191a12 100644
--- a/source/blender/gpu/opengl/gl_state.cc
+++ b/source/blender/gpu/opengl/gl_state.cc
@@ -27,6 +27,7 @@
#include "glew-mx.h"
#include "gl_context.hh"
+#include "gl_framebuffer.hh"
#include "gl_state.hh"
using namespace blender::gpu;
@@ -64,6 +65,13 @@ GLStateManager::GLStateManager(void) : GPUStateManager()
set_mutable_state(mutable_state);
}
+void GLStateManager::apply_state(void)
+{
+ this->set_state(this->state);
+ this->set_mutable_state(this->mutable_state);
+ active_fb->apply_state();
+};
+
void GLStateManager::set_state(const GPUState &state)
{
GPUState changed = state ^ current_;
@@ -125,22 +133,6 @@ void GLStateManager::set_mutable_state(const GPUStateMutable &state)
{
GPUStateMutable changed = state ^ current_mutable_;
- if ((changed.viewport_rect[0] != 0) || (changed.viewport_rect[1] != 0) ||
- (changed.viewport_rect[2] != 0) || (changed.viewport_rect[3] != 0)) {
- glViewport(UNPACK4(state.viewport_rect));
- }
-
- if ((changed.scissor_rect[0] != 0) || (changed.scissor_rect[1] != 0) ||
- (changed.scissor_rect[2] != 0) || (changed.scissor_rect[3] != 0)) {
- if ((state.scissor_rect[2] > 0)) {
- glScissor(UNPACK4(state.scissor_rect));
- glEnable(GL_SCISSOR_TEST);
- }
- else {
- glDisable(GL_SCISSOR_TEST);
- }
- }
-
/* TODO remove, should be uniform. */
if (changed.point_size != 0) {
if (state.point_size > 0.0f) {