Problem with Opengl version

I’m working in a CAD program trying to give better specular shininess to textured objects. I use a opengl 1.2 define, GL_SEPARATE_SPECULAR_COLOR. I test the opengl version (using glGetString(GL_VERSION)) before using the define and I get “1.2” . When the scene is rendered in a window everything is ok.
When printing, the application uses an option to render to a DC with a DIBitmap, and it makes a change of context. The flags of the pixelformatdescriptor for that context are:

PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL

Just after the wglCreateContext, I ask for the opengl version and i get “1.1” ! Is there any reason to make it happen? Maybe PFD_SUPPORT_GDI is not compatible with my driver’s opengl version? Any idea?

Check the GL_VENDOR and GL_RENDERER, too, and you’ll see that you get Microsoft’s GDI Generic OpenGL Implementation.
Drawing to device bitmaps in system memory is not supported by hardware implementations.

You’re right, Relic
Do you know any alternative solution for rendering to a bitmap using the hardware OpenGl?
thanks

How big do you need the bitmap to be? If it’s not excessively large, rendering to a pbuffer and doing a glReadPixels() is the best solution. If it does have to be excessively large, subdivide the image into multiple tiles, render each tile separately, use glReadPixels() to get the results, and then stitch the tiles together into a single large image for saving.

– Tom

I has this problem long time ago and I lose many time to solve it but withowt success. I do not found any way to do hardware accelerated rendering context in the memory. And also I do not succeed to drawn something on invisible window. Finally i was forced to create preview window and to get the image from it.

Given that you are printing just use glReadPixels() to get the frame buffer, create your own DIB and print it.

The problem is the printed image can be very large, something like 6000x4500. I’m afraid it will not fit in any frame buffer or pbuffer. There’s not an easier solution than tiled rendering?

You can glReadPixels directly from your window back buffer, but you should be aware that if the window is (wholly or partly) occluded by another window, the occluded area is undefined (usually it does NOT contain any useful OpenGL graphics). This is also true if the window is iconified, for instance.

The better solution is to use pbuffers (see the WGL_ARB_pbuffer, WGL_EXT_pbuffer and/or GLX_SGIX_pbuffer extensions), again in combination with glReadPixels.

Tiled rendering is ridiculously easy, especially if you’re already using glFrustum(). See http://www.delphi3d.net/download/hiresshot.zip for an example.

Just add in the code to use a pbuffer instead of a window, and you’re all set.

– Tom

Originally posted by Tom Nuydens:
[b]Tiled rendering is ridiculously easy, especially if you’re already using glFrustum(). See http://www.delphi3d.net/download/hiresshot.zip for an example.

Just add in the code to use a pbuffer instead of a window, and you’re all set.

– Tom[/b]

Hi
It was not so easy for me, but I’ve finished the tiled render for my application and it works pretty well
Thanks a lot, Tom