Skip to content

Commit

Permalink
#5909: Reduce the GL state handling code to the minimum for interacti…
Browse files Browse the repository at this point in the history
…on stages
  • Loading branch information
codereader committed Mar 13, 2022
1 parent 4199e47 commit 88615af
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions radiantcore/rendersystem/backend/LightInteractions.cpp
Expand Up @@ -137,8 +137,24 @@ void LightInteractions::drawInteractions(OpenGLState& state, GLSLBumpProgram& pr

if (!pass || !pass->stateIsActive()) continue;

// Apply our state to the current state object
pass->evaluateStagesAndApplyState(state, globalFlagsMask, renderTime, entity);
// Evaluate the expressions in the material stages
pass->evaluateShaderStages(renderTime, entity);

// Enable alphatest if required
if (pass->state().stage0 && pass->state().stage0->hasAlphaTest())
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, pass->state().stage0->getAlphaTest());
}
else
{
glDisable(GL_ALPHA_TEST);
}

// Bind textures
OpenGLState::SetTextureState(state.texture0, pass->state().texture0, GL_TEXTURE0, GL_TEXTURE_2D);
OpenGLState::SetTextureState(state.texture1, pass->state().texture1, GL_TEXTURE1, GL_TEXTURE_2D);
OpenGLState::SetTextureState(state.texture2, pass->state().texture2, GL_TEXTURE2, GL_TEXTURE_2D);

// Load stage texture matrices
program.setDiffuseTextureTransform(pass->getDiffuseTextureTransform());
Expand Down
@@ -1,6 +1,7 @@
#include "GLSLBumpProgram.h"
#include "../GLProgramFactory.h"

#include "GLProgramAttributes.h"
#include "itextstream.h"
#include "igame.h"
#include "string/convert.h"
Expand Down
@@ -1,6 +1,5 @@
#pragma once

#include "GLProgramAttributes.h"
#include "GLSLProgramBase.h"

namespace render
Expand Down

0 comments on commit 88615af

Please sign in to comment.