Temporary solution for precision problems in spherical grids.

This commit is contained in:
Jonathas Costa
2020-05-28 17:01:08 -04:00
parent 9c2b5eefb2
commit 2c1035f05d
3 changed files with 35 additions and 17 deletions
@@ -214,16 +214,22 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() *
modelTransform;
_gridProgram->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
_gridProgram->setUniform("projectionTransform", data.camera.projectionMatrix());
_gridProgram->setUniform("modelViewTransform", modelViewTransform);
_gridProgram->setUniform("projectionTransform", glm::dmat4(data.camera.projectionMatrix()));
_gridProgram->setUniform("gridColor", _gridColor);
float adjustedLineWidth = 1.f;
#ifndef __APPLE__
adjustedLineWidth = _lineWidth;
#endif
// Saves current state:
GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0);
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
GLfloat currentLineWidth;
glGetFloatv(GL_LINE_WIDTH, &currentLineWidth);
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha,
blendDestRGB, blendSrcAlpha, blendSrcRGB;
@@ -235,11 +241,11 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
// Changes GL state:
glLineWidth(_lineWidth);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(adjustedLineWidth);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, nullptr);
@@ -251,9 +257,11 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
glLineWidth(currentLineWidth);
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
if (!isBlendEnabled) {
glDisablei(GL_BLEND, 0);
}
if (!isLineSmoothEnabled) {
glDisable(GL_LINE_SMOOTH);
}