Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Location
    Ontario, Canada
    Posts
    1,750

    Question How to print OpenGL window?

    Can someone recommend to me an easy way that I can send my OpenGL viewport to the printer so that everything can be printed? I would like to create a "print" button in my 3D level editor so that people can get hard copies of their screen shots.

    I'm working in Windows.

    thanks,
    C++, 3D OpenGL and Game Programming video tutorials:
    www.MarekKnows.com
    Play my free games: Ghost Toast, Zing, Jewel Thief

  2. #2
    Join Date
    Jun 2005
    Location
    NY
    Posts
    1,374
    Have you tried creating an image out of the screen, probably jpeg or bitmap would be easiest, then sending that created image to the printer? I'm not sure how to take get the image in OpenGL. On Windows you can use PrintDlgEx to bring up the printer selection and I think it gets the printer device context then just use BitBlt to copy the image data from the image to the printer device context.

    Or you could use EnumPrinters and then when one is found use CreateDC with the second parameter being the name contained in the PRINTER_INFO_ structure. Note that PRINTER_INFO_4 is not supported in Windows 95/98/ME so if you plan to support those you'll need to use PRINTER_INFO_5 then once you have the DC you can use BitBlt.
    CodeGuru: DLL Tutorial For Beginners by me. Rated 4 1/2 out of 5.

  3. #3
    Join Date
    Aug 2007
    Location
    Montreal, Canada
    Posts
    618
    Maybe you can use HLSL to get an image file of the screen.

    Here is a link where they do that in XNA, maybe you can adjust it for OpenGL?

    http://www.dhpoware.com/demos/xnaRenderToTexture.html

  4. #4
    Join Date
    Mar 2005
    Location
    Ontario, Canada
    Posts
    1,750
    Just to clear things up, I know how to get all the pixel data that I'm rendering to my viewport. The part that I'm not sure how to do, is to send all the pixel data to the printer.

    I'll have a look around to see if I can find some sample code that uses PrintDlgEx. This sounds like the best option so far.
    C++, 3D OpenGL and Game Programming video tutorials:
    www.MarekKnows.com
    Play my free games: Ghost Toast, Zing, Jewel Thief

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •