mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025213: Visualization, TKOpenGl - do not use deprecated built-ins in GLSL shaders
Inherit NCollection_Buffer from Standard_Transient, do not use incomplete NCollection_Handle. OpenGl_Context, add methods ActiveProgram(),BindProgram() to manage currently active GLSL program. Add method ::ToUseVbo(). OpenGl_ShaderProgram, setup locations of pre-defined vertex attributes occVertex, occNormal, occTexCoord, occColor before linkage. Remove methods OpenGl_ShaderProgram::Bind(), ::BindWithVariables() and ::Unbind() - OpenGl_Context::BindProgram() should be used instead. Introduce class OpenGl_VertexBufferCompat, which emulates VBO behavior on systems without VBO (compatibility with broken OpenGL drivers on Windows). OpenGl_PrimitiveArray - use OpenGl_VertexBufferCompat when VBO is unavailable, remove duplicated code. Use OpenGl_VertexBuffer::HasNormalAttribute() method to activate lighting. OpenGl_Text - use OpenGl_VertexBufferCompat, eliminate duplicated code. Changes in OpenGl_VertexBuffer, drop methods BindFixed()/UnbindFixed(). Superseded by new methods BindAllAttributes()/UnbindAllAttributes() which handle active GLSL program, when it is set.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
#include <Standard_Atomic.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
@@ -262,6 +263,12 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
}
|
||||
}
|
||||
|
||||
// bind locations for pre-defined Vertex Attributes
|
||||
SetAttributeName (theCtx, Graphic3d_TOA_POS, "occVertex");
|
||||
SetAttributeName (theCtx, Graphic3d_TOA_NORM, "occNormal");
|
||||
SetAttributeName (theCtx, Graphic3d_TOA_UV, "occTexCoord");
|
||||
SetAttributeName (theCtx, Graphic3d_TOA_COLOR, "occColor");
|
||||
|
||||
if (!Link (theCtx))
|
||||
{
|
||||
TCollection_AsciiString aLog;
|
||||
@@ -413,21 +420,6 @@ Standard_Boolean OpenGl_ShaderProgram::FetchInfoLog (const Handle(OpenGl_Context
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Bind
|
||||
// purpose : Sets the program object as part of current rendering state
|
||||
// =======================================================================
|
||||
void OpenGl_ShaderProgram::Bind (const Handle(OpenGl_Context)& theCtx) const
|
||||
{
|
||||
if (myProgramID == NO_PROGRAM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theCtx->core20->glUseProgram (myProgramID);
|
||||
theCtx->ShaderManager()->myIsPP = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ApplyVariables
|
||||
// purpose : Fetches uniform variables from proxy shader program
|
||||
@@ -448,29 +440,6 @@ Standard_Boolean OpenGl_ShaderProgram::ApplyVariables(const Handle(OpenGl_Contex
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BindWithVariables
|
||||
// purpose : Binds the program object and applies variables
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderProgram::BindWithVariables (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
Bind (theCtx);
|
||||
return ApplyVariables (theCtx);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Unbind
|
||||
// purpose : Reverts to fixed-function graphics pipeline (FFP)
|
||||
// =======================================================================
|
||||
void OpenGl_ShaderProgram::Unbind (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (theCtx->ShaderManager()->myIsPP)
|
||||
{
|
||||
theCtx->core20->glUseProgram (NO_PROGRAM);
|
||||
theCtx->ShaderManager()->myIsPP = Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ActiveState
|
||||
// purpose : Returns index of last modification for specified state type
|
||||
|
Reference in New Issue
Block a user