Thank you for reply.
Actually I am trying to draw parts of the screen rendered by opengl. So I received an advice from this site to draw the parts as texture in quad portions. I used glReadPixels() to read the frame buffer and draw it as texture but the resulting image was just the texture image i already loaded to the program. Also I used the windows function:
COLORREF pixel = GetPixel( GetDC( NULL ), ip, jp);
But the same result, it gave me the bmp texture file and not the image itself.
I need just a way to read the pixels colors from the screen and save the portion I need to draw in an auxiliary buffer or any other buffer I can draw (drawable buffer). I used glDrawPixels() did not work with the available buffers(front and back).
Now, I am desperately looking for a piece of software to capture the screen and read the colors of the pixels and then I will need an auxiliary buffer or another drawable one to draw selected portions of the image. There are many commercial screen capturers or grabber software but I can not employ them in my software, I need it to be embedded in my program
I would really appreciate any help
This is my simple function:
void MyFunction()
{
int width_p = 600;
int height_p = 600;
float VCorners[4][3] = {{ 0.0f, 0.0f, -1.0f }, // left bottom
{ 8.5f, 0.0f, -1.0f }, //right bottom
{ 8.5f, 8.5f, -1.0f }, // right top
{ 0.0f, 8.5f, -1.0f }}; // left top
float percentage;
float* pixels_index = new float[3*(width_p)*(height_p)];
int ip,jp;
for (jp=0;jp<height_p;jp++)
{
percentage=jp/height_p;
cout<< percentage <<"
";
for (ip=0;ip<width_p;ip++)
{
COLORREF pixel = GetPixel( GetDC( NULL ), ip, jp);
pixels_index[3*(width_p*jp + ip)] = (int)GetRValue( pixel );
pixels_index[3*(width_p*jp + ip)+1] = (int)GetGValue( pixel );
pixels_index[3*(width_p*jp + ip)+2] = (int)GetBValue( pixel );
}
}
//glReadBuffer(GL_FRONT_RIGHT);
//glPixelStorei(GL_PACK_ALIGNMENT, 1);
//glReadPixels(0,0,600,600,GL_RGB,GL_FLOAT, pixels_index);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 100, 100, 0, GL_FLOAT, GL_FLOAT, pixels_index);
glEnable (GL_TEXTURE_2D);
glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0); glVertex3fv(VCorners[0]);
glTexCoord2f (1.0, 0.0); glVertex3fv(VCorners[1]);
glTexCoord2f (1.0, 1.0); glVertex3fv(VCorners[2]);
glTexCoord2f (0.0, 1.0); glVertex3fv(VCorners[3]);
glEnd ();
glDisable (GL_TEXTURE_2D);
glutSwapBuffers();
glFlush();
delete pixels_index;
}