GLTEXBUFFERRANGE(3G)
π
glTexBufferRange / glTextureBufferRange β the 3G manual page, bestie
Okay so welcome to the GLTEXBUFFERRANGE(3G) page, and no cap this one is about two functions that attach a range of a buffer object's data store to a buffer texture object. It's giving "buffer texture glow-up" energy. β¨
β¨ NAME β¨
glTexBufferRange, glTextureBufferRange β attach a range of a buffer object's data store to a buffer texture object. That's the whole name-section vibe, periodt. π«Ά
πΈ C SPECIFICATION πΈ
void glTexBufferRange(GLenum target, GLenum internalformat,
GLuint buffer, GLintptr offset, GLsizeiptr size);
void glTextureBufferRange(GLuint texture, GLenum internalformat,
GLuint buffer, GLintptr offset, GLsizei size);
Look at those signatures. The way they're just sitting there being all C-like and iconic. π
π PARAMETERS π
targetβ Specifies the target to which the texture object is bound forglTexBufferRange. Must beGL_TEXTURE_BUFFER. No substitutions, bestie.textureβ Specifies the texture object name forglTextureBufferRange.internalformatβ Specifies the internal format of the data in the store belonging tobuffer.bufferβ Specifies the name of the buffer object whose storage to attach to the active buffer texture.offsetβ Specifies the offset of the start of the range of the buffer's data store to attach.sizeβ Specifies the size of the range of the buffer's data store to attach.
π¦ DESCRIPTION π¦
So glTexBufferRange and glTextureBufferRange attach a range of the data store of a specified buffer object to a specified texture object, and they specify the storage format for the texture image found in the buffer object. The texture object must be a buffer texture. Like, that's not optional. π
If buffer is zero, any buffer object attached to the buffer texture is detached and no new buffer object is attached. If buffer is non-zero, it must be the name of an existing buffer object. That's the rule, fr fr. π₯
The start and size of the range are specified by offset and size respectively, both measured in basic machine units. offset must be greater than or equal to zero, size must be greater than zero, and the sum of offset and size must not exceed the value of GL_BUFFER_SIZE for buffer. Furthermore, offset must be an integer multiple of the value of GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT. So basically: check your alignment, bestie. π
Okay so internalformat is likeβ¦ the personality of your texture, and it must be one of these sized internal formats β no vibes-based guessing, bestie. Here's the whole menu: sized internal format, base type, how many components, whether it's normalized, and then exactly what lands in components 0, 1, 2 and 3. π
GL_R8β base typeubyte,1component, Norm: YES, components0..3βR,0,0,1GL_R16β base typeushort,1component, Norm: YES, components0..3βR,0,0,1GL_R16Fβ base typehalf,1component, Norm: NO, components0..3βR,0,0,1GL_R32Fβ base typefloat,1component, Norm: NO, components0..3βR,0,0,1GL_R8Iβ base typebyte,1component, Norm: NO, components0..3βR,0,0,1GL_R16Iβ base typeshort,1component, Norm: NO, components0..3βR,0,0,1GL_R32Iβ base typeint,1component, Norm: NO, components0..3βR,0,0,1GL_R8UIβ base typeubyte,1component, Norm: NO, components0..3βR,0,0,1GL_R16UIβ base typeushort,1component, Norm: NO, components0..3βR,0,0,1GL_R32UIβ base typeuint,1component, Norm: NO, components0..3βR,0,0,1GL_RG8β base typeubyte,2components, Norm: YES, components0..3βR,G,0,1GL_RG16β base typeushort,2components, Norm: YES, components0..3βR,G,0,1GL_RG16Fβ base typehalf,2components, Norm: NO, components0..3βR,G,0,1GL_RG32Fβ base typefloat,2components, Norm: NO, components0..3βR,G,0,1GL_RG8Iβ base typebyte,2components, Norm: NO, components0..3βR,G,0,1GL_RG16Iβ base typeshort,2components, Norm: NO, components0..3βR,G,0,1GL_RG32Iβ base typeint,2components, Norm: NO, components0..3βR,G,0,1GL_RG8UIβ base typeubyte,2components, Norm: NO, components0..3βR,G,0,1GL_RG16UIβ base typeushort,2components, Norm: NO, components0..3βR,G,0,1GL_RG32UIβ base typeuint,2components, Norm: NO, components0..3βR,G,0,1GL_RGB32Fβ base typefloat,3components, Norm: NO, components0..3βR,G,B,1GL_RGB32Iβ base typeint,3components, Norm: NO, components0..3βR,G,B,1GL_RGB32UIβ base typeuint,3components, Norm: NO, components0..3βR,G,B,1GL_RGBA8β base typeuint,4components, Norm: YES, components0..3βR,G,B,AGL_RGBA16β base typeshort,4components, Norm: YES, components0..3βR,G,B,AGL_RGBA16Fβ base typehalf,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA32Fβ base typefloat,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA8Iβ base typebyte,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA16Iβ base typeshort,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA32Iβ base typeint,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA8UIβ base typeubyte,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA16UIβ base typeushort,4components, Norm: NO, components0..3βR,G,B,AGL_RGBA32UIβ base typeuint,4components, Norm: NO, components0..3βR,G,B,A
Read that table like a playlist, not a vibe β every format, base type, component count and norm flag above is exactly what it is, no substitutions, okay? π«Ά
π¦ how many texels tho
So when a range of a buffer object gets attached to a buffer texture, the specified range of the buffer object's data store is literally taken as the texture's texel array. That's it, that's the whole relationship. π
And the number of texels in the buffer texture's texel array is given by this lil formula right here:
$$ \left\lfloor { size \over { components \times
sizeof(base\_type) } } \right\rfloor $$
where components and base_type are the element count and base data type for elements, as specified in the table above β¨ (so like, the components column and the base type column, not vibes).
Then β and this is the part people skip and then get confused β the number of texels in the texel array is clamped to the value of the implementation-dependent limit GL_MAX_TEXTURE_BUFFER_SIZE. So your math can say one thing and your driver can say "no bestie, smaller." π
β οΈ And when a buffer texture is accessed in a shader, the results of a texel fetch are undefined if the specified texel coordinate is negative, or greater than or equal to the clamped number of texels in the texel array. So stay in bounds, fr fr β out-of-range reads are giving chaos and not the cute kind. π
π ERRORS (aka the vibe check fails) π
okay so bestie, this is where the driver says "no <3" β here's every way you can break it:
GL_INVALID_ENUMβ gets thrown byglTexBufferRangeif target isn'tGL_TEXTURE_BUFFER. like, wrong door, babe.GL_INVALID_OPERATIONβ gets thrown byglTextureBufferRangeif texture isn't the name of an actually-existing texture object. not a vibe.GL_INVALID_ENUMβ also thrown byglTextureBufferRangeif the effective target of texture isn'tGL_TEXTURE_BUFFER.GL_INVALID_ENUMβ thrown if internalformat isn't one of the sized internal formats described above. no off-brand formats in this house π«GL_INVALID_OPERATIONβ thrown if buffer isn't zero and isn't the name of an existing buffer object.GL_INVALID_VALUEβ thrown if offset is negative, if size is less than or equal to zero, or ifoffset + sizeis greater than the value ofGL_BUFFER_SIZEfor buffer. math girlies stay winning πGL_INVALID_VALUEβ thrown if offset isn't an integer multiple of the value ofGL_TEXTURE_BUFFER_OFFSET_ALIGNMENT. alignment is not a suggestion, it's a lifestyle β¨
π ASSOCIATED GETS (the receipts)
glGet()with argumentGL_TEXTURE_BUFFER_OFFSET_ALIGNMENTglGetTexLevelParameter()with argumentsGL_TEXTURE_BUFFER_OFFSETorGL_TEXTURE_BUFFER_SIZE.
ποΈ VERSION SUPPORT (who gets to sit with us)
the chart lowkey slaps, so here's the whole thing spelled out. the columns were OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, and the dashes mean "nope, not invited" while the β means "she's here, she's iconic":
glTexBufferRangeβ-in2.0,-in2.1,-in3.0,-in3.1,-in3.2,-in3.3,-in4.0,-in4.1,-in4.2, β in4.3, β in4.4, β in4.5glTextureBufferRangeβ-in2.0,-in2.1,-in3.0,-in3.1,-in3.2,-in3.3,-in4.0,-in4.1,-in4.2,-in4.3,-in4.4, β in4.5
so likeβ¦glTexBufferRangesaid "I'm available from4.3onward π " andglTextureBufferRangeshowed up fashionably late at4.5only. main character energy fr fr.
π«Ά SEE ALSO
glTexBuffer().
Β©οΈ COPYRIGHT
Copyright Β© 2012-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.
Copyright Β© 2012-2014 Khronos Group
and that's the whole page bestie, we ate and left no crumbs π the source says [FIXME: source], the version is from 08/09/2021, and the page goes by GLTEXBUFFERRANGE(3G) β take care of her, she's iconic πβ¨
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms