Render scene to printer

Hello,

I am trying to work out a plan to render an OpenGL scene to the printer. I would like to open up the common Windows print dialog and then off-screen render to the printer. It would be helpful to get some ideas about how to do this.

Thanks,
John

You can find about 5 or so examples of OpenGL and Print Preview on codeguru and codeproject alone:

http://www.google.com/search?hl=en&lr=&q=opengl+print+preview+&btnG=Search

The one thing you’ll probably notice is that all those tutorials use PFD_DRAW_TO_BITMAP
for offscreen rendering. Well, that’s ok if your rendering is limited to wireframe,
material colors or vertex colors, but if you’re rendering a textured model (which no tutorial
will show you btw), this turns into a pain in the arse because you can’t share textures,
so you’ll have to either reload all of your textures twice, or look into hardware-accelerated
pbuffers for offscreen rendering for sharing textures, but what if someone graphics card
doesn’t support pbuffers, well then you’ll have to support software offscreen rendering one
way or the other.

My program is not using textures. But the bitmap would end up being too large anyway. I want the program to render directly to the printer. I do not use MFC.

You want to render directly to the printer or render to offscreen memory, because you are
talking about two different things now? First off, I don’t think you can render directly to
the printer using OpenGL, because you don’t own the printer DC. So you have to render to
an offscreen memory DC using OpenGL, then copy that to the printer DC. And whether those
examples are MFC or not, the principal is the same. You can just extract the code you need.

I got my program to print using metafiles, but there is no depth buffering. Do I need to use a sorting algorithm to print what I see on the screen?

You can go with a vector-based output approach, but I suppose there are disadvantages as well
as you pointed out. Whatever metafile file format you’re using, it probably needs some instructions
to know how to draw your model. There is a code project tutorial mentioning something about
“fast z-sorting algorithm using AVL trees”. I print everything to bitmaps, so I don’t have that
problem.

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