I am trying to use render to texture concept with cube map textures but somehow texture is not getting applied to geometry in draw call. Here is my code
#define WIDTH 64
#define HEIGHT 64
glGenTextures(1, &id1);
glBindTexture(GL_TEXTURE_CUBE_MAP, id1);
glGenFramebuffers(1, &Fboid);
for(int i=0;i<6;i++)
{
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexImage2D(types[i], 0, GL_RGBA,WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE,0);
}
glBindFramebuffer(GL_FRAMEBUFFER, Fboid);
for(int i=0;i<6;i++)
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,types[i],id1,0);
draw_cube();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
draw();
I have verified that framebuffer binding is complete or not. Also draw_cube() correctly draws geometry as per expected. When i remove FBO and supply data to glteximage2D() it correctly applies cubemap texture to geometry in draw() call. Width height is same as the viewport set in draw_cube call.
What's wrong with above code?