Click to See Complete Forum and Search --> : more then one gloption


Cash-Einsacker
April 1st, 2004, 01:29 AM
Hi i have the problem that i cant work with 2 options like:

glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
glEnable(GL_LIGHT1);

and

glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);

these options are for two objects, but only one is active for both.
It is possible to bind a option to a specify option so that both have their own options?


Greets

Assmaster
April 1st, 2004, 08:40 AM
I'm not sure I understand what you mean by "option". Are you refering to OpenGL states like glEnable(GL_SOMETHING)?

Could you also try to be clearer on what you want to do with those "options"?

Assmaster
April 1st, 2004, 01:14 PM
After a PM, I think I understand what you're asking.

The behabiour you are seeing, is simply because of the way OpenGL works. It's a state-machine, and therefore any state you enable will stay enabled until you say otherwise.

Because of this you need to enable all the states that a certain primitive you want to draw requires, and then draw the primitive. If a primitive you draw afterwards needs some other state enabled, disable any state that is not needed, enable those who are, and draw the next primitive.

A simpified example:glEnable(GL_LIGHTING);
glutSolidTeapot(1.0);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glutSolidTeapot(1.0);This code will first draw a teapot with lighting enabled. After that it draws a teapot with lighting disabled, but with texturing enabled.

I hope that answered your question.

Cash-Einsacker
April 1st, 2004, 01:35 PM
Hello i want to draw two objects at the same time!

with different options. look at my source above
when i change a option its global for every object!

Assmaster
April 1st, 2004, 02:06 PM
Umm... Not sure i follow you. You can't do two things at the same time. That's true if we're talking either programming in general, or OpenGL specifically. (Unless we're talking multithreading here!)

In your code, you are in fact drawing one thing after the other, so just enable/disable the correct states before you draw each of them.