<commit_before>/******************************************************************************
 * This file is part of the Gluon Development Platform
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "renderwidget.h"

#include <QResizeEvent>
#include <QDebug>
#include <QVector3D>
#include <QMatrix4x4>

#include "manager.h"
#include "outputsurface.h"
#include "backend.h"

#include "shader.h"
#include "meshdata.h"

using namespace GluonGraphics;

class RenderWidget::Private
{
    public:
        Private() : surface( 0 ) { }

        OutputSurface* surface;

        Shader* shader;
        MeshData* data;
};

RenderWidget::RenderWidget( QWidget* parent, Qt::WindowFlags f ) :
    QWidget( parent, f ), d( new Private )
{
    setAttribute( Qt::WA_PaintOnScreen );
    setAttribute( Qt::WA_OpaquePaintEvent );
}

RenderWidget::~RenderWidget()
{
    delete d->surface;
    delete d;
}

void RenderWidget::paintEvent( QPaintEvent* event )
{
    if( !d->surface )
    {
        if( !Manager::instance()->backend()->initialize( this ) )
            qFatal( Manager::instance()->backend()->errorString().toUtf8() );

        Manager::instance()->initialize();
        d->surface = Manager::instance()->backend()->createOutputSurface( this );
        d->surface->setSize( width(), height() );

        d->surface->createDebug();
    }

    d->surface->renderContents();
}

void RenderWidget::resizeEvent( QResizeEvent* event )
{
    if( d->surface )
        d->surface->setSize( event->size().width(), event->size().height() );
    QWidget::resizeEvent( event );
}

#include "renderwidget.moc"<commit_msg>Graphics: Ensure we initialize everything as soon as possible.<commit_after>/******************************************************************************
 * This file is part of the Gluon Development Platform
 * Copyright (c) 2012 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "renderwidget.h"

#include <QResizeEvent>
#include <QDebug>
#include <QVector3D>
#include <QMatrix4x4>

#include "manager.h"
#include "outputsurface.h"
#include "backend.h"

#include "shader.h"
#include "meshdata.h"

using namespace GluonGraphics;

class RenderWidget::Private
{
    public:
        Private() : surface( 0 ) { }

        OutputSurface* surface;

        Shader* shader;
        MeshData* data;
};

RenderWidget::RenderWidget( QWidget* parent, Qt::WindowFlags f ) :
    QWidget( parent, f ), d( new Private )
{
    setAttribute( Qt::WA_PaintOnScreen );
    setAttribute( Qt::WA_OpaquePaintEvent );

    if( !Manager::instance()->backend()->initialize( this ) )
        qFatal( Manager::instance()->backend()->errorString().toUtf8() );
}

RenderWidget::~RenderWidget()
{
    delete d->surface;
    delete d;
}

void RenderWidget::paintEvent( QPaintEvent* event )
{
    if( !d->surface )
    {
        Manager::instance()->initialize();
        d->surface = Manager::instance()->backend()->createOutputSurface( this );
        d->surface->setSize( width(), height() );
    }

    d->surface->renderContents();
}

void RenderWidget::resizeEvent( QResizeEvent* event )
{
    if( d->surface )
        d->surface->setSize( event->size().width(), event->size().height() );
    QWidget::resizeEvent( event );
}

#include "renderwidget.moc"
{'fraction_non_alphanumeric': 0.1533064001701042, 'fraction_numerical': 0.009355730384860728, 'mean_word_length': 3.9, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '630720', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1297, 'n_words': 444}