Render disc using blending, to avoid problems with trails being covered by disc

This commit is contained in:
Emma Broman
2020-09-02 10:55:15 +02:00
parent 15eaea1bc5
commit 1ea486fb1b

View File

@@ -222,6 +222,24 @@ void RenderableOrbitdisc::render(const RenderData& data, RendererTasks&) {
_texture->bind();
_shader->setUniform(_uniformCache.texture, unit);
GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0);
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);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glBindVertexArray(_quad);
@@ -229,6 +247,16 @@ void RenderableOrbitdisc::render(const RenderData& data, RendererTasks&) {
glEnable(GL_CULL_FACE);
_shader->deactivate();
// Restores blending state
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
glDepthMask(true);
if (!blendEnabled) {
glDisablei(GL_BLEND, 0);
}
}
void RenderableOrbitdisc::update(const UpdateData& data) {