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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// safety
|
||||
|
|
|
@ -256,6 +256,7 @@ public:
|
|||
{
|
||||
bool LowMaxVertexUniformCount;
|
||||
} Workarounds;
|
||||
void ObjectLabel(uint32_t identifier, uint32_t name, int32_t length, const char * label);
|
||||
|
||||
protected:
|
||||
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
|
||||
const GLuint hNewProg = glCreateProgram();
|
||||
#ifdef GL_KHR_debug
|
||||
if (glObjectLabel)
|
||||
glObjectLabel(GL_PROGRAM, hNewProg, -1, szWhat);
|
||||
#endif
|
||||
pGL->ObjectLabel(GL_PROGRAM, hNewProg, -1, szWhat);
|
||||
glAttachShader(hNewProg, hVert);
|
||||
glAttachShader(hNewProg, hFrag);
|
||||
glLinkProgram(hNewProg);
|
||||
|
@ -523,10 +520,7 @@ GLuint C4Shader::Create(GLenum iShaderType, const char *szWhat, const char *szSh
|
|||
{
|
||||
// Create shader
|
||||
GLuint hShader = glCreateShader(iShaderType);
|
||||
#ifdef GL_KHR_debug
|
||||
if (glObjectLabel)
|
||||
glObjectLabel(GL_SHADER, hShader, -1, szWhat);
|
||||
#endif
|
||||
pGL->ObjectLabel(GL_SHADER, hShader, -1, szWhat);
|
||||
|
||||
// Compile
|
||||
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.
|
||||
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
||||
|
||||
#ifdef GL_KHR_debug
|
||||
if (glObjectLabel)
|
||||
glObjectLabel(GL_BUFFER, drawingDataVertexBufferObject, -1, "<particles>/VBO");
|
||||
#endif
|
||||
pGL->ObjectLabel(GL_BUFFER, drawingDataVertexBufferObject, -1, "<particles>/VBO");
|
||||
|
||||
// generate new VAO ID
|
||||
drawingDataVertexArraysObject = pGL->GenVAOID();
|
||||
|
@ -1034,10 +1031,7 @@ void C4ParticleChunk::Draw(C4TargetFacet cgo, C4Object *obj, C4ShaderCall& call,
|
|||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, drawingDataVertexBufferObject);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ::Particles.GetIBO());
|
||||
#ifdef GL_KHR_debug
|
||||
if (glObjectLabel)
|
||||
glObjectLabel(GL_VERTEX_ARRAY, vao, -1, "<particles>/VAO");
|
||||
#endif
|
||||
pGL->ObjectLabel(GL_VERTEX_ARRAY, vao, -1, "<particles>/VAO");
|
||||
|
||||
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Position));
|
||||
glEnableVertexAttribArray(call.GetAttribute(C4SSA_Color));
|
||||
|
|
|
@ -604,10 +604,7 @@ void StdMesh::UpdateVBO()
|
|||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
#ifdef GL_KHR_debug
|
||||
if (glObjectLabel)
|
||||
glObjectLabel(GL_BUFFER, vbo, -1, (Label + "/VBO").c_str());
|
||||
#endif
|
||||
pGL->ObjectLabel(GL_BUFFER, vbo, -1, (Label + "/VBO").c_str());
|
||||
|
||||
// Unmapping the buffer may fail for certain reasons, in which case we need to try again.
|
||||
do
|
||||
|
|
Loading…
Reference in New Issue