GLSELECTBUFFER(3G)
β¨ glSelectBuffer β bestie, let's set up a whole buffer for selection mode values β¨
okay so this is a 3G manual page, aka OpenGL-adjacent chaos, and it's literally called glSelectBuffer π. She sets up the spot where selection-mode values get dumped. That's it, that's the job, and she eats.
π C SPECIFICATION π
void glSelectBuffer( GLsizei size,
GLuint *buffer )
no cap, that's the whole signature. two args, both doing the most.
π PARAMETERS π
sizeβ the size ofbuffer, bestie. how much room we're giving her.bufferβ this one returns the selection data. she's not just sitting there, she's giving back. π«Ά
π DESCRIPTION π
okay so glSelectBuffer has two arguments: buffer is a pointer to an array of unsigned integers, and size indicates the size of that array. And buffer is the one that returns values from the name stack (peep glInitNames, glLoadName, glPushName) when the rendering mode is GL_SELECT (peep glRenderMode). π
THE RULES, and I mean the rules: glSelectBuffer must be issued before selection mode is enabled, and it must not be issued while the rendering mode is GL_SELECT. do not play with this. fr fr. π
A programmer can use selection to figure out which primitives are drawn into some region of a window. That region is defined by the current modelview and perspective matrices. main character region energy. β¨
In selection mode, no pixel fragments are produced from rasterization. not a single one. Instead, if a primitive or a raster position intersects the clipping volume defined by the viewing frustum and the user-defined clipping planes, this primitive causes a selection hit. (And with polygons? No hit occurs if the polygon is culled. π )
When a change is made to the name stack, or when glRenderMode is called, a hit record is copied to buffer if any hits have occurred since the last such event (name stack change or glRenderMode call). And the hit record is, in order:
- the number of names in the name stack at the time of the event,
- followed by the minimum and maximum depth values of all vertices that hit since the previous event,
- followed by the name stack contents, bottom name first.
Depth values (which are in the range [0,1]) are multiplied by 2^32 - 1 before being placed in the hit record. yes, that number. big number. iconic. π₯
An internal index into buffer is reset to 0 whenever selection mode is entered. Each time a hit record is copied into buffer, the index is incremented to point to the cell just past the end of the block of names β that is, to the next available cell. π
If the hit record is larger than the number of remaining locations in buffer, as much data as can fit is copied, and the overflow flag is set. overflow. not cute. be careful. π
If the name stack is empty when a hit record is copied, that record consists of 0 followed by the minimum and maximum depth values.
To exit selection mode, call glRenderMode with an argument other than GL_SELECT. Whenever glRenderMode is called while the render mode is GL_SELECT, it:
- returns the number of hit records copied to
buffer, - resets the overflow flag and the selection buffer pointer,
- and initializes the name stack to be empty.
and if the overflow bit was set when glRenderMode was called, a negative hit record count is returned. negative. as in, bad vibes. as in, the count is telling you it overflowed. π
πΈ NOTES πΈ
- The contents of
bufferare undefined untilglRenderModeis called with an argument other thanGL_SELECT. undefined means undefined, bestie, don't read it and act surprised. π glBegin/glEndprimitives and calls toglRasterPoscan result in hits. sneaky little hits. β¨
π ERRORS π
GL_INVALID_VALUEis generated ifsizeis negative. negative size? jail.GL_INVALID_OPERATIONis generated ifglSelectBufferis called while the render mode isGL_SELECT, or ifglRenderModeis called with argumentGL_SELECTbeforeglSelectBufferis called at least once. order matters, periodt.GL_INVALID_OPERATIONis generated ifglSelectBufferis executed between the execution ofglBeginand the corresponding execution ofglEnd. no glSelectBuffer mid-primitive. absolutely not.
π¦ ASSOCIATED GETS π¦
you can go get these, she's not hiding:
glGetwith argumentGL_NAME_STACK_DEPTHglGetwith argumentGL_SELECTION_BUFFER_SIZEglGetPointervwith argumentGL_SELECTION_BUFFER_POINTER
π SEE ALSO π
glFeedbackBuffer(3G)glInitNames(3G)glLoadName(3G)glPushName(3G)glRenderMode(3G)
go read those too, they're all in the same friend group. π«Ά
and that's the whole page, bestie!! π this was the GLSELECTBUFFER(3G) page from the 3G manual section β so if you ever need to cite her, it's glSelectBuffer, section 3G, page name GLSELECTBUFFER(3G). no date on this one, just the name, so that's what we're rolling with. now go call glRenderMode and exit selection mode like a responsible icon. mwah. π
β¨π
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- fedora 43: gl-manpages 1.1-34.20190306.fc43 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- fedora 44: gl-manpages 1.1-35.20190306.fc44 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms