I am trying to put multiple depthbuffers into one Framebuffer. I want to use VR and render both eyes at the same time:
that means, in the geometry stage I want to clone the incoming triangle to two outgoing triangles with a shift of the eye offset for layered rendering. Therefore I would like to have two RGB textures / maybe one RGB texture 2d array and two depthbuffers / a depthbuffer array
here is my program code so far, the error occurred at the second last line of code and it is a GL_INVALID_ENUM error.
GLError();
glGenFramebuffers(1, &m_sFrameBufferInfo.m_nFrameBuffer);
GLError();
glBindFramebuffer(GL_FRAMEBUFFER, m_sFrameBufferInfo.m_nFrameBuffer);
//Left eye
GLuint textureLeft;
glGenTextures(1, &textureLeft);
GLError();
glBindTexture(GL_TEXTURE_2D, textureLeft);
GLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_nWindowWidth, m_nWindowHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
GLError();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLError();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLError();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureLeft, 0);
GLError();
//right eye
GLuint textureRight;
glGenTextures(1, &textureRight);
GLError();
glBindTexture(GL_TEXTURE_2D, textureRight);
GLError();
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_nWindowWidth, m_nWindowHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
GLError();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLError();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLError();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, textureRight, 0);
GLError();
//depth buffer
GLuint textureDepth;
glGenTextures(1, &textureDepth);
GLError();
glBindTexture(GL_TEXTURE_2D_ARRAY, textureDepth);
GLError();
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH24_STENCIL8, m_nWindowWidth, m_nWindowHeight,2 , 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
GLError();
glFramebufferTexture3D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D_ARRAY, textureDepth, 2, 0);
GLError();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLError();
Thanks for your help!