For the old approach, generating a texture for the ImageTexture for compute shaders would look like this:
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_FLOAT, nullptr);
However, in DSA, glTexImage2D is no longer a thing and we need to use glTextureStorage2D
and glTextureSubImage2D
to replace it.
Yet, the new DSA functions don't work with ImageTextures, when I try to create texture for the ImageTextures, the texture returns black. Here is the code:
glCreateTextures(GL_TEXTURE_2D, 1, &m_texture);
glTextureStorage2D(m_texture, 0, m_internalFormat, (GLsizei)width, (GLsizei)height);
glTextureParameteri(m_texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTextureParameteri(m_texture, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTextureParameteri(m_texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(m_texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTextureSubImage2D(m_texture, 0, 0, 0, (GLsizei)width, (GLsizei)height, m_dataFormat, GL_UNSIGNED_BYTE, nullptr);
I've read about that the new DSA functions are immutable textures and maybe that causes this problem? If that is the case, what is the DSA counterpart for creating mutable textures?
nullptr
toglTex(ture)SubImage*D
. If you don't want to fill the texture with data, then just don't call it. $\endgroup$