Jump to content
  • Advertisement
Sign in to follow this  
Forkbomb

OpenGL Ray Tracing problems

This topic is 3608 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 All! This is my first time posting on GameDev, quite exciting! I very recently got into computer graphics and am using OpenGL to do my learning. At this point I'm working on a ray tracer and am getting some strange behavior, I think. So here's the code I'm working with (it's the display function hooked to glutDisplayFunc):
void display(void)
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(30,128/128,1.0,150);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(50,50,50,0,10,0,0,1,0);

    GLdouble projection[16];
    GLdouble modelview[16];
    GLint viewport[4];
    GLdouble objx,objy,objz;

    glGetDoublev(GL_MODELVIEW_MATRIX,modelview);
    glGetDoublev(GL_PROJECTION_MATRIX,projection);
    glGetIntegerv(GL_VIEWPORT,viewport);

    for (int x = 0; x < 128; x++)
    {
        for (int y = 0; y < 128; y++)
        {
            gluUnProject(x,y,0,modelview,projection,viewport,&objx,&objy,&objz);
            cout << "pixel (x,y=" << x << "," << y << ") => " << objx << " " << objy << " " << objz << endl;
        }
    }

    glFlush();
}
I'm using gluUnProject to get my pixel coordinates in object space so I can compute my ray vector. The picture will be 128x128 pixels. My question is - does this look right as far as correctly using gluUnProject to get the pixel coordinates? All of my objx, objy, and objz values come out to 49.xxxx. The numbers seemed strange to me because if I combined these numbers with that of my camera coordinates then it would produce very similar vectors for all of my rays. I guess I'm just really unsure of myself since I'm so new at this, but I'm hoping to get some positive feedback from all you pros out there :) Thanks for taking the time to read. Regards, Forkbomb [Edited by - Forkbomb on December 6, 2008 1:30:54 PM]

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!