GL_INVALID_VALUE - Rendering a ChatBox in a ChildWindow - v0.7alpha2

Started by Maxomann, 18 October 2015, 14:28:10

Maxomann

I have a problem using the ChatBox widget in a ChildWindow.
As soon as the ChatBox leaves its original position the text in it is cut off. (Screen1)
And when the ChildWindow is too far in the bottom right corner of the window a GL_INVALID_Value gets thrown. (Screen2)

Minimal Code to repoduce the error is:

#include "stdafx.h"

using namespace std;
using namespace sf;
using namespace tgui;
using namespace placeholders;

int main()
{
// Create the window
RenderWindow window{ { 1080, 720 }, "Window" };
Gui gui{ window };

// Load the font
gui.setFont( "./DejaVuSans.ttf" );

auto childWindow = make_shared<ChildWindow>();
childWindow->setSize( 800, 400 );

auto chatBox = make_shared<ChatBox>();
chatBox->addLine( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );

childWindow->add( chatBox );
gui.add( childWindow );

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

// Pass the event to all the widgets
gui.handleEvent( event );
}

window.clear();

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

window.display();

//output GL_ERROR
while( true )
{
GLenum err = glGetError();
if( err == GL_NO_ERROR )
break;
cout << err << endl;
}
}
}



I compiled TGUI myself with SFML 2.3.2 precompiled binaries using VisualStudio 2015.

texus

Both issues were caused by the same bug.
The internal Panel inside the ChatBox was never told that it was inside a ChildWindow so it didn't update its clipping area like it should. I seem to have introduced this bug when I recently split the initialize function into a setParent and a setFont function which means that it is possible that there are other widgets with the same problem. I tested a select few other widgets which worked fine though. I don't have time to test all the widgets, so in the unlikely event that you come across another widget that has its text cut off then just let me know and I'll fix it asap.

The fixed version can be downloaded from github.