DOCERR: Printing an OpenGL Image

Last reviewed: September 29, 1995
Article ID: Q132866
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

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 reference words: 3.50 4.00 Windows 95
KBCategory: kbgraphic kbdocerr
KBSubcategory: GdiOpenGL


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.