OpenGL控制问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 04:02:24
我在学opengl,调用opengl在视口画了几个球,我想单独控制其中一个球(非视图),如鼠标在视口上点击它后, 可以拖曳。 或提供一个界面,让某个球转动起来。当然, 得先有一个方式, 让程序知道用户控制哪个模型。这个怎么实现的?有没有模型的唯一标识符或其它方式?
我菜鸟,懂的人不要笑话啊~,
能讲些关键实现函数的话, 感激不尽!

OpenGL的选择机制应该能解决你这个问题
红宝书上有的
你自己看下好了
void glInitNames(void);
Clears the name stack so that it's empty.
void glPushName(GLuint name);
Pushes name onto the name stack. Pushing a name beyond the capacity of the stack generates the error GL_STACK_OVERFLOW. The name stack's depth can vary among different OpenGL implementations, but it must be able to contain at least sixty-four names. You can use the parameter GL_NAME_STACK_DEPTH with glGetIntegerv() to obtain the depth of the name stack.
void glPopName(void);
Pops one name off the top of the name stack. Popping an empty stack generates the error GL_STACK_UNDERFLOW.
void glLoadName(GLuint name);
Replaces the value on the top of the name stack with name. If the stack is empty, which it is right after glInitNames() is called, glLoadName() generates the error GL_INVALID_OPERATION. To avoid this, if the stack is initially empty, call glPushName() at least once to put something