Jump to content
  • Advertisement
Sign in to follow this  
golgoth

OpenGL glRenderMode(GL_SELECT)

This topic is 4613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! all this setup works wonderfully for 3d objects but once there is an ortho primitive, no 3d elements can be picked! wherever i click, the ortho primtive is always return as a hit! what im im doing wrong? here s the code:
void OpenGL::SetPicking(Actor *in_actor, Primitive *in_primitive, Int in_x, Int in_y)
{
Int l_precision = 4;
GLint l_viewport[4];
GLuint l_buffer[512];
glGetIntegerv(GL_VIEWPORT, l_viewport);
glSelectBuffer(512, l_buffer);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

glRenderMode(GL_SELECT);
gluPickMatrix(in_x, m_height - in_y, l_precision, l_precision, l_viewport);

if (in_primitive->IsOrtho())
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f); // Left, Right, Bottom, Top, zNear, zFar.
else
gluPerspective(m_currentCamera->GetFovy(), m_currentCamera->GetAspect(), m_currentCamera->GetZNear(), m_currentCamera->GetZFar());

SetClientStates(in_primitive);
Transform(in_actor, in_primitive);
Draw(in_primitive);
UnTransform(in_actor, in_primitive);

glMatrixMode(GL_PROJECTION);
glPopMatrix();

Int l_hit = glRenderMode(GL_RENDER);

if (l_hit != 0)
{
in_primitive->SetMinDepth(l_buffer[1]);
in_primitive->SetMaxDepth(l_buffer[2]);
m_picking.push_back(in_actor);
}
}
m_witdh and m_height are the window size, in_x and in_y are the mouse position! Transform and Untransform push and pop matrices for the respective element either in 2d or 3d mode... any help would be nice! Thx [Edited by - golgoth on January 4, 2006 10:13:18 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!