So I have a problem, I am calling some opengl frame buffer functions in my code but for some reason I get the error from the title. I am also calling many other opengl functions without any problems but with this particular one I have troubles. So problematic code:
void FrameBuffer::create()
{
glCreateFramebuffers(1, &m_RendererId);
glBindFramebuffer(GL_FRAMEBUFFER, m_RendererId);
glCreateTextures(GL_TEXTURE_2D, 1, &m_ColorAttach);
glBindTexture(GL_TEXTURE_2D, m_ColorAttach);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_buffSpec.Width, m_buffSpec.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_ColorAttach, 0);
glCreateTextures(GL_TEXTURE_2D, 1, &m_DepthAttach);
glBindTexture(GL_TEXTURE_2D, m_DepthAttach);
//glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, m_buffSpec.Width, m_buffSpec.Height);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_buffSpec.Width, m_buffSpec.Height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); //(storage ili image??)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthAttach, 0);
if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
std::cout << "Framebuffer status not OK" << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
On the second line, calling bind frame buffer, I get this error. In my header file I do have all the needed uint32_t ids. When I comment out that second line I get the same error but on glCreateTextures. What could be wrong here? This is a method from my frame buffer class. This is the code where the method is called:
EditorLayer::EditorLayer()
: Layer("Example"),
mVAO(std::make_shared<VertexArrayObject>()),
mCubeVao(std::make_shared<VertexArrayObject>()),
m_lib(std::make_shared<ShaderLibrary>()),
camControl(std::make_shared<CameraController>()),
textureCube(std::make_shared<CubeTexture>(m_Textures)),
spec{ 400, 400 },
m_FB(std::make_shared<FrameBuffer>(spec))
{
m_FB->create();
mCubeVao->generateVAO();
mCubeVao->bindData(verticesCube, texind, 120, 36);
mCubeVao->dataLayout(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 0);
mCubeVao->dataLayout(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), 3 * sizeof(float));
mCubeVao->unbindVertexArrayObject();
glEnable(GL_DEPTH_TEST);
textureCube->loadTexture();
activeScene.CreateEntity();
m_lib->Load("shady", "C:/eng/Nube/GameApp/shaders/textureCube.glsl");
}
All the other stuff is just fine but this one thing, this frame buffer, is not working. Any ideas?