Skip to content

Global OpenGL state #8

@elect86

Description

@elect86

globjects poses a very interesting matter about the opengl state

From their readme

"
State

OpenGL state is wrapped as States, StateSettings and Capabilities, where the latter two are mainly used internally.

auto currentState = State::currentState(); // full current state; usable for resetting

auto state1 = new State(State::ImmediateMode); // all changes are applied immediately
state1->enable(GL_RASTERIZER_DISCARD); // Configuring a Capability
state1->primitiveRestartIndex(static_cast<GLuint>(-1)); // Configuring a StateSetting

auto state2 = new State(State::DeferredMode); // changes has to be applied explicitly
state2->pointSize(10.0f);
state2->apply();

currentState->apply(); // Reset manipulated state

I like the idea to have a determined place where we can set important variables. In the sample he uses ImmediateMode, but I'm thinking more about using DSA (Direct State Access) or not. Atm DSA is just a top variable to say..

Also, sometimes, for debug purposes, I always missed a confortable way to reset the whole current gl state in a specific point.

Having something like state::reset looks wonderful under this point of view..

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions