c++ - opengl中glSelectBuffer的返回值

标签 c++ c 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 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/

相关文章:

c++ - 编译器无法将指向字符串文字的指针解释为方法的参数

C - 如何正确释放指向 n 字符数组 ((*p)[n]) 的指针的内存?

c - 处理 strcpy 的返回类型的正确方法是什么

java - 当前线程中没有 OpenGL 上下文

python - 让 VisPy 的 MPL_plot 发挥作用

java - 为什么我的光照计算会导致颜色跳到黑色?

c++ - 使用增强几何适应几何对象模型的问题

c++ - 对自制类对象进行不区分大小写的排序

java - C++ 和 Java 中的静态变量

c - 从C中的文本文件中读取unicode字符