Skip to main content
gamedev.net
🔒 Locked

Enabling GL_LIGHTING crashes program, help please.

Started by Xersist 3 replies 700+ views
Original Post
Xersist
Xersist
Can anyone please help me a fix for this? When I use basic lighting and enable it. From what I can tell if I translate to like -1.5 the program will still work. The object doesn''t get drawn behind the user either. It''s like it doesn''t like to be drawn too close to the user. The object is retangle shape and by moving slowly back more and more the object will rotate farther and farther before it crashes, and all the time the object is in viewing distance to see the whole thing. When I get to like -1.5 it works fine too. I want to be able to have the object come twards the user. Here''s my actually code that crashes and if I comment out the glEnable(GL_LIGHTING) it works fine. glPushMatrix(); glLoadIdentity(); glEnable(GL_LIGHTING); // Enabling this will crash program // memory cannot be "read" it says glTranslatef(0.0f,0.0f,-1.0f); glRotatef(rot1++,0.0f,1.0f,0.0f); glRotatef(rot2++,1.0f,0.0f,0.0f); glCallList(m_listObject); glPopMatrix(); Thats the best I can describe it, can anyone help/had this problem? Here is how I am enabling lighting. glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); Thanks, Jim
-X-
zedzeek
zedzeek
i remember someit like this a couple of years ago, but i cant remember what the solution was. if u want send me the fullworking project and ill take a quick look

http://members.xoom.com/myBollux
Dave007
Dave007
I think the best 100% working method.
have one initialising function where
everything is set how it have to be.

st like

void Init()
{
float ambient[] = { 0.2, 0.3, 0.6, 1.0 };
...
...
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
...
...

glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
...
//other init code
}

I''m usign this and I have no problems with it!!

Dave007
dave007@volny.cz
--------Dave[ Math Studio ] A Computer Algebra System
avianRR
avianRR
Just an idea??? have you tried putting in a matching call to glDisable(GL_LIGHTING); ??? Don''t know why that might make a difference but you could try it!
This point already been made but... If your entire scene is being light then put the call to glEnable(GL_LIGHTING); in the initialazation code so it only gets called once! Theres no need to waste processing time on calling this every frame if it''s never disabled!
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.