View Full Version : Render to element buffers possible?

10-14-2006, 11:39 AM
So, what I'm trying to do here is just like render to vertex buffers (using an FBO, GL_PIXEL_PACK_BUFFER_EXT and glReadPixels), just that I want to update my element array - the indices to the vertices for each face - instead of the vertex coordinates themselves.

Two problems, though:
- First, when I read from the FBO texture and/or buffer, that should have the updated indices, there's a small error. Sometimes an index will be one above or below the supposed index. This is due to precision problems when OpenGL does its multiplication thing when storing integers into a float. Is there a way to either disable the multiplication, or have it store integer values past 255 (and have these values available on a shader)?

- Second, the readPixels is exceedingly slow. I suppose it's because of the conversion from GL_FLOAT_R32_NV to unsigned integers, but element arrays can't be anything other than signed or unsigned bytes or integers, apparently. Any way around this?

Thanks a lot already!

10-14-2006, 11:59 PM
Well, I guess, you answered your question yourself... Current generations only work with floats and there are no integer-storage textures. I doubt you can do it with current hardware, due to precision issues.

10-15-2006, 09:11 AM
Well, I can write and read back an "integer" value from a float point texture just fine, if I pass it as a float. The problem is on the conversion, since the element draw call function requires an integer value type. What I want to do is simple: when passing floats, OpenGL doesn't do anything with the value, it's stored as-is. I want to know if it's possible to disable the multiplication it does with integer values when storing and reading back, just like it is with float values.

I don't think it's possible, but I thought it was worth a shot trying to ask it around here anyway.


10-15-2006, 11:51 PM
As I understand, you want to made something similar to a "render to vertex array", but with the indices.

Instead a FBO why don't you try a PBO? The combination PBO/VBO "simulates" the render to vertex array in some way.

Take a look to http://developer.nvidia.com/object/using_VBOs.html, where this thechnique is explained (at the specification of the PBO there are code samples too), as this can be useful to you.