<commit_before>#include <Engine/Data/ShaderConfigFactory.hpp>
#include <Engine/Rendering/ForwardRenderer.hpp>
#include <minimalapp.hpp>

#include <Gui/Utils/KeyMappingManager.hpp>
#include <Gui/Viewer/TrackballCameraManipulator.hpp>

MinimalApp::MinimalApp( int& argc, char** argv ) :
    QApplication( argc, argv ),
    m_engine( nullptr ),
    m_task_queue( nullptr ),
    m_viewer( nullptr ),
    m_frame_timer( nullptr ),
    m_target_fps( 60 ) {
    // Set application and organization names in order to ensure uniform
    // QSettings configurations.
    // \see http://doc.qt.io/qt-5/qsettings.html#QSettings-4
    QCoreApplication::setOrganizationName( "STORM-IRIT" );
    QCoreApplication::setApplicationName( "HelloRadium" );

    // Initialize Engine.
    m_engine.reset( Ra::Engine::RadiumEngine::createInstance() );
    m_engine->initialize();

    ///\todo update when a basic viewer is implemented ... (to call setupKeyMappingCallbacks)
    Ra::Gui::KeyMappingManager::createInstance();
    Ra::Gui::KeyMappingManager::getInstance()->addListener(
        Ra::Gui::TrackballCameraManipulator::configureKeyMapping );
    Ra::Gui::KeyMappingManager::getInstance()->addListener( Ra::Gui::Viewer::configureKeyMapping );

    // Initialize taskqueue.
    m_task_queue.reset( new Ra::Core::TaskQueue( std::thread::hardware_concurrency() - 1 ) );
    // Initialize viewer.
    m_viewer.reset( new Ra::Gui::Viewer );

    CORE_ASSERT( m_viewer != nullptr, "GUI was not initialized" );
    connect( m_viewer.get(),
             &Ra::Gui::Viewer::requestEngineOpenGLInitialization,
             this,
             &MinimalApp::onGLInitialized );
    m_viewer->setupKeyMappingCallbacks();

    // Initialize timer for the spinning cube.
    m_frame_timer = new QTimer( this );
    m_frame_timer->setInterval( 1000 / m_target_fps );
}

MinimalApp::~MinimalApp() {
    // need to clean up everithing before engine is cleaned up.
    m_task_queue.reset( nullptr );
    m_viewer.reset( nullptr );
    m_engine->cleanup();
    m_engine.reset( nullptr );
}

void MinimalApp::onGLInitialized() {
    // initialize here the OpenGL part of the engine used by the application
    m_engine->initializeGL();
    // add the renderer
    std::shared_ptr<Ra::Engine::Rendering::Renderer> e(
        new Ra::Engine::Rendering::ForwardRenderer() );
    m_viewer->addRenderer( e );
    connect( m_frame_timer, &QTimer::timeout, this, &MinimalApp::frame );
}

void MinimalApp::frame() {
    // We use a fixed time step, but it is also possible
    // to check the time from last frame.
    const Scalar dt = 1.f / Scalar( m_target_fps );

    // Starts the renderer
    m_viewer->startRendering( dt );

    // Collect and run tasks
    m_engine->getTasks( m_task_queue.get(), dt );
    m_task_queue->startTasks();
    m_task_queue->waitForTasks();
    m_task_queue->flushTaskQueue();

    // Finish the frame
    m_viewer->swapBuffers();

    m_engine->endFrameSync();
}<commit_msg>[tests] draw primitive app render after task flush.<commit_after>#include <Engine/Data/ShaderConfigFactory.hpp>
#include <Engine/Rendering/ForwardRenderer.hpp>
#include <minimalapp.hpp>

#include <Gui/Utils/KeyMappingManager.hpp>
#include <Gui/Viewer/TrackballCameraManipulator.hpp>

MinimalApp::MinimalApp( int& argc, char** argv ) :
    QApplication( argc, argv ),
    m_engine( nullptr ),
    m_task_queue( nullptr ),
    m_viewer( nullptr ),
    m_frame_timer( nullptr ),
    m_target_fps( 60 ) {
    // Set application and organization names in order to ensure uniform
    // QSettings configurations.
    // \see http://doc.qt.io/qt-5/qsettings.html#QSettings-4
    QCoreApplication::setOrganizationName( "STORM-IRIT" );
    QCoreApplication::setApplicationName( "HelloRadium" );

    // Initialize Engine.
    m_engine.reset( Ra::Engine::RadiumEngine::createInstance() );
    m_engine->initialize();

    ///\todo update when a basic viewer is implemented ... (to call setupKeyMappingCallbacks)
    Ra::Gui::KeyMappingManager::createInstance();
    Ra::Gui::KeyMappingManager::getInstance()->addListener(
        Ra::Gui::TrackballCameraManipulator::configureKeyMapping );
    Ra::Gui::KeyMappingManager::getInstance()->addListener( Ra::Gui::Viewer::configureKeyMapping );

    // Initialize taskqueue.
    m_task_queue.reset( new Ra::Core::TaskQueue( std::thread::hardware_concurrency() - 1 ) );
    // Initialize viewer.
    m_viewer.reset( new Ra::Gui::Viewer );

    CORE_ASSERT( m_viewer != nullptr, "GUI was not initialized" );
    connect( m_viewer.get(),
             &Ra::Gui::Viewer::requestEngineOpenGLInitialization,
             this,
             &MinimalApp::onGLInitialized );
    m_viewer->setupKeyMappingCallbacks();

    // Initialize timer for the spinning cube.
    m_frame_timer = new QTimer( this );
    m_frame_timer->setInterval( 1000 / m_target_fps );
}

MinimalApp::~MinimalApp() {
    // need to clean up everithing before engine is cleaned up.
    m_task_queue.reset( nullptr );
    m_viewer.reset( nullptr );
    m_engine->cleanup();
    m_engine.reset( nullptr );
}

void MinimalApp::onGLInitialized() {
    // initialize here the OpenGL part of the engine used by the application
    m_engine->initializeGL();
    // add the renderer
    std::shared_ptr<Ra::Engine::Rendering::Renderer> e(
        new Ra::Engine::Rendering::ForwardRenderer() );
    m_viewer->addRenderer( e );
    connect( m_frame_timer, &QTimer::timeout, this, &MinimalApp::frame );
}

void MinimalApp::frame() {
    // We use a fixed time step, but it is also possible
    // to check the time from last frame.
    const Scalar dt = 1.f / Scalar( m_target_fps );

    // Collect and run tasks
    m_engine->getTasks( m_task_queue.get(), dt );
    m_task_queue->startTasks();
    m_task_queue->waitForTasks();
    m_task_queue->flushTaskQueue();

    // Starts the renderer
    m_viewer->startRendering( dt );

    // Finish the frame
    m_viewer->swapBuffers();

    m_engine->endFrameSync();
}
{'fraction_non_alphanumeric': 0.13082077051926297, 'fraction_numerical': 0.0033500837520938024, 'mean_word_length': 3.7201581027667983, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4886488', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1817, 'n_words': 403}