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 control point) selected, take the top one
if (hits > 1)
choiche = selectBuff[(hits*4)-1];
else
choiche = selectBuff[3];
cpsel = false;
基本上想知道selectBuff的结构。作者编写 selectBuff[3]
和 selectBuff[(hits*4)-1]
是什么意思?
官方文档说,缓冲区从名称堆栈返回值。但是,这实际上并没有告诉我作者执行 selectBuff[3]
的意思。
完整代码(这是一个绘画程序)see here .
最佳答案
来自 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."
因此,它应该是堆栈内容的名称。
关于c++ - opengl中glSelectBuffer的返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5705791/