opengl fonts

Started by
10 comments, last by harnacks 18 years, 10 months ago
Is there a way using the nehe tutorial on fonts to draw a screen font NOT affected by lighting ? Mine dissapears when I move behind it or something.
Advertisement
glDisable(GL_LIGHTING);
i realize the greater problem is in fact that while my view changed using gluLookAt, the light still seems to come from the same place, when I rotate around something, i should see its dark side, and I don't. Any thoughts ?
Because the light is always in the 'same spot', and is moving with the view. Like a video camera with a light on it.

Are you drawing 3d letters, and you want to be able to see the backside? Be more specific.

If you are rending 2d text over a scene, you always want the lights off, as well as texturing (unless you use it for the letters).
Ya you've kindof got what I'm saying. My view is like im holding a flashlight or something. Thats not how I want the scene to be rendered. i want the light to be stationary so that as I rotate around these little 3d boxes and 3d text i have, that at some point I see the back (dark) side of them. Is that what the CameraClass on NEHE's site is about or will gluLookAt still work ? I ask only because I did SO MUCH work with spherical coordinates and such that I feel like I should keep using it.
You've got to think of the light positions as you think of the positions of other objects in the scene - if you want them to be affected by a transformation of some kind, you set the light's position after you've set the transformation.
So what you do is you that you set the light position (with glLight*v) after you've done the viewing transformation (e.g. with gluLookAt.) Of course you need to do this every frame for it to work :)
(The same goes for light direction)
The problem is that your modelview matrix seted up by gluLookAt affects the position of your light. So you should put light before gluLookAt, such as:


LightPosition(x, y, z);
gluLookAt(...);
http://358574108.qzone.qq.com
Repositioning the light each frame.. is that the preferred way of doing it ? or is that inefficient ?
Quote:Original post by harnacks
Repositioning the light each frame.. is that the preferred way of doing it ? or is that inefficient ?

Setting the light every frame is more inefficient that not setting it every frame, yes. The cheapest operation is the one you don't have to do, you know. But if you want the light position to be affected by the modelview matrix, then you don't have a choise but to set it after the modelview matrix is set, which usually means every frame.
Basicly, lights work like any other object with a position. They get rotated and translated with the rest of the objects. If you want the light to follow an object that is rotating, you must set the light position along with the rotation, not before.


This topic is closed to new replies.

Advertisement