1

I'm writing my first ray tracer. I want to make it work in real-time. I want to use opengl for display. I want to write my screen to floating point buffer and display the buffer. What extension and/or buffer type I need?

Thanks in advance!

1 Answer 1

3

I'm writing my first ray tracer. I want to make it work in real-time.

Ambitious!

I want to use opengl for display. I want to write my screen to floating point buffer and display the buffer.

OpenGL can read from float buffers directly, e.g.

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_FLOAT, data);

But OpenGL may choose any internal format that matches your selection. GL_RGB internal format can be anything that can somehow store RGB data. You can be specific about what you want. For example GL_RGB16 tells OpenGL you want 16 bits resolution per channel. The implementation may choose to use 24 bits per channel, as this allows for 16 bit to be stored. But ultimately the implementation decides, which internal format it will be, based on the constraints you put upon it.

Floating point framebuffers and textures are supported in OpenGL through extensions GL_ARB_texture_float, GLX_ARB_fbconfig_float, WGL_ARB_fbconfig_float, but due to patent issues not all OpenGL implementations implement it (ATI and NVidia do).

3
  • I got confused by "But OpenGL may choose any internal format". Does it mean that I can't specify pixel format RGB or BGR?
    – user742010
    Sep 5, 2011 at 12:35
  • @user742010: You can tell OpenGL which format the data is you're supplying to it. But OpenGL is free to choose internally whatever it sees bit best. It is possible to tell OpenGL which internal format you'd like to have. See my edit.
    – datenwolf
    Sep 5, 2011 at 15:17
  • There is GL_ARB_color_buffer_float also. It cannot be displayed, but it'a valid alternative in the case float textures are not supported.
    – Luca
    Sep 5, 2011 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.