mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0032461: Visualization - expensive call of glGetTexEnviv/glTexEnvi in each render of OpenGl_Text
- removed the call of glGetTexEnviv, glTexEnvi - replaced on the OpenGl_Sampler::applyGlobalTextureParams/resetGlobalTextureParams - added the method in OpenGl_Font returning first texture
This commit is contained in:
parent
7c6fecf9a8
commit
58f2990bc5
@ -114,6 +114,12 @@ public:
|
|||||||
const Standard_Utf32Char theUChar,
|
const Standard_Utf32Char theUChar,
|
||||||
Tile& theGlyph);
|
Tile& theGlyph);
|
||||||
|
|
||||||
|
//! @return first texture.
|
||||||
|
const Handle(OpenGl_Texture)& Texture() const
|
||||||
|
{
|
||||||
|
return myTextures.First();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Render new glyph to the texture.
|
//! Render new glyph to the texture.
|
||||||
|
@ -27,6 +27,7 @@ class OpenGl_Sampler : public OpenGl_Resource
|
|||||||
{
|
{
|
||||||
friend class OpenGl_Context;
|
friend class OpenGl_Context;
|
||||||
friend class OpenGl_Texture;
|
friend class OpenGl_Texture;
|
||||||
|
friend class OpenGl_Text;
|
||||||
DEFINE_STANDARD_RTTIEXT(OpenGl_Sampler, OpenGl_Resource)
|
DEFINE_STANDARD_RTTIEXT(OpenGl_Sampler, OpenGl_Resource)
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <OpenGl_Aspects.hxx>
|
#include <OpenGl_Aspects.hxx>
|
||||||
#include <OpenGl_GlCore11.hxx>
|
#include <OpenGl_GlCore11.hxx>
|
||||||
#include <OpenGl_GraphicDriver.hxx>
|
#include <OpenGl_GraphicDriver.hxx>
|
||||||
|
#include <OpenGl_Sampler.hxx>
|
||||||
#include <OpenGl_ShaderManager.hxx>
|
#include <OpenGl_ShaderManager.hxx>
|
||||||
#include <OpenGl_ShaderProgram.hxx>
|
#include <OpenGl_ShaderProgram.hxx>
|
||||||
#include <OpenGl_ShaderStates.hxx>
|
#include <OpenGl_ShaderStates.hxx>
|
||||||
@ -780,16 +781,10 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
}
|
}
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
// activate texture unit
|
// activate texture unit
|
||||||
GLint aTexEnvParam = GL_REPLACE;
|
if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull())
|
||||||
if (theCtx->core11ffp != NULL)
|
|
||||||
{
|
{
|
||||||
theCtx->core11fwd->glDisable (GL_TEXTURE_1D);
|
const Handle(OpenGl_Texture)& aTexture = myFont->Texture();
|
||||||
theCtx->core11fwd->glEnable (GL_TEXTURE_2D);
|
OpenGl_Sampler::applyGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters());
|
||||||
theCtx->core11ffp->glGetTexEnviv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &aTexEnvParam);
|
|
||||||
if (aTexEnvParam != GL_REPLACE)
|
|
||||||
{
|
|
||||||
theCtx->core11ffp->glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -861,9 +856,10 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(GL_ES_VERSION_2_0)
|
#if !defined(GL_ES_VERSION_2_0)
|
||||||
if (theCtx->core11ffp != NULL)
|
if (theCtx->core11ffp != NULL && theCtx->ActiveProgram().IsNull())
|
||||||
{
|
{
|
||||||
theCtx->core11ffp->glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aTexEnvParam);
|
const Handle(OpenGl_Texture)& aTexture = myFont->Texture();
|
||||||
|
OpenGl_Sampler::resetGlobalTextureParams (theCtx, *aTexture, aTexture->Sampler()->Parameters());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user