Can textureBufferObjects be flattened?

I have organized the vbo data to be loaded into a textureBufferObject according to an internal indexing system… [0] is number of lights, [1] is index into first light data, [2] is index into next light data if there is a next light; index into the first light data points to position.x, index into the first light data + 1 points to position.y etc. The tbo is working fine thanks to Dark Photon samplerBuffer example needed - OpenGL - Khronos Forums. But I find the tbo requires to be indexes as an array of vec4 (floats in my case) rather than a flat single array as the tbo specs suggest. That is, to access tbo[4] I have to use

float f=texelFetch(tbo, 1)[0];

. I do not see any setting in the initialization that might flatten the tbo:

int size=dat.length * GL_FLOAT.sizeof;
glGenBuffers(1, &tbo); assert(tbo>0);
glBindBuffer(GL_TEXTURE_BUFFER, tbo);
glBufferData(GL_TEXTURE_BUFFER, size, null, GL_STATIC_DRAW);
glBufferSubData(GL_TEXTURE_BUFFER, 0, size, dat.ptr);
		
glGenTextures(1, &lMap); assert(lMap > 0);
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_BUFFER, lMap);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo);	

//D

Does anyone have any thoughts on how best to proceed in the situation?:doh:

ahem

glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo);

This format tells it that every texel is 4 floating-point values. If you want every texel to be 1 floating point value, then you need to use GL_R32F for the internal format.

As a side note, GL3-generation hardware supports 1,2 and 4 component TBOs (i.e. R, RG, RGBA) but as a rule of thumb, GL4 hardware is needed for 3-component TBO’s (i.e. RGB).

Note that no matter what format you use, you’ll still get back a gvec4 from the texelFetch function, even if you use GL_R32F, but you should not care about the other components besides the first, they’re just there for transparency, i.e. the shader doesn’t have to actually know what format you wanted the hardware to interpret your buffer.

As a side note, GL3-generation hardware supports 1,2 and 4 component TBOs (i.e. R, RG, RGBA) but as a rule of thumb, GL4 hardware is needed for 3-component TBO’s (i.e. RGB).

Only half of GL 3.x hardware doesn’t support 3-component buffer textures. The NVIDIA half. This is easily testable via the ARB_texture_buffer_object_rgb32 extension.

Only half of GL 3.x hardware doesn’t support 3-component buffer textures. The NVIDIA half. This is easily testable via the ARB_texture_buffer_object_rgb32 extension.

Thanks for the heads up, I did not know that AMD’s GL3 generation hardware supported ARB_texture_buffer_object_rgb32 [the test boxes I have are heavily NVIDIA biased, and the AMD box I have is GL4 generation].

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.