VS2013 Tutorial - Open GL issue.

Started by jackdaws, 12 February 2014, 13:39:27

jackdaws

I was following the tutorial for TGUI in Visual Studio 2013 Pro (Win 8.1 64bit enterprise) when I ran across this problem. Everything compiles fine but when I go to debug the program only the username and password text is displayed the image is not.

The exact error is "An internal OpenGL call failed in RenderTarget.cpp : GL_IVALID_VALUE, a numeric argument is out of range"

I have no idea what that means and the only thing I found on google like that was https://github.com/texus/TGUI/issues/17 .

(Copy paste my code)

ifdef SFML_STATIC
#pragma comment(lib, "glew.lib")
#pragma comment(lib, "freetype.lib")
#pragma comment(lib, "jpeg.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "gdi32.lib") 
#endif // SFML_STATIC


#include <SFML/Graphics.hpp>

#include <TGUI/TGUI.hpp>

void loadWidgets(tgui::Gui& gui);

int main()
{
// Create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
tgui::Gui gui(window);

// Load the font (you should check the return value to make sure that it is loaded)
gui.setGlobalFont("DejaVuSans.ttf");

loadWidgets(gui);

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();

// Pass the event to all the widgets (if there would be widgets)
gui.handleEvent(event);
}

// The callback loop
tgui::Callback callback;
while (gui.pollCallback(callback))
{
// Make sure tha callback comes from the button
if (callback.id == 1)
{
// Get the username and password
tgui::EditBox::Ptr editBoxUsername = gui.get("Username");
tgui::EditBox::Ptr editBoxPassword = gui.get("Password");

sf::String username = editBoxUsername->getText();
sf::String password = editBoxPassword->getText();

// Continue here by checking if the username and password are correct ...
}
}


window.clear();

// Draw all created widgets
gui.draw();

window.display();
}

return EXIT_SUCCESS;
}

void loadWidgets(tgui::Gui& gui)
{
// Create the background image
tgui::Picture::Ptr picture(gui);
picture->load("miranda.jpg");
picture->setSize(800, 600);

// Create the username label
tgui::Label::Ptr labelUsername(gui);
labelUsername->setText("Username:");
labelUsername->setPosition(200, 100);

// Create the password label
tgui::Label::Ptr labelPassword(gui);
labelPassword->setText("Password:");
labelPassword->setPosition(200, 250);

// Create the username edit box
tgui::EditBox::Ptr editBoxUsername(gui, "Username");
editBoxUsername->load("TGUI/widgets/Black.conf");
editBoxUsername->setSize(400, 40);
editBoxUsername->setPosition(200, 140);

// Create the password edit box (we will copy the previously created edit box)
tgui::EditBox::Ptr editBoxPassword = gui.copy(editBoxUsername, "Password");
editBoxPassword->setPosition(200, 290);
editBoxPassword->setPasswordCharacter('*');

// Create the login button
tgui::Button::Ptr button(gui);
button->load("TGUI/widgets/Black.conf");
button->setSize(260, 60);
button->setPosition(270, 440);
button->setText("Login");
button->bindCallback(tgui::Button::LeftMouseClicked);
button->setCallbackId(1);
}

texus

#1
You should put "return 0;" before your main loop, that will show you the first few errors that are being printed instead of seeing the error that is printed every frame.

Because you say that the image isn't being displayed, I assume that it isn't loaded. The reason for this is probably because you are placing the image in the wrong folder (not in the working directory).

It seems like EditBox is missing a check in draw which causes it to be drawn even when it isn't loaded (which probably causes those opengl errors). I'll solve it in the next release, but the real problem which you have is that it isn't loaded correctly.

jackdaws

Oh derp. I forgot .jpg wasn't supported. That's why it wasn't loading. The GL issue wasn't fixed however but as you said it doesn't effect the program (from what I can see) at all. Thanks :D

texus

Quoteit doesn't effect the program
Then we are talking about a different issue.
I could only reproduce the errors when the file passed to the load function of EditBox wasn't found, which means that the edit box doesn't get drawn. If everything works (when you see the image, two labels, two edit boxes and the button) then I don't get these errors.

If it doesn't affect anything then it can be ignored, although I would prefer to fix such issue. But as I can't reproduce this, it might just as well be a driver issue. And whatever the issue is, if I can't reproduce it then I can't fix it.