GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

Hi All,

I cannot get specular highlights on bitmap generated from my opengl view. I am rendering the SAME scene on a rendering context generated from a standard windows bitmap DC.

Is there any known bug here around? Am I missing something?

Thanks a lot in advance for your help.


Rendering to a Windows bitmap with a memory DC will use the Microsoft GDI Generic OpenGL implementation. Check your glGetString(GL_VENDOR) and GL_VERSION and you’ll see.
That’s OpenGL 1.1 and separate specular color was added in OpenGL 1.2 (Check the OpenGL 2.0 specs Appendix D).
Hardware implementations normally don’t support render to bitmap, but you could render hardware accelerated to a p-buffer or framebuffer object and copy it to a bitmap instead.

Hi Relic,

Thanks so much. You made center to the first reply.

Do you know where I can find a C/CPP example of the two tecniques you mentioned?

What about switching to OpenGL extensions to render specular highlights an leave the memory DC code as it is?

Will windows Vista add a new OpenGL implementation that supports GL_SEPARATE_SPECULAR_COLOR?!?

Thanks again,


I read here and there about the frame buffer extension. It looks like it is possible only to render on a texture and not on a bitmap.

How can I copy the texture image back to the bitmap object?

Is it possible with the frame buffer extension to render directly to a bitmap?



OpenGL itself does not support windows bitmaps, so you have to copy pixels yourself.
You can use glReadPixels to read pixels from current rendering target or glGetTexImage to get pixels from texture.

Originally posted by devdept:
Will windows Vista add a new OpenGL implementation that supports GL_SEPARATE_SPECULAR_COLOR?!?
Apparently, Vista is supposed to have OpenGL 1.4 by default, so both separate specular & secondary color should be available.

Thanks a lot k_szczech & Serge K.

Now everything is clear!

But that Vista OpenGL 1.4 implementation is a wrapper on top of D3D and that means it probably doesn’t offer render_to_bitmap, which would then still leave the OpenGL 1.1 SW implementation for your memory bitmap as only option.

Thanks Relic,

I am looking over the internet for a PBuffer or framebuffer render to bitmap code but I cannot find any useful example.

Do you know one?

Should I use the glGetTexImage to generate a bitmap from a framebuffer render to texture?

Thanks again, Alberto

There is no example which use pbuffers or FBOI to render to a bitmap because that’s not possible. As said before, you need to render to a color buffer in a pbuffer or FBO (I doubt that MS has implemented either) and glReadPixels into memory, move that data to a Windows bitmap with a GDI BitBlt() or SetDIBits()

If you don’t know how to work with Windows bitmaps, search this site

For a plethora of pbuffer and FBO samples look on this forum and if you have an NVIDIA graphics board look into the NV SDK OpenGL samples. Start reading here:

I wouldn’t recommend glGetTexImage because that might be slow or not working depending on the quality of your graphics vendor’s OpenGL implementation.

Maybe you could explain the reason why you want to render to a bitmap and people could come up with a more elegant solution.

Thank you Relic,

My only intention is to capture OpenGL Control scene in a bitmap, eventually with a bigger resolution. I am sure that it is a fairly common requirement for OpenGL applications.

As I mentioned earlier all the samples on the internet use Windows Memory DCs…

What do you think of this code:;f=3;t=014455

Isn’t it the code I need?

Thanks again,