conflict with OpenGL
« on: 01 February 2015, 15:31:00 »
Hey, have a bit of an urgent problem while trying to use TGUI(0.6.6.2 for VS 2010) in a program that already uses SFML 2.2 for window\opengl_context\input.

First i initialize TGUI:
Code: [Select]
tgui::Gui mainGui;
...
mainGui.setWindow(mainWindow);
mainGui.setGlobalFont("Calibri.ttf");

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:

Code: [Select]
tgui::Picture::Ptr dashboard_bg(mainGui, "dashboard_bg");
dashboard_bg->load("dashboard_bg.tga");
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.
« Last Edit: 01 February 2015, 15:35:16 by Sagittarius »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: conflict with OpenGL
« Reply #1 on: 01 February 2015, 15:37:17 »
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?
http://www.sfml-dev.org/tutorials/2.2/window-opengl.php#using-opengl-together-with-the-graphics-module

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?

Re: conflict with OpenGL
« Reply #2 on: 01 February 2015, 15:43:11 »
Thanks, i didn't know that, changed the draw code to:

Code: [Select]
if(!windowClosed) {
renderScene(); //my render

mainWindow.pushGLStates();

mainGui.draw();
mainWindow.display();

mainWindow.popGLStates();
}

But unfortunately, behavior is the same.

Re: conflict with OpenGL
« Reply #3 on: 01 February 2015, 15:45:38 »
Yes, it does crash if i put

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

instead of picture creation code.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: conflict with OpenGL
« Reply #4 on: 01 February 2015, 15:49:17 »
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.