Double buffering with GDI calls

I understand OpenGL doublebuffering ending with the GDI swapbuffers command. I want to take that further and after the OpenGL frame is rendered, draw a line of text to the top of the frame and then swapbuffers.

Can I do it?
How?

Thanks in advance for any advice,
cam

Check the MSDN for the DrawText or TextOut win32 function calls…

I’m thinking that’s all you’d need to do.

You’d have to experiment, but in your main rendering loop, render everything to your GL context first, then do the DrawText call…

hth,

Originally posted by camoguard:
[b]I understand OpenGL doublebuffering ending with the GDI swapbuffers command. I want to take that further and after the OpenGL frame is rendered, draw a line of text to the top of the frame and then swapbuffers.

Can I do it?
How?

Thanks in advance for any advice,
cam[/b]
No, it’s impossible. GDI does not know anything about OpenGL backbuffers.
SwapBuffers is not a GDI function, it’s a Win32 API function and just a shortcut for wglSwapLayerBuffers.

Why can’t you render the text with OpenGL instead?
There is wglUseFontBitmaps which build a font for you and text rendering code with that looks like this:

glColor3f(r, g, b); // Text color (assert lighting off). Issue before glRasterPos!
glRasterPos2i(x,y) // Baseline startpoint of first character. RasterPos is transformed by the current modelview matrix!
glListBase(baseOfFirstCharacter);
GLubyte sz[] = "Your text goes here!";
glCallLists(strlen(sz), GL_UNSIGNED_BYTE, sz);

should print the stuff into the backbuffer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.