Note that there are some explanatory texts on larger screens.

plurals
  1. POCorrect handling for objects and lights in 3D space - OpenGL
    primarykey
    data
    text
    <p>I am trying to get everything up and running with my engine but am having trouble figuring out what order to add objects and lights to get everything rendered correctly.</p> <p>I set up my projection and modelview matrix in my itialization:</p> <pre><code>glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(75.0f,(GLfloat)width/(GLfloat)height, 0.1f , 1000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); </code></pre> <p>Then, when I am rendering geometry, I clear the buffer and load the identity matrix and update my camera.</p> <pre><code>glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Camera updates glRotatef(camera.anglePitch, 1.0f, 0.0f, 0.0f); glRotatef(camera.angleYaw, 0.0f, 1.0f, 0.0f); glTranslatef(-camera.position.x, -camera.position.y, -camera.position.z); // Now render level.render(); </code></pre> <p>My view of my level is a camera, which I gather is eye coordinates moving around. I am trying to render objects and lights in my level and have them show up in the correct places.</p> <p>I need to add the objects at specific points in the world. For instance, a torus at (10, 10, 25). Is there anything I need to do before I render this torus objects that will make them appear correctly at 10, 10, 25? Do I need to render and then translate them for instance?</p> <p>Also, part 2 has to do with lights. It is pretty much the same question. What consideration do I have to have when rendering say a light at 50, 50, 50? Can I just position the light normally or do again do I have to translate it to there? Or am I over thinking this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload