Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43

Thread: How does OpenGL store it's states?

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    How does OpenGL store it's states?

    Do they use 32 bits? I would assume not because there are more than 32 states.

    Am I correct when I say that variables created in opengl for states are initialized using this method:

    GLenum state_polygon{GL_POLYGON_SMOOTH, GL_POLYGON_STIPPLE};

    Or does it look like this:
    GLenum states{all state variables};

  2. #2
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Copenhagen, DK, Denmark
    Posts
    72

    Re: How does OpenGL store it's states?

    It's probably your last suggestion, it's the one that makes most sense if you take a quick look at gl.h.

    But why the heck do you want to know that? OpenGL doesn't specify how to do it, so each driver could do it differently internally.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: How does OpenGL store it's states?

    My model library is using bits for states. I want to store more than 32 states.

    I could do this:
    bool StateArray[256];

    enum state{Blah1, Blah2...};

    StateArray[Blah1]=true;

    I'd rather know if there's a better way...is there?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Gothenburg, Sweden
    Posts
    124

    Re: How does OpenGL store it's states?

    That seems like an easy straightforward way to do it... what are your problems with doing it like that?

    I'm just trying to say that it really doesn't matter, as long as things are going fast enough and are easy to use in the rest of your code. (Trying to do it 'modular' is good too, but in this case you could easily write a class that overloads the [] operator, if you're into c++.)

    If you have loads of bits (256 is not) then you could perhaps use std::vector<bool> which stores bools as bits (instead of taking up a byte, which is the common case) ... but you'd lose a lot more performance trying to bit-fiddle like that than you'd gain by having a smaller memory footprint.
    --
    /Marcus

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: How does OpenGL store it's states?

    I started programming about 5+ years ago. During that time computers weren't all that fast, and every book I read and every tutorial I saw have brain washed me into thinking "don't use any more memory than you have to!!!". In one way it's helped me to keep things small, but in the other way it's holding me from doing more things.

    I'll just have to get over it. You can't push forward unless you push the limits.

    Here's an example of saving to much space. Way back when, when I had been programming for about 3 years, I had a cool idea for 3D models...it was to index vertices so you could share vertices that way. I said to myself "wow, all the indices would take up alota room in memory if I did that...the pros must have a better way". Gah!!! If I had only pushed my limits. I've learned never to hold back sence I found out that that's how the pros DO do it .

  6. #6
    Junior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Gothenburg, Sweden
    Posts
    124

    Re: How does OpenGL store it's states?

    I believe the trade-off was the same then as it is now (I've coded in C/C++ for some 8 years now, and was hacking assembly on amiga before that).

    Don't optimize until you know it matters!

    What if you optimize the heck out of this to save... say.. 4 kb... only to allocate 200kb of stuff in another place... (and I'm being conservative with numbers here..)

    [This message has been edited by macke (edited 04-16-2001).]
    --
    /Marcus

  7. #7
    Junior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Gothenburg, Sweden
    Posts
    124

    Re: How does OpenGL store it's states?

    Idea: Why don't you go look in the MESA source?

    ftp://ftp.mesa3d.org/pub/sourceforge/mesa3d/

    It's all C, but it's an opengl implementation nevertheless.
    --
    /Marcus

  8. #8
    Intern Contributor
    Join Date
    Dec 2000
    Location
    houston, tx
    Posts
    80

    Re: How does OpenGL store it's states?

    little magic trolls do it for you
    no need to worry about them.

  9. #9
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sweden
    Posts
    130

    Re: How does OpenGL store it's states?

    Man Kaber...

    .. would my graphics card work faster if I threaten it with a spanking aswell?

    Maybe its a little Demon that sits on the other side of the monitor, painting his ass off with a small brush.

    Maybe he is the reason why we mistype so often...


  10. #10
    Intern Contributor
    Join Date
    Dec 2000
    Location
    houston, tx
    Posts
    80

    Re: How does OpenGL store it's states?

    Originally posted by Hull:
    Man Kaber...

    .. would my graphics card work faster if I threaten it with a spanking aswell?

    Maybe its a little Demon that sits on the other side of the monitor, painting his ass off with a small brush.

    Maybe he is the reason why we mistype so often...


    man, now that's just silly
    of course it would



    laterz.

Posting Permissions

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