Fooling around with OpenGL a bit. I got a problem with the lights.
I place the lights with a call to glLightfv(lnum, GL_POSITION, Position) and I also place a small cube there so I can see where the light currently is, or at least should be. But it looks like the light is somewhere next to the sube and not inside it.
Inside my little "engine", everything is an extension to the type TSceneNode. Lights too. Before and after an object is drawn the engine call these two (They are a part of TSceneNode)
All objects also got a render() method. Lights too, and it looks like this:
Can anyone spot a nasty bug or something? Should glTranslate/glrotate/glscale not be used when placing lights?
As I said before, a small cube is being drawn at the lights center and it looks like it is drawn where I want my light, but the light is shining on my scene somewhere else. Looks like it's some GL units along the positive X axis and some units along the negative Z axis from where the cube is, if that makes things any clearer. I have no clue at all what's wrong...
I place the lights with a call to glLightfv(lnum, GL_POSITION, Position) and I also place a small cube there so I can see where the light currently is, or at least should be. But it looks like the light is somewhere next to the sube and not inside it.
Inside my little "engine", everything is an extension to the type TSceneNode. Lights too. Before and after an object is drawn the engine call these two (They are a part of TSceneNode)
Method pre_render() glPushMatrix() gltranslatef(x_pos,y_pos,z_pos) glscalef( x_scale, y_scale, z_scale ) glrotatef(x_rot, 1.0,0.0,0.0) glrotatef(y_rot, 0.0,1.0,0.0) glrotatef(z_rot, 0.0,0.0,1.0) EndMethod Method post_render() glPopMatrix() EndMethod
All objects also got a render() method. Lights too, and it looks like this:
Method Render() Position[0] = x_pos Position[1] = y_pos Position[2] = z_pos glLightfv(lnum, GL_AMBIENT, Ambient) glLightfv(lnum, GL_DIFFUSE, Diffuse) glLightfv(lnum, GL_POSITION, Position) EndMethod
Can anyone spot a nasty bug or something? Should glTranslate/glrotate/glscale not be used when placing lights?
As I said before, a small cube is being drawn at the lights center and it looks like it is drawn where I want my light, but the light is shining on my scene somewhere else. Looks like it's some GL units along the positive X axis and some units along the negative Z axis from where the cube is, if that makes things any clearer. I have no clue at all what's wrong...