conflict with OpenGL

Started by Sagittarius, 01 February 2015, 15:31:00


Hey, have a bit of an urgent problem while trying to use TGUI( for VS 2010) in a program that already uses SFML 2.2 for window\opengl_context\input.

First i initialize TGUI:
tgui::Gui mainGui;

i have mainGui.handleEvent(currentEvent); and mainGui.draw(); in my main loop;

It compiles and runs fine.
But as soon as i create picture like this:

tgui::Picture::Ptr dashboard_bg(mainGui, "dashboard_bg");
dashboard_bg->setSize(600, 100);

It breaks my OpenGL render. Causing it to crash on glBindVertexArray or glDrawElements. According to gDebugger, the vertex array i use is not valid when i pass it to glBindVertexArray , although it is allocated after i setup gui create picture. Is this for reals(i dunno, maybe you expect me to use SFML's classes instead of proper OpenGL :)) or is this a bug\my misunderstanding of how TGUI works?

P.S. commenting out mainGui.draw() doesn't stop the problem; it's the creation of gui object that cuases it.


TGUI just uses the graphics module from SFML for everything it draws, there should be nothing that TGUI influences that SFML doesn't do already (except perhaps clipping, but the way I implemented it should not give problems).

So could it be that you are not saving and restoring OpenGL states around the draw calls?

If you are doing that already then you should test if you get the same crash or not when loading and drawing an sf::Texture and sf::Sprite.

Edit: If it is the creating of the widgets then the problem is more serious. But does it work when just creating a sf::Texture instead of loading a widget?


Thanks, i didn't know that, changed the draw code to:

if(!windowClosed) {
renderScene(); //my render




But unfortunately, behavior is the same.


Yes, it does crash if i put

sf::Texture texture;
if (!texture.loadFromFile("dashboard_bg.tga"))
    return -1;

instead of picture creation code.


Then you should probably create a minimal code that reproduces the error that doesn't use tgui and go ask on the sfml forum. I can't help you with this.