OpenGl: lightings and fonts

This is a discussion on OpenGl: lightings and fonts within the Game Programming forums, part of the General Programming Boards category; I am learning opengl to implement games in the future. I wrote a program displaying a cube with reflection. A ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    133

    OpenGl: lightings and fonts

    I am learning opengl to implement games in the future. I wrote a program displaying a cube with reflection. A light is suppose to lit the cube from the left side. However the cube is seen lit from both side.

    And in the render() function, if i call the printString() function, the reflection of the cube is gone. I have attached the source code file. Can someone pls see what is wrong?

    Thanks

    Using VC++ 6.0

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    It seems to me your matrix stack is getting corrupted. I don't have time to debug your program but I would suggest that you create a routine to output a matrix that you get from OpenGL. Take out your string routine so it works fine and record the matrices. Then put it in and record them and note the differences.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    133
    Thanks for the suggestion, MrWiz. But i am very new to openGL. How do i record the matrix? I have only learn how to load and multiply matrix stack, but not sure how i could read out the matrix and record them.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    It's pretty easy, you can wrap the function up and have it display your matrix all nice so you don't have to repeat the code everytime. The main matrices you are worried about are modelview and projection but i doubt projection is getting messed up but check it anyways.

    Code:
    GLdouble modelview[16]; // 4x4 matrix so we need 16 entries
    glGetDoublev(GL_MODELVIEW_MATRIX, modelview); // Get modelview matrix
    and similarily for projection..

    Code:
    GLdouble projection[16]; // 4x4 matrix so we need 16 entries
    glGetDoublev(GL_PROJECTION_MATRIX, projection); // Get projection matrix
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21