Hi!
I have a problem with offscreen rendering:
I’ve been created a pBuffer, got a DC from this and created a RC.
I wanna get the framebuffer contents in:
GLubyte *imgout;
Well, in my render function, i do the following:
void Render(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0,0,-5);
glBegin(GL_TRIANGLES);
glVertex3d(-1,0,0);
glVertex3d(1,0,0);
glVertex3f(0.0f,1.6f,0.0f);
glEnd();
//here i try to get the framebuffer content:
glReadPixels(
0,0,
screen_width,
screen_height,
GL_RGBA,
GL_UNSIGNED_BYTE,imgout
);
}
Well, all what i get is a GLubyte array filled with the color specified in glClearColor, pure blue.
I’d also tried with glCopyTexSubImage2D. I do the following:
GLuint tex;
ZeroMemory(imgout,sizeof(GLubyte)4screen_width*screen_height);
glGenTextures(1,&tex);
glBindTexture(GL_TEXTURE_2D, tex);
//i create an empty texture:
glTexImage2D(
GL_TEXTURE_2D, 0, 4,
screen_width, screen_height,
0, GL_RGBA,
GL_UNSIGNED_BYTE, imgout
);
glCopyTexSubImage2D(
GL_TEXTURE_2D,0,0,0,0,0,
screen_width,screen_height
);
glFlush();
glGetTexImage(
GL_TEXTURE_2D,0,GL_RGBA,
GL_UNSIGNED_BYTE,imgout);
But in this case i got an imgout array zero-filled.
sugestions??..
Bad english i wrote, i know… i’m spanish :rolleyes:
see ya!