15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OpenGL printing...

David Little -- dlittle@communique.net
Friday, August 30, 1996

Environment:  Win95, OpenGL, VC4.1, PowerStation4.0

I am drawing a plot using OpenGL in a CSplitterWnd.  In one of the
windows, I have some text info that relates to the plot, then a window
with some controls, and a window with the plot itself.  Everything works
perfectly, except I can't get the plot to print.  I have an example that
plots to a bitmap, then BitBlt's it to a printer DC, but can't seem to
get this to work.  I found an example (GLPRT) at FTP.MICROSOFT.COM, but
it only works with NT4.0, and that isn't my target system.

Help!

David




Roger Onslow -- Roger_Onslow@compsys.com.au
Monday, September 02, 1996

David,

>I am drawing a plot using OpenGL in a CSplitterWnd.  In one of the
>windows, I have some text info that relates to the plot, then a window
>with some controls, and a window with the plot itself.  Everything works
>perfectly, except I can't get the plot to print.  I have an example that
>plots to a bitmap, then BitBlt's it to a printer DC, but can't seem to
>get this to work.  I found an example (GLPRT) at FTP.MICROSOFT.COM, but
>it only works with NT4.0, and that isn't my target system.
>
>Help!

We are doing exactly the same thing. Yes, you have to setup your OpenGL 
rendering context to output to a bitmap (which you would probably create in 
your OnSize function and keep around until the size changes again).  The in 
your OnDraw, BitBlt from the bitmap to the screen.  Best to use a separate 
function to actually render the 3D image to the bitmap, otherwise it will 
regenerate on every call to OnDraw (not nice if all you are doing is moving a 
dialog over it, say).  Then for printing, you do the same things as OnDraw -- 
just bitblt to printer DC rather than screen DC -- shouldn't need to shange any 
code to do this.  In my implementation, I create a 24bit DIB for rendering into 
so I always get maximum colour usage and then let the blt to screen and printer 
do the mapping to the appropriate palette (halftone is useful here, perhaps).

Hope this helps you.

I may be able to send some code if you really get stuck

Roger Onslow




| Вернуться в корень Архива |