Microsoft KB Archive/132866

{|
 * width="100%"|

DOCERR: Printing an OpenGL Image

 * }

Q132866

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * Microsoft Windows NT Server versions 3.5, 3.51
 * Microsoft Windows NT Workstation versions 3.5, 3.51
 * Microsoft Windows 95

-

SUMMARY
The documentation relating to printing an OpenGL image in the Win32 SDK versions 3.5, 3.51, and 4.0 is incorrect. The current version of Microsoft's implementation of OpenGL in Windows NT does not provide support for printing. More specifically, an application cannot call wglCreateContext or wglMakeCurrent on a printer device context.

To work around this limitation, draw the OpenGL image into a memory bitmap, and then print the bitmap.

MORE INFORMATION
Here are the correct steps to print an OpenGL image:


 * 1) Create a printer device context.
 * 2) Create a memory device context.
 * 3) Create a bitmap that can be either a DIB section or a screen compatible bitmap, and select it into the memory device context. This bitmap must have four or more bits of color information per pixel.
 * 4) Set the pixel format of the memory device context.
 * 5) Create a rendering context, passing the wglCreateContext function the handle to the memory device context, and make that rendering context a thread's current rendering context.
 * 6) Make OpenGL calls, which will draw into that rendering context.
 * 7) Disconnect and delete the rendering context.
 * 8) Use StretchDIBits, SetDIBitsToDevice, StretchBlt, or BitBlt from the memory device context to the printer device context.
 * 9) Delete the bitmap, the memory device context, and the printer device context.

Additional query words: 3.50 4.00 Windows

Keywords : kbgraphic kbprint kbdocerr kbOSWinNT350 kbOSWinNT351 kbOSWin95

Issue type :

Technology : kbAudDeveloper kbWin32sSearch kbWin32API