PDA

View Full Version : Can i draw to metafile from OpenGL?



Sanya
03-16-2001, 04:03 AM
Is there any method draw to metafile from OpenGL?

dslater
03-27-2001, 08:44 AM
Originally posted by Sanya:
Is there any method draw to metafile from OpenGL?

The only way to draw to a Windows metafile is to draw to a bitmap and then bitblt the bitmap into the metafile. Under Windows NT/2000, you can draw to an Enhanced Metafile by using the Enhanced Metafile CD to create your rendering context. However, this Enhanced Metafile will only work under Windows NT/2000. Microsoft has some sample code demonstrating how to do this in the MSDN

Sanya
03-27-2001, 08:59 PM
Thanx dslater, i create enhanced metafile on Windows2000, but how a can see it on my screen and what more important can draw it on plotter? Most viewers can't draw OpenGL enhanced metafiles. Did you know any?

dslater
04-18-2001, 05:19 AM
In your own code you should be able to call PlayEnhMetaFile() to play your enhanced metafile to a DC. If your plotter is just another printer on your system, then this should work for your plotter. To be honest, I don't know much about plotters, so there may be some limitations I don't know about http://www.opengl.org/discussion_boards/ubb/smile.gif.
As for viewers, I know that MS Word 2000 can display Enhanced Metafiles.

As a last resort, if your plotter can display bitmaps, you can always render your OpenGL scene to a bitmap and then BitBlt the bitmap to the print device. To use the full resolution of your printer, you will need to create a very large bitmap. i.e. for a 600 dpi printer with 8.5x11 inch paper, you need a 5100x6600 pixel bitmap. Unfortunately, you will run into memory problems with a bitmap this large. What you need to do ( and what I did in my app) is to render your scene in bands. - Note, this is a non-trivial exercise. you need to manipulate both your viewport and viewing frustum. You should also compile your entire scene into a display list as you be re-rendering it many times. - this method has the advantage that it will work under Win95/98 as well.

If you can't send bitmaps to your plotter, than I'm not sure what else you can do. I once saw code on this site that used the OpenGL feedback mechanism to read the transformed geometry and then generate postscript for scalable postscript output. That may be a starting point for you - this file to look for is gl2eps.c or gl2eps.cpp

[This message has been edited by dslater (edited 04-18-2001).]

JohnHutch
04-18-2001, 07:22 PM
I have come up against the same issue. I have followed the advice so far and have an enhanced metafile (which has been constructed with reference to the Screen DC). I get a valid RC and can make make it current. However, I get nothing being rendered into the Metafile. A test with Basic GDI is appearing but no simple OpenGL commands. Any tips? http://www.opengl.org/discussion_boards/ubb/confused.gif

dslater
05-09-2001, 07:11 AM
Not sure as I've never actually tried rendering to an Enhanced Metafile. The first place I would start is in Choosing my pixel format - try a single buffer format compatible with GDI instead of double buffered.