Board index » delphi » Rendering OpenGL to a bitmap

Rendering OpenGL to a bitmap

I'm working on converting an SVG file to an OpenGL rendering, which is
working fine on screen so far. However I also need to be able to print it
and OpenGL won't directly render to the printer.

As a precursor to printing therefore, I am rendering it to a bitmap first,
then printing the bitmap. It's also relevant that when I load the file I
first use GL_COMPILE to create a list of GL commands, which I subsequently
replay in rendering (I have to do this twice, once for PFD_DRAW_TO_WINDOW
and once for PFD_DRAW_TO_BITMAP).

The initial compile is done unscaled, with the picture clipped to whatever
size the SVG file says it is.

Rendering to the screen works fine, either original size or rescaled
according to use preference.

Rendering to the bitmap, suitably scaled by printer resolution/screen
resolution, and then the printer also works fine EXCEPT WHEN I AM DOING IT

The first time I do it, and only the first time, the image is always 1"
(i.e. in this case 600 pixels) square.though the bitmap is the right size
and it is correctly positioned on the page. This is irrespective of the size
of the bitmap or of the image. I have checked that it is the bitmap that is
wrong, not the drawing to the printer, which is just done by

The code that is executed the first time is exactly the same as the code
executed each subsequent time.

Does anyone have any idea why this might be happening?


Re:Rendering OpenGL to a bitmap

Expanding on this - my testbed program also allows the user to scale the
picture up or down arbitrarily. Again this works fine on screen: I decided
to try using in in the render-to-bitmap routine. The situation now is:

Whatever the magnification the first rendering is 1" square.
Subsequently it is correct.
Change the magnification
The first time it renders using the old magnification
Every subsequent time it gets it right.

Again the new bitmap is the right size but the image is scaled wrong.

I do check that the correct scaling transformation is in place for each
rendering: i.e. the transformation matrix for the ones that go wrong is the
same as the matrix when they go correctly.

Other Threads