i want to render to a cube map… but im unsure how…
this is how i got it now… which is wrong… im unsure how i would bind the different faces of the cubemap…
inline void Begin(GLenum texture)
{
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glActiveTexture(texture);
glBindTexture(GL_TEXTURE_CUBE_MAP, img);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0,width_,height_);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
}
this is how i set it up…
inline void Create(int _width, int _height, GLint type)
{
width_ = _width;
height_ = _height;
type_ = type;
glActiveTexture(GL_TEXTURE21);
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glGenRenderbuffersEXT(1, &depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width_, height_);
glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_CUBE_MAP, img);
for(int i=0; i<6; i++)
{
glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, GL_RGBA8, _width, height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, this->texID, 0);
}
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
}