Skip to content

Mixing with raw openGL calls and Context::current().resetState() #626

Description

@TrevorCash

I am trying to get up and running with using raw openGL inside a simple Application. (I am porting an application that used to use raw SDL to now use Magnum)

I am using the imgui example as a base.

if I use some simple openGL calls:

glBindVertexArray(gameGraphics->linesVAO);
glDrawArrays(GL_LINES, 0, maxLines);
glBindVertexArray(0);

In the Application::drawEvent()

I get a crash after a frame (or 2?) when imgui is draw with the Mesh object.

So to midigate I started to use Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::EnterExternal);
and Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::ExitExternal);

Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::EnterExternal);

glBindVertexArray(gameGraphics->linesVAO);
glDrawArrays(GL_LINES, 0, maxLines);
glBindVertexArray(0);

Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::ExitExternal);

So now it no longer crashes (Great!)

I have found that using Magnum::GL::Context::current().resetState(); causes some corruption of the framebuffer with imgui or something. because if you add this code:

Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::EnterExternal);
Magnum::GL::Context::current().resetState(Magnum::GL::Context::State::ExitExternal);

right after the _imgui.newFrame() call. the application will distort the imgui windows when the application windows is resized by dragging.

I am testing on windows.

In general I should be able to bind different gl buffers / textures as long as I use resetState() right to push/pop my changes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions