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: What to keep in mind when moving ahead?

  1. #1
    Intern Newbie
    Join Date
    Dec 2013
    Posts
    45

    What to keep in mind when moving ahead?

    I'm constantly afraid of writing something one way, and having it come back to bite me in the butt because it doesn't fit with what I'll be doing later; it's happened plenty for me already through learning OpenGL. Do you all have any tips/pointers for how to lay out an OpenGL-based program? Is it best to encapsulate stuff in classes as much as I can, or is that not too necessary? I'm just a bit reluctant to do so because, since I'm a beginner, I might write classes looking at an OpenGL object from the wrong perspective, and they might end up being useless in the end.

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,162
    It is very hard to give any kind of advice, since you have to find a compromise between efficiency and easiness of development.
    The efficiency assumes a minimization of state changing, while OO paradigm assumes encapsulation states with objects.
    DSA (Direct State Access) could be the solution, but it is not a part of the core.

    My general advice: make classes/objects for renderer, shaders, data containers (vertex and texture) etc.

  3. #3
    Intern Newbie
    Join Date
    Dec 2013
    Posts
    45
    I didn't even know about DSA. I just read about it, and that looks like it could really help with some of my class wrappers. For example:
    Code :
        void SetData(const T &Data_in)
        {
            if((Data_in != Data) || Dirty)
            {
                Data = Data_in;
                GLuint Initial;
                glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)(&Initial));
                GLuint Previous = Initial;
                for(auto &i : Uniforms)
                {
                    if(i.first != Previous)
                    {
                        glUseProgram(i.first);
                        Previous = i.first;
                    }
                    SetUniform(i.second);
                }
                if(Initial != Previous) glUseProgram(Initial);
            }
            Dirty = false;
        }
    DSA would be great for that. Is DSA commonly supported?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,224
    AMD and NVidia both do. Click "EXT_direct_state_access" here:

    * OpenGL capabilities database

    Check vendor, GPU, and driver combinations you care about.

Posting Permissions

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