Rewrite of glut printing thread

Hello,
I am working on a small graphic program that allows user to label measured geometry with GLUT based labels the rest of the program is in MFC/Opengl. The issue is that the labels work great in the normal view but when converted to a bitmap the labels text “flips” itself:

[SIZE=2]// draw the callout text
[/SIZE]glColor3ub(0, 0, 0); 
[SIZE=2]unsigned[/SIZE] [SIZE=2]int[/SIZE] i;
[SIZE=2]// the name
[/SIZE][SIZE=2]if[/SIZE]( feature->label_name ) {
glRasterPos2d(x_callout_location + (char_offset * 0.5), y_callout_location - (line_offset * max_lines)); 
[SIZE=2]for[/SIZE]( i = 0; i < strlen(feature->name); i++ )
{
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, feature->name[i]);
[SIZE=2]if[/SIZE]( i > max_x ) {
max_x = i;
}
}
max_lines++;
}


this code calls create bitmap:


BYTE* pBitmapBits = (BYTE*)malloc(IMAGE_WIDTH * IMAGE_HEIGHT * 4);
RenderToBitmap(pBitmapBits, IMAGE_WIDTH, IMAGE_HEIGHT, [SIZE=2]false[/SIZE], [SIZE=2]true[/SIZE], [SIZE=2]false[/SIZE], [SIZE=2]false[/SIZE], [SIZE=2]false[/SIZE], [SIZE=2]false[/SIZE] );
[SIZE=2]// Initialize the bitmap header info.
[/SIZE]BITMAPINFO bmi;
memset(&bmi, 0, [SIZE=2]sizeof[/SIZE](BITMAPINFO));
bmi.bmiHeader.biSize = [SIZE=2]sizeof[/SIZE](BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = IMAGE_WIDTH;
bmi.bmiHeader.biHeight = -IMAGE_HEIGHT;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = IMAGE_WIDTH * IMAGE_HEIGHT * 4;
WriteBitmap(filename, &bmi.bmiHeader, [SIZE=2]sizeof[/SIZE](BITMAPINFOHEADER), pBitmapBits, IMAGE_WIDTH * IMAGE_HEIGHT * 4);
free(pBitmapBits);


And finally this code renders the bitmap

[SIZE=2]// render to the backbuffer and copy the backbuffer to a bitmap
[/SIZE][SIZE=2]// clear buffer
[/SIZE]glClearColor(1, 1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
[SIZE=2]//glPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT); // for GL_DRAW_BUFFER and GL_READ_BUFFER
[/SIZE][SIZE=2]//glDrawBuffer(GL_BACK);
[/SIZE]glPushMatrix();
SetSize(width, height, [SIZE=2]true[/SIZE]);
glLoadIdentity();
[SIZE=2]// Draw here
[/SIZE][SIZE=2]if[/SIZE]( video ) {
oglDrawVideo();
} [SIZE=2]else[/SIZE] {
oglDrawScene(thumbnail, background, orient, zero, window);
}
[SIZE=2]// copy the frame buffer pixels to our bitmap
[/SIZE]glReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, bits);
SetSize(m_cx, m_cy, [SIZE=2]false[/SIZE]);
glPopMatrix();
[SIZE=2]// copy the framebuffer pixels to a texture
[/SIZE][SIZE=2]//glPopAttrib(); // GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
[/SIZE]


Attached are better pictures of the output.

Thanks for any help

-Derrek

I believe byte 0 of a bmp is top left of the image but byte 0 of an OpenGL is the bottom left. You need to allow for this when loading the image