Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Avoiding state changes

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Avoiding state changes

    I know that it is evil to enable and disable states a lot of times.
    However if i, for example, donīt know wether the depth test is enabled, and i enable it a lot of times, although it has never been disabled, is this bad for performance ?

    I would think that OpenGL first checks, if a state is already en-/disabled, but if not, i would have to do this.

    Maybe you think itīs a stupid question, but i want to be certain about this.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    155

    Re: Avoiding state changes

    1. just remember if you set it on or off, then you don't have to set it x times
    2. i don't think just setting alphatest on or off will slow down your program a lot. i guess it's only a variable that is set to true or false
    go vegan

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2003
    Posts
    4

    Re: Avoiding state changes

    boolean glIsEnabled(GL_DEPTH_TEST)

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    371

    Re: Avoiding state changes

    Unnecessary state changes are always bad.Make your own state checking routine instead.Put the states you use in a hashtable. Slap your own myglEnable and myglDisable calls around it. This is simple and efficient.

Posting Permissions

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