#### Archived

This topic is now archived and is closed to further replies.

# Matrix Transforms and Lighting

This topic is 5049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all, I posted here last week with a problem with OpenGL lighting - and I''ve since worked it out. However, the solution really doesn''t look pretty... and more importantly, whilst it technically works I doubt its ''correct'' OpenGL. Any chance anyone can tell me how this should be done? Basically, I have a load of geometry being rendered with a single directional light source. Yet I found that changing the viewing angle (not position tho) would affect lighting. So instead of setting up lighting ONCE at startup (as I would in D3D) I have to re-set the direction before rendering each block of terrain (such that the current MODELVIEW transform doesn''t screw it over). As such I''ve lost 10 million triangles/second in performance (~50mil down to 38-40mil). I cant see how this can be correct?! Surely the many OpenGL games kicking around can''t be doing something as ugly as this! surely there is a way that I can setup my lighting and then leave it alone ? or at least only make minimal changes such that the MODELVIEW doesn''t screw over my lighting? cheers, Jack

##### Share on other sites
is the following construct more correct ? (haven't checked it yet..)

glPushMatrix( )  glLoadIdentity( )  //set light positionglPopMatrix( )

as a do-once-at-startup type operation?

EDIT: scrap that, it dont work - anyone got ANY ideas?!

cheers,
Jack

[edited by - Jollyjeffers on March 21, 2004 10:45:33 AM]