Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    655

    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.

    Alberto

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    655

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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,

    Alberto

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    655

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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?

    Thanks,

    Alberto

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,108

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Apr 2000
    Location
    Redlands, CA, USA
    Posts
    233

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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.

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    655

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    Thanks a lot k_szczech & Serge K.

    Now everything is clear!

  8. #8
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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.

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Dec 2005
    Location
    Italy
    Posts
    655

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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

  10. #10
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: GL_SEPARATE_SPECULAR_COLOR not working on Bitmap context.

    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
    http://msdn2.microsoft.com/en-us/default.aspx

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •