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?
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.
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.
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.
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()
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.
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…