CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2003
    Posts
    85

    more then one gloption

    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

  2. #2
    Join Date
    Jun 2003
    Location
    Gjøvik, Norway
    Posts
    204
    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"?

  3. #3
    Join Date
    Jun 2003
    Location
    Gjøvik, Norway
    Posts
    204
    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:
    Code:
    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.

  4. #4
    Join Date
    Mar 2003
    Posts
    85
    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!

  5. #5
    Join Date
    Jun 2003
    Location
    Gjøvik, Norway
    Posts
    204
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured