Skip to content

Commit

Permalink
#5912: Rename OpenGLShaderPass methods and fields for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 5, 2022
1 parent df6c08a commit 15a6c9c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
10 changes: 5 additions & 5 deletions radiantcore/rendersystem/backend/FullBrightRenderer.cpp
Expand Up @@ -39,17 +39,17 @@ IRenderResult::Ptr FullBrightRenderer::render(RenderStateFlags globalstate, cons
// OpenGLShaderPasses (containing the renderable geometry), and render the
// contents of each bucket. Each pass is passed a reference to the "current"
// state, which it can change.
for (const auto& pair : _sortedStates)
for (const auto& [_, pass] : _sortedStates)
{
// Render the OpenGLShaderPass
if (pair.second->empty()) continue;
if (pass->empty()) continue;

if (pair.second->isApplicableTo(_renderViewType))
if (pass->isApplicableTo(_renderViewType))
{
pair.second->render(current, globalstate, view.getViewer(), view, time);
pass->render(current, globalstate, view.getViewer(), view, time);
}

pair.second->clearRenderables();
pass->clearRenderables();
}

cleanupState();
Expand Down
22 changes: 8 additions & 14 deletions radiantcore/rendersystem/backend/OpenGLShaderPass.cpp
Expand Up @@ -502,11 +502,10 @@ void OpenGLShaderPass::deactivateShaderProgram(OpenGLState& current)
current.glProgram = nullptr;
}

// Add a Renderable to this bucket
void OpenGLShaderPass::addRenderable(const OpenGLRenderable& renderable,
const Matrix4& modelview)
{
_renderablesWithoutEntity.emplace_back(renderable, modelview);
_transformedRenderables.emplace_back(renderable, modelview);
}

// Render the bucket contents
Expand All @@ -529,20 +528,17 @@ void OpenGLShaderPass::render(OpenGLState& current,

_owner.drawSurfaces(view);

if (!_renderablesWithoutEntity.empty())
{
renderAllContained(_renderablesWithoutEntity, current, viewer, time);
}
drawRenderables(current);
}

void OpenGLShaderPass::clearRenderables()
{
_renderablesWithoutEntity.clear();
_transformedRenderables.clear();
}

bool OpenGLShaderPass::empty()
{
return _renderablesWithoutEntity.empty() && !_owner.hasSurfaces() && !_owner.hasWindings();
return _transformedRenderables.empty() && !_owner.hasSurfaces() && !_owner.hasWindings();
}

bool OpenGLShaderPass::isApplicableTo(RenderViewType renderViewType) const
Expand Down Expand Up @@ -621,19 +617,17 @@ void OpenGLShaderPass::SetUpNonInteractionProgram(OpenGLState& current, const Ve
current.glProgram->applyRenderParams(viewer, objTransform, parms);
}

// Flush renderables
void OpenGLShaderPass::renderAllContained(const Renderables& renderables,
OpenGLState& current,
const Vector3& viewer,
std::size_t time)
void OpenGLShaderPass::drawRenderables(OpenGLState& current)
{
if (_transformedRenderables.empty()) return;

// Keep a pointer to the last transform matrix used
const Matrix4* transform = nullptr;

glPushMatrix();

// Iterate over each transformed renderable in the vector
for (const auto& r : renderables)
for (const auto& r : _transformedRenderables)
{
// If the current iteration's transform matrix was different from the
// last, apply it and store for the next iteration
Expand Down
8 changes: 2 additions & 6 deletions radiantcore/rendersystem/backend/OpenGLShaderPass.h
Expand Up @@ -53,18 +53,14 @@ class OpenGLShaderPass
};

// Vector of transformed renderables using this state
typedef std::vector<TransformedRenderable> Renderables;
Renderables _renderablesWithoutEntity;
std::vector<TransformedRenderable> _transformedRenderables;

protected:

void setupTextureMatrix(GLenum textureUnit, const IShaderLayer::Ptr& stage);

// Render all of the given TransformedRenderables
void renderAllContained(const Renderables& renderables,
OpenGLState& current,
const Vector3& viewer,
std::size_t time);
void drawRenderables(OpenGLState& current);

/* Helper functions to enable/disable particular GL states */

Expand Down

0 comments on commit 15a6c9c

Please sign in to comment.