Thread: OpenGL issues

    #1
  1. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190

    OpenGL issues


    I am really getting :mad: on this...

    I am doing some fun with opengl. At least trying to. My problem is:
    - when i only translate the MODELVIEW matrix, the lights keep static and the room is lit depending on where i am standing. like as if i was carrying a flashlight with me.
    - when i translate the PROJECTION matrix instead, the whole output starts shearing and some polygons are clipped unnecessarily.
    - when i mix both, i get the same result as with only using PROJECTION matrix.

    Ive read quite many tutorials and books, but could not find a clue what causes this behaviour... :confused:

    Anyone here got some experience with OpenGL and lighting? My renderer looks like this:
    Code:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(Tilt, 1, 0, 0);
    glRotatef(Heading, 0, 1, 0);
    glTranslatef(myPosition.X, myPosition.Y, myPosition.Z);
    
    for (....) {
      ... call all renderlists... 
    }
    The lights are setup only once in my Init() function. I tried to re-setup them in the rendering function, but this would require me to do the vector math to find their position depending on heading,tilt and my position. I doubt this is necessary for OpenGL lighting. Everything else was so easy up to now :(

    Any ideas?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190

    Lightbulb Got it solved.


    The concepts of OpenGL are just as whacked as the rest of the programming world :rolleyes:

    I actually do have to move the lights against the direction that my camera is moving. No idea why they dont correspond to polygons in that way as i have to redraw polygons in each frame, but lights not ...

    Sadly, my framerate dropped from constant 400-410/sec to varying between 160 and 360.
    Ok, im out optimizing this now :D
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    2
    Rep Power
    0

    OpenSceneGraph


    Hi!

    If you are in to OpenGL a lot you sholud try the OpenSceneGraph project @ www.openscenegraph.org
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    Gladly I got the lights issues solved. The drop in framerate was due to a part of the code where was so frustrated that i did reset the lights on each frame and re-setup them then. Seems like the initialization of the lights takes some time. A varying time on my radeon... :confused:

    Only had a short glance at the page:
    "DirectX .x model loader" - exactly what i need for my next step :D
    Are you also using OpenGL?

    Thanks for the link.
    M.

IMN logo majestic logo threadwatch logo seochat tools logo