mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
VizFramework: Improve the stability of text color in ResInsight.
The setting for current OpenGL texture engine is not controlled well enough, causing the wrong texture to be active when rendering text - hence giving semi-random colors for the text.
This commit is contained in:
parent
cf439fbf96
commit
90402c285d
@ -347,11 +347,10 @@ void Glyph::setupAndBindTexture(OpenGLContext* oglContext, bool software)
|
|||||||
texture->setWrapMode(Texture2D_FF::CLAMP);
|
texture->setWrapMode(Texture2D_FF::CLAMP);
|
||||||
texture->setMinFilter(Texture2D_FF::NEAREST);
|
texture->setMinFilter(Texture2D_FF::NEAREST);
|
||||||
texture->setMagFilter(Texture2D_FF::NEAREST);
|
texture->setMagFilter(Texture2D_FF::NEAREST);
|
||||||
texture->setupTexture(oglContext);
|
|
||||||
texture->setupTextureParams(oglContext);
|
|
||||||
|
|
||||||
ref<RenderStateTextureMapping_FF> textureMapping = new RenderStateTextureMapping_FF(texture.p());
|
ref<RenderStateTextureMapping_FF> textureMapping = new RenderStateTextureMapping_FF(texture.p());
|
||||||
textureMapping->setTextureFunction(RenderStateTextureMapping_FF::MODULATE);
|
textureMapping->setTextureFunction(RenderStateTextureMapping_FF::MODULATE);
|
||||||
|
textureMapping->setupTexture(oglContext);
|
||||||
|
|
||||||
m_textureBindings = textureMapping;
|
m_textureBindings = textureMapping;
|
||||||
#endif
|
#endif
|
||||||
@ -364,7 +363,6 @@ void Glyph::setupAndBindTexture(OpenGLContext* oglContext, bool software)
|
|||||||
sampler->setMagFilter(Sampler::NEAREST);
|
sampler->setMagFilter(Sampler::NEAREST);
|
||||||
|
|
||||||
ref<Texture> texture = new Texture(m_textureImage.p());
|
ref<Texture> texture = new Texture(m_textureImage.p());
|
||||||
texture->setupTexture(oglContext);
|
|
||||||
|
|
||||||
RenderStateTextureBindings* textureBindings = new RenderStateTextureBindings(texture.p(), sampler.p(), "dummy");
|
RenderStateTextureBindings* textureBindings = new RenderStateTextureBindings(texture.p(), sampler.p(), "dummy");
|
||||||
textureBindings->setupTextures(oglContext);
|
textureBindings->setupTextures(oglContext);
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "cvfRenderStateDepth.h"
|
#include "cvfRenderStateDepth.h"
|
||||||
#include "cvfRenderStateBlending.h"
|
#include "cvfRenderStateBlending.h"
|
||||||
#include "cvfRenderStatePolygonOffset.h"
|
#include "cvfRenderStatePolygonOffset.h"
|
||||||
|
#include "cvfOpenGLCapabilities.h"
|
||||||
|
|
||||||
#ifndef CVF_OPENGL_ES
|
#ifndef CVF_OPENGL_ES
|
||||||
#include "cvfRenderState_FF.h"
|
#include "cvfRenderState_FF.h"
|
||||||
@ -349,8 +350,20 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix
|
|||||||
|
|
||||||
RenderStateLighting_FF light(false);
|
RenderStateLighting_FF light(false);
|
||||||
light.applyOpenGL(oglContext);
|
light.applyOpenGL(oglContext);
|
||||||
#endif
|
|
||||||
|
// The active texture may be set to something different than unit 0 if we end up using
|
||||||
|
// software rendering here, BUT the context actually has higher capabilities
|
||||||
|
// Must be set before any texture related OpenGL calls
|
||||||
|
if (oglContext->capabilities()->supportsOpenGL2())
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will get turned on during rendering of text, but must be off for background and border
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
projCam.applyOpenGL();
|
projCam.applyOpenGL();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -417,7 +430,7 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix
|
|||||||
#ifndef CVF_OPENGL_ES
|
#ifndef CVF_OPENGL_ES
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glColor4fv(m_backgroundColor.ptr());
|
glColor3fv(m_backgroundColor.ptr());
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
glVertex3fv(v1);
|
glVertex3fv(v1);
|
||||||
glVertex3fv(v2);
|
glVertex3fv(v2);
|
||||||
|
Loading…
Reference in New Issue
Block a user