Added some object labels in opengl so they're reflected on RenderDoc while on debug

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2022-11-02 09:28:42 +01:00
parent 69657a0014
commit 261bc696df
4 changed files with 28 additions and 1 deletions

View File

@ -132,6 +132,9 @@ void initGLFW ()
glfwWindowHint (GLFW_SAMPLES, 4);
glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1);
if (DEBUG)
glfwWindowHint (GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
}
void addPkg (CCombinedContainer* containers, const std::string& path, std::string pkgfile)

View File

@ -13,7 +13,12 @@ ITexture* CContainer::readTexture (std::string filename)
void* textureContents = this->readFile (filename, nullptr);
return new CTexture (textureContents);
ITexture* result = new CTexture (textureContents);
if (DEBUG)
glObjectLabel (GL_TEXTURE, result->getTextureID (), -1, filename.c_str ());
return result;
}
std::string CContainer::readVertexShader (const std::string& filename)

View File

@ -26,6 +26,10 @@ CFBO::CFBO (
glBindTexture (GL_TEXTURE_2D, this->m_texture);
// give OpenGL an empty image
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
// label stuff for debugging
if (DEBUG)
glObjectLabel (GL_TEXTURE, this->m_texture, -1, this->m_name.c_str ());
// set filtering parameters, otherwise the texture is not rendered
if (flags & TextureFlags::ClampUVs)
{

View File

@ -242,6 +242,14 @@ void CPass::render (CFBO* drawTo, ITexture* input, GLuint position, GLuint texco
glEnableVertexAttribArray ((*cur)->id);
glBindBuffer (GL_ARRAY_BUFFER, *(*cur)->value);
glVertexAttribPointer ((*cur)->id, (*cur)->elements, (*cur)->type, GL_FALSE, 0, nullptr);
if (DEBUG)
glObjectLabel (GL_BUFFER, *(*cur)->value, -1, (
"Image " + std::to_string (this->getMaterial ()->getImage ()->getId ()) +
" Pass " + this->m_pass->getShader() +
" " + (*cur)->name
).c_str ()
);
}
}
@ -391,6 +399,13 @@ void CPass::setupShaders ()
throw std::runtime_error (message);
}
if (DEBUG)
{
glObjectLabel (GL_PROGRAM, this->m_programID, -1, this->m_pass->getShader ().c_str ());
glObjectLabel (GL_SHADER, vertexShaderID, -1, (this->m_pass->getShader () + ".vert").c_str ());
glObjectLabel (GL_SHADER, fragmentShaderID, -1, (this->m_pass->getShader () + ".frag").c_str ());
}
// after being liked shaders can be dettached and deleted
glDetachShader (this->m_programID, vertexShaderID);
glDetachShader (this->m_programID, fragmentShaderID);