Return value of glSelectBuffer in opengl
static GLuint selectBuff[BUFFER_LENGTH];
glSelectBuffer(BUFFER_LENGTH, selectBuff);
..
//Draw something..
..
// Collect the hits
hits = glRenderMode(GL_RENDER);
..
..
if(hits > 0){ //something's been selected
fprintf(stderr,"something has been selected");
unsigned int choiche;
// fi there's more than one figure (or c开发者_StackOverflowontrol point) selected, take the top one
if (hits > 1)
choiche = selectBuff[(hits*4)-1];
else
choiche = selectBuff[3];
cpsel = false;
I basically want to know the structure of selectBuff. What does the author meaning by coding selectBuff[3]
and selectBuff[(hits*4)-1]
?
Official doc says, buffer returns values from the name stack. But, that doesn't actually tell me what author meant by doing selectBuff[3]
.
For complete code (it's a paint program) see here.
From http://www.opengl.org/sdk/docs/man/xhtml/glSelectBuffer.xml
"The hit record consists of 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."
Therefore, it should be the name stack contents.
精彩评论