forked from Mirrors/openclonk
GL: Deduplicate the check for glObjectLabel
parent
506d116c42
commit
a1a6e36cde
|
@ -275,6 +275,14 @@ bool CStdGL::PrepareSpriteShader(C4Shader& shader, const char* name, int ssc, C4
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CStdGL::ObjectLabel(uint32_t identifier, uint32_t name, int32_t length, const char * label)
|
||||||
|
{
|
||||||
|
#ifdef GL_KHR_debug
|
||||||
|
if (glObjectLabel)
|
||||||
|
glObjectLabel(identifier, name, length, label);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
|
CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
|
||||||
{
|
{
|
||||||
// safety
|
// safety
|
||||||
|
|
|
@ -256,6 +256,7 @@ public:
|
||||||
{
|
{
|
||||||
bool LowMaxVertexUniformCount;
|
bool LowMaxVertexUniformCount;
|
||||||
} Workarounds;
|
} Workarounds;
|
||||||
|
void ObjectLabel(uint32_t identifier, uint32_t name, int32_t length, const char * label);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
||||||
|
|
|
@ -329,10 +329,7 @@ bool C4Shader::Init(const char *szWhat, const char **szUniforms, const char **sz
|
||||||
|
|
||||||
// Link program
|
// Link program
|
||||||
const GLuint hNewProg = glCreateProgram();
|
const GLuint hNewProg = glCreateProgram();
|
||||||
#ifdef GL_KHR_debug
|
pGL->ObjectLabel(GL_PROGRAM, hNewProg, -1, szWhat);
|
||||||
if (glObjectLabel)
|
|
||||||
glObjectLabel(GL_PROGRAM, hNewProg, -1, szWhat);
|
|
||||||
#endif
|
|
||||||
glAttachShader(hNewProg, hVert);
|
glAttachShader(hNewProg, hVert);
|
||||||
glAttachShader(hNewProg, hFrag);
|
glAttachShader(hNewProg, hFrag);
|
||||||
glLinkProgram(hNewProg);
|
glLinkProgram(hNewProg);
|
||||||
|
@ -523,10 +520,7 @@ GLuint C4Shader::Create(GLenum iShaderType, const char *szWhat, const char *szSh
|
||||||
{
|
{
|
||||||
// Create shader
|
// Create shader
|
||||||
GLuint hShader = glCreateShader(iShaderType);
|
GLuint hShader = glCreateShader(iShaderType);
|
||||||
#ifdef GL_KHR_debug
|
pGL->ObjectLabel(GL_SHADER, hShader, -1, szWhat);
|
||||||
if (glObjectLabel)
|
|
||||||
glObjectLabel(GL_SHADER, hShader, -1, szWhat);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Compile
|
// Compile
|
||||||
glShaderSource(hShader, 1, &szShader, 0);
|
glShaderSource(hShader, 1, &szShader, 0);
|
||||||
|
|
|
@ -1006,10 +1006,7 @@ void C4ParticleChunk::Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall& call,
|
||||||
// glVertexAttribPointer requires a valid GL_ARRAY_BUFFER to be bound and we need the buffer to be created for glObjectLabel.
|
// glVertexAttribPointer requires a valid GL_ARRAY_BUFFER to be bound and we need the buffer to be created for glObjectLabel.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
||||||
|
|
||||||
#ifdef GL_KHR_debug
|
pGL->ObjectLabel(GL_BUFFER, drawingDataVertexBufferObject, -1, "<particles>/VBO");
|
||||||
if (glObjectLabel)
|
|
||||||
glObjectLabel(GL_BUFFER, drawingDataVertexBufferObject, -1, "<particles>/VBO");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// generate new VAO ID
|
// generate new VAO ID
|
||||||
drawingDataVertexArraysObject = pGL->GenVAOID();
|
drawingDataVertexArraysObject = pGL->GenVAOID();
|
||||||
|
@ -1034,10 +1031,7 @@ void C4ParticleChunk::Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall& call,
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ::Particles.GetIBO());
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ::Particles.GetIBO());
|
||||||
#ifdef GL_KHR_debug
|
pGL->ObjectLabel(GL_VERTEX_ARRAY, vao, -1, "<particles>/VAO");
|
||||||
if (glObjectLabel)
|
|
||||||
glObjectLabel(GL_VERTEX_ARRAY, vao, -1, "<particles>/VAO");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Position));
|
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Position));
|
||||||
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Color));
|
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Color));
|
||||||
|
|
|
@ -604,10 +604,7 @@ void StdMesh::UpdateVBO()
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
#ifdef GL_KHR_debug
|
pGL->ObjectLabel(GL_BUFFER, vbo, -1, (Label + "/VBO").c_str());
|
||||||
if (glObjectLabel)
|
|
||||||
glObjectLabel(GL_BUFFER, vbo, -1, (Label + "/VBO").c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Unmapping the buffer may fail for certain reasons, in which case we need to try again.
|
// Unmapping the buffer may fail for certain reasons, in which case we need to try again.
|
||||||
do
|
do
|
||||||
|
|
Loading…
Reference in New Issue