Jump to content
  • Advertisement
Sign in to follow this  
spek

OpenGL How to upload a 16 bit FP texture?

This topic is 4489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I want to upload data to a floating point texture. I guess I use:
            glTexImage2D( GL_TEXTURE_2D,                    // Target
                          0,                                // MIP MAP level
                          GL_RGB16F_ARB,                    // internal format
                          width , height,                   // width, height
                          0,                                // border
                          GL_RGB16F_ARB,                    // format
                          GL_FLOAT,                         // atype
                          pData );                          // data
But I'm not sure if all the parameters are correct... It also depends on the buffer I give of course. Now my buffer looks like this:
  Vector3f = array[0..2] of GL_FLOAT;

  pixels   = array[0..width-1] of array[0..height-1] of Vector3f;
  
So, I have a 2D array with vectors. vector[0] = red, vector[1] = green, vector[2] = blue. But I'm not sure if the order of the colors and/or the pixels is right. And are the parameters correct? By the way, I apply this texture on geometry that is rendered onto a 16 bit FP buffer (FBO). I'm using default OpenGL, no shaders in the first case. Are the colors in the 0..1 range, or can they get higher without doing something special, since the texture and buffer are floating point"? Greetings, Rick

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by spek
By the way, I apply this texture on geometry that is rendered onto a 16 bit FP buffer (FBO). I'm using default OpenGL, no shaders in the first case. Are the colors in the 0..1 range, or can they get higher without doing something special, since the texture and buffer are floating point"?


Of course, the colors can be out of the [0, 1] range in your fp texture and FBO. The problem is that they'll be clamped to that range once they reach the framebuffer (or a non floating point render target).

[Edited by - mhamlin on July 29, 2006 11:57:45 AM]

Share this post


Link to post
Share on other sites
Ok. That won't be a problem, its not renderd to the screen itself. I only need the FP texture that rolls out to measure things.

But how about the order of the pixel data, and the parameters I should pass?

Greetings,
Rick

Share this post


Link to post
Share on other sites
It should be:

glTexImage2D( GL_TEXTURE_2D, // Target
0, // MIP MAP level
GL_RGB16F_ARB, // internal format
width , height, // width, height
0, // border
GL_RGB, // format
GL_FLOAT, // atype
pData ); // data

('format' and 'type' specifiers for the source data are separate).

HTH

Share this post


Link to post
Share on other sites
Ok, thanks!

Now last but not least, what is the order of the data I give? It's an array with pixels, but I don't know the order I must use. For example, is it "left to right, top-down":

0 1 2 3
4 5 6 7
8 9 10 11

Where the numbers are the index in the array?

Greetings,
Rick

Share this post


Link to post
Share on other sites
Use 1D array with pixels going linearly as RGB - RGB - RGB etc.. you cant use 2D array that isn't single linear block, unless you alloc it on the stack.

So if you have a Vector3f that has nothing more than float[3] then array of Vector3f[width*height] is linear block of floats as float[3*width*height] if you typecast it to (float*), i.e float pointer.
And that works.

ch.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!