Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


cec19

Member Since 09 Jan 2012
Offline Last Active Feb 09 2012 08:33 AM

#4901259 Mouse ray picking not working.

Posted by cec19 on 10 January 2012 - 05:10 AM

I managed to fix the problem. The code, which made things not work was in the display function:

void Display()
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();


    glPushMatrix();
        ApplyCamera();
        DrawGrid(10000, 200);
        DrawObjects();

    glPopMatrix();

    DrawText();


    glutSwapBuffers();
}

Simply, the push and pop funcs are making sth wrong in my code(I am not so experienced and I can't tell exactly what). By removing them I managed to get good results for the depth buffers.

void Display()
{
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();


    DrawText();

    ApplyCamera();
    DrawGrid(10000, 200);
    DrawObjects();


    glutSwapBuffers();
}

Thats it! If anyone can explain me why the pushing and popping matrices screws the whole algorithm please post. :)


PARTNERS