mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0025854: Visualization, TKOpenGl - add option to request Core profile 3.2+
OpenGl_Caps::contextCompatible - new option to request compatibility/core OpenGL profile. OpenGl_Window - request core profile when requested (WGL and Cocoa). OpenGl_Context::CheckExtension() - retrieve extensions using glGetStringi(). OpenGl_Context::init() - set backward-compatible functions to NULL within core profile: core11, core15, core20, core32back, core33back, core41back, core42back, core43back, core44back. OpenGl_Context::BindDefaultVao() - create default VAO required for core profile. OpenGl_Context::ReadGlVersion() - make method public. OpenGl_ShaderManager - create programs using GLSL version 150 when available. OpenGl_VertexBuffer, OpenGl_ShaderProgram, OpenGl_ShaderObject - use functions set from core profile instead of compatibility. TKOpenGl - escape deprecated functionality with runtime checks. Command vcaps - add option -compatibleProfile to request core/compatibility profile. NIS_View - prevenr rendering within Core profile (unsupported). Test case for issue CR25854 Aspect_GraphicCallbackStruct::IsCoreProfile - add new field to the struct for NIS
This commit is contained in:
@@ -230,6 +230,8 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
? "precision highp float;\n"
|
||||
: "precision mediump float;\n");
|
||||
aSource = aHeader + aPrefix + aSource;
|
||||
#else
|
||||
aSource = aHeader + aSource;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -354,7 +356,7 @@ Standard_Boolean OpenGl_ShaderProgram::AttachShader (const Handle(OpenGl_Context
|
||||
}
|
||||
|
||||
myShaderObjects.Append (theShader);
|
||||
theCtx->core20->glAttachShader (myProgramID, theShader->myShaderID);
|
||||
theCtx->core20fwd->glAttachShader (myProgramID, theShader->myShaderID);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -388,7 +390,7 @@ Standard_Boolean OpenGl_ShaderProgram::DetachShader (const Handle(OpenGl_Context
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glDetachShader (myProgramID, theShader->myShaderID);
|
||||
theCtx->core20fwd->glDetachShader (myProgramID, theShader->myShaderID);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -404,8 +406,8 @@ Standard_Boolean OpenGl_ShaderProgram::Link (const Handle(OpenGl_Context)& theCt
|
||||
}
|
||||
|
||||
GLint aStatus = GL_FALSE;
|
||||
theCtx->core20->glLinkProgram (myProgramID);
|
||||
theCtx->core20->glGetProgramiv (myProgramID, GL_LINK_STATUS, &aStatus);
|
||||
theCtx->core20fwd->glLinkProgram (myProgramID);
|
||||
theCtx->core20fwd->glGetProgramiv (myProgramID, GL_LINK_STATUS, &aStatus);
|
||||
if (aStatus == GL_FALSE)
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -431,12 +433,12 @@ Standard_Boolean OpenGl_ShaderProgram::FetchInfoLog (const Handle(OpenGl_Context
|
||||
}
|
||||
|
||||
GLint aLength = 0;
|
||||
theCtx->core20->glGetProgramiv (myProgramID, GL_INFO_LOG_LENGTH, &aLength);
|
||||
theCtx->core20fwd->glGetProgramiv (myProgramID, GL_INFO_LOG_LENGTH, &aLength);
|
||||
if (aLength > 0)
|
||||
{
|
||||
GLchar* aLog = (GLchar*) alloca (aLength);
|
||||
memset (aLog, 0, aLength);
|
||||
theCtx->core20->glGetProgramInfoLog (myProgramID, aLength, NULL, aLog);
|
||||
theCtx->core20fwd->glGetProgramInfoLog (myProgramID, aLength, NULL, aLog);
|
||||
theOutput = aLog;
|
||||
}
|
||||
return Standard_True;
|
||||
@@ -496,7 +498,7 @@ GLint OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& th
|
||||
const GLchar* theName) const
|
||||
{
|
||||
return myProgramID != NO_PROGRAM
|
||||
? theCtx->core20->glGetUniformLocation (myProgramID, theName)
|
||||
? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
|
||||
: INVALID_LOCATION;
|
||||
}
|
||||
|
||||
@@ -508,7 +510,7 @@ GLint OpenGl_ShaderProgram::GetAttributeLocation (const Handle(OpenGl_Context)&
|
||||
const GLchar* theName) const
|
||||
{
|
||||
return myProgramID != NO_PROGRAM
|
||||
? theCtx->core20->glGetAttribLocation (myProgramID, theName)
|
||||
? theCtx->core20fwd->glGetAttribLocation (myProgramID, theName)
|
||||
: INVALID_LOCATION;
|
||||
}
|
||||
|
||||
@@ -549,7 +551,7 @@ Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glGetUniformiv (myProgramID, theLocation, theValue);
|
||||
theCtx->core20fwd->glGetUniformiv (myProgramID, theLocation, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -577,7 +579,7 @@ Standard_Boolean OpenGl_ShaderProgram::GetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glGetUniformfv (myProgramID, theLocation, theValue);
|
||||
theCtx->core20fwd->glGetUniformfv (myProgramID, theLocation, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -605,7 +607,7 @@ Standard_Boolean OpenGl_ShaderProgram::GetAttribute (const Handle(OpenGl_Context
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glGetVertexAttribiv (theIndex, GL_CURRENT_VERTEX_ATTRIB, theValue);
|
||||
theCtx->core20fwd->glGetVertexAttribiv (theIndex, GL_CURRENT_VERTEX_ATTRIB, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -633,7 +635,7 @@ Standard_Boolean OpenGl_ShaderProgram::GetAttribute (const Handle(OpenGl_Context
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glGetVertexAttribfv (theIndex, GL_CURRENT_VERTEX_ATTRIB, theValue);
|
||||
theCtx->core20fwd->glGetVertexAttribfv (theIndex, GL_CURRENT_VERTEX_ATTRIB, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -785,7 +787,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform1i (theLocation, theValue);
|
||||
theCtx->core20fwd->glUniform1i (theLocation, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -877,7 +879,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform1f (theLocation, theValue);
|
||||
theCtx->core20fwd->glUniform1f (theLocation, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -905,7 +907,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform2iv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform2iv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -933,7 +935,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform3iv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform3iv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -961,7 +963,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform4iv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform4iv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -989,7 +991,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform2fv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform2fv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1019,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform3fv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform3fv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1047,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform4fv (theLocation, 1, theValue);
|
||||
theCtx->core20fwd->glUniform4fv (theLocation, 1, theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1075,7 +1077,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniformMatrix4fv (theLocation, 1, GL_FALSE, theTranspose ? theValue.Transposed() : theValue);
|
||||
theCtx->core20fwd->glUniformMatrix4fv (theLocation, 1, GL_FALSE, theTranspose ? theValue.Transposed() : theValue);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1117,7 +1119,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform1fv (theLocation, theCount, theData);
|
||||
theCtx->core20fwd->glUniform1fv (theLocation, theCount, theData);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1135,7 +1137,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform2fv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform2fv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1153,7 +1155,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform3fv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform3fv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1171,7 +1173,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform4fv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform4fv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1189,7 +1191,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform1iv (theLocation, theCount, theData);
|
||||
theCtx->core20fwd->glUniform1iv (theLocation, theCount, theData);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1209,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform2iv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform2iv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1225,7 +1227,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform3iv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform3iv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1243,7 +1245,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetUniform (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform4iv (theLocation, theCount, theData[0].GetData());
|
||||
theCtx->core20fwd->glUniform4iv (theLocation, theCount, theData[0].GetData());
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1271,7 +1273,7 @@ Standard_Boolean OpenGl_ShaderProgram::SetSampler (const Handle(OpenGl_Context)&
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCtx->core20->glUniform1i (theLocation, theTextureUnit);
|
||||
theCtx->core20fwd->glUniform1i (theLocation, theTextureUnit);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -1282,9 +1284,9 @@ Standard_Boolean OpenGl_ShaderProgram::SetSampler (const Handle(OpenGl_Context)&
|
||||
Standard_Boolean OpenGl_ShaderProgram::Create (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (myProgramID == NO_PROGRAM
|
||||
&& theCtx->core20 != NULL)
|
||||
&& theCtx->core20fwd != NULL)
|
||||
{
|
||||
myProgramID = theCtx->core20->glCreateProgram();
|
||||
myProgramID = theCtx->core20fwd->glCreateProgram();
|
||||
}
|
||||
|
||||
return myProgramID != NO_PROGRAM;
|
||||
@@ -1313,10 +1315,10 @@ void OpenGl_ShaderProgram::Release (OpenGl_Context* theCtx)
|
||||
}
|
||||
}
|
||||
|
||||
if (theCtx->core20 != NULL
|
||||
if (theCtx->core20fwd != NULL
|
||||
&& theCtx->IsValid())
|
||||
{
|
||||
theCtx->core20->glDeleteProgram (myProgramID);
|
||||
theCtx->core20fwd->glDeleteProgram (myProgramID);
|
||||
}
|
||||
|
||||
myProgramID = NO_PROGRAM;
|
||||
|
Reference in New Issue
Block a user