View Full Version : GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.
09-12-2006, 11:12 PM
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.
09-13-2006, 12:25 AM
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.
09-13-2006, 12:38 AM
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?!?
09-13-2006, 02:29 AM
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?
09-13-2006, 04:07 AM
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.
09-13-2006, 11:18 AM
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.
09-13-2006, 01:44 PM
Thanks a lot k_szczech & Serge K.
Now everything is clear!
09-14-2006, 07:37 AM
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.
09-14-2006, 07:55 AM
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
09-14-2006, 09:52 AM
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: http://developer.nvidia.com/page/home
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.
09-14-2006, 02:33 PM
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:
Isn't it the code I need?
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.