glRenderMode函数始终返回1

glRenderMode函数始终返回1

本文介绍了glRenderMode函数始终返回1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我在vc ++中使用OpenGL
我已经画了一个矩形,现在我想选择那个矩形,并想在单击时更改矩形的颜色.
为此,我在openGL中使用了拾取功能,但是即使我也单击矩形外部,glRenderMode(GL_RENDER)函数始终返回1.
我的代码是

hi all
i''m using OpenGL in vc++
i''ve drawn a rectnagle, now i want to pick that rectangle and want to change the color of rectangle when i click on that.
for that i''ve used picking in openGL, but in that the glRenderMode( GL_RENDER ) function always returns 1, even if i click outside the rectangle also.
my code is,

glSelectBuffer( 50, nSelBuf );
    glGetIntegerv( GL_VIEWPORT, nViewport );
    glRenderMode( GL_SELECT );
glInitNames();
    glPushName( 5 );
	glMatrixMode( GL_PROJECTION );
	glPushMatrix();
	glLoadIdentity();

	gluPickMatrix( CursorDownPos.x, 500 - CursorDownPos.y, PICK_AREA, PICK_AREA, nViewport );
	glMatrixMode( GL_MODELVIEW );
	DrawRect();// this function will draw the rectangle
	glMatrixMode( GL_PROJECTION );
	glPopMatrix();
	int nHits = glRenderMode( GL_RENDER ); // here the nHits value will always be 1.
	glMatrixMode( GL_MODELVIEW );

推荐答案


这篇关于glRenderMode函数始终返回1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:47