mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 05:19:18 -06:00
OpenGL State Caching.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
namespace {
|
||||
@@ -290,25 +291,6 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) {
|
||||
_program->setUniform("projectionTransform", data.camera.projectionMatrix());
|
||||
_program->setUniform("color", glm::vec4(_lineColor.value(), _opacity));
|
||||
|
||||
// Save current state:
|
||||
GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0);
|
||||
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
|
||||
GLfloat currentLineWidth;
|
||||
glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth);
|
||||
|
||||
GLenum blendEquationRGB;
|
||||
GLenum blendEquationAlpha;
|
||||
GLenum blendDestAlpha;
|
||||
GLenum blendDestRGB;
|
||||
GLenum blendSrcAlpha;
|
||||
GLenum blendSrcRGB;
|
||||
glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB);
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha);
|
||||
glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB);
|
||||
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
|
||||
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
|
||||
|
||||
// Change GL state:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnablei(GL_BLEND, 0);
|
||||
@@ -322,15 +304,8 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) {
|
||||
// Restore GL State
|
||||
unbindGL();
|
||||
_program->deactivate();
|
||||
glLineWidth(currentLineWidth);
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
if (!isBlendEnabled) {
|
||||
glDisablei(GL_BLEND, 0);
|
||||
}
|
||||
if (!isLineSmoothEnabled) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
global::renderEngine.openglStateCache().setBlendState();
|
||||
global::renderEngine.openglStateCache().setLineState();
|
||||
}
|
||||
|
||||
void RenderableNodeLine::validateNodes() {
|
||||
|
||||
Reference in New Issue
Block a user