mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Render disc using blending, to avoid problems with trails being covered by disc
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user