<commit_before>#include "oglWidget.h"

//
// CONSTRUCTORS ////////////////////////////////////////////////////////////////
// 

/**
 * @brief      Default constructor for OGLWidget.
 */
OGLWidget::OGLWidget()
{
    // Update the widget after a frameswap
    connect( this, SIGNAL( frameSwapped() ),
        this, SLOT( update() ) );
    // Exit the application
    connect( this, SIGNAL( exitFlag() ),
        QApplication::instance(), SLOT( quit() ) );

    // Setup the Camera
    camera.rotate( -40.0f, 1.0f, 0.0f, 0.0f );
    camera.translate( 0.0f, 30.0f, 45.0f );

    renderables.push_back( new Sun() );
}

/**
 * @brief      Destructor class to unallocate OpenGL information.
 */
OGLWidget::~OGLWidget()
{
    makeCurrent();
    teardownGL();
}

//
// OPENGL FUNCTIONS ////////////////////////////////////////////////////////////
// 

void OGLWidget::initializeGL()
{
    // Init OpenGL Backend
    initializeOpenGLFunctions();
    printContextInfo();

    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->initializeGL();
    }
}

/**
 * @brief      Sets the prespective whenever the window is resized.
 *
 * @param[in]  width   The width of the new window.
 * @param[in]  height  The height of the new window.
 */
void OGLWidget::resizeGL( int width, int height )
{
    projection.setToIdentity();
    projection.perspective( 55.0f,  // Field of view angle
                            float( width ) / float( height ),   // Aspect Ratio
                            0.01f,  // Near Plane (MUST BE GREATER THAN 0)
                            1000.0f );  // Far Plane
}

/**
 * @brief      OpenGL function to draw elements to the surface.
 */
void OGLWidget::paintGL()
{
    glEnable( GL_DEPTH_TEST );
    glDepthFunc( GL_LEQUAL );
    glDepthMask( GL_TRUE );
    glEnable( GL_CULL_FACE );
    glClearColor( 0.0f, 0.0f, 0.2f, 1.0f );

    // Clear the screen
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->paintGL( camera, projection );
    }
}

/**
 * @brief      Destroys any OpenGL data.
 */
void OGLWidget::teardownGL()
{
    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->teardownGL();
    }
}

//
// QT SLOTS ////////////////////////////////////////////////////////////////////
// 

/**
 * @brief      Updates any user interactions and model transformations.
 */
void OGLWidget::update()
{
    Input::update();
    if( Input::keyPressed( Qt::Key_Escape ) )
        emit exitFlag();

    // Camera Transforms
    if( Input::buttonPressed( Qt::RightButton ) )
    {
        static const float cameraTranslationSpeed = 0.1f;
        static const float cameraRotationSpeed = 0.1f;

        camera.rotate( -cameraRotationSpeed * Input::mouseDelta().x(), 
            Camera3D::LocalUp );<commit_msg>updated camera speed<commit_after>#include "oglWidget.h"

//
// CONSTRUCTORS ////////////////////////////////////////////////////////////////
// 

/**
 * @brief      Default constructor for OGLWidget.
 */
OGLWidget::OGLWidget()
{
    // Update the widget after a frameswap
    connect( this, SIGNAL( frameSwapped() ),
        this, SLOT( update() ) );
    // Exit the application
    connect( this, SIGNAL( exitFlag() ),
        QApplication::instance(), SLOT( quit() ) );

    // Setup the Camera
    camera.rotate( -40.0f, 1.0f, 0.0f, 0.0f );
    camera.translate( 0.0f, 30.0f, 45.0f );

    renderables.push_back( new Sun() );
}

/**
 * @brief      Destructor class to unallocate OpenGL information.
 */
OGLWidget::~OGLWidget()
{
    makeCurrent();
    teardownGL();
}

//
// OPENGL FUNCTIONS ////////////////////////////////////////////////////////////
// 

void OGLWidget::initializeGL()
{
    // Init OpenGL Backend
    initializeOpenGLFunctions();
    printContextInfo();

    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->initializeGL();
    }
}

/**
 * @brief      Sets the prespective whenever the window is resized.
 *
 * @param[in]  width   The width of the new window.
 * @param[in]  height  The height of the new window.
 */
void OGLWidget::resizeGL( int width, int height )
{
    projection.setToIdentity();
    projection.perspective( 55.0f,  // Field of view angle
                            float( width ) / float( height ),   // Aspect Ratio
                            0.01f,  // Near Plane (MUST BE GREATER THAN 0)
                            1000.0f );  // Far Plane
}

/**
 * @brief      OpenGL function to draw elements to the surface.
 */
void OGLWidget::paintGL()
{
    glEnable( GL_DEPTH_TEST );
    glDepthFunc( GL_LEQUAL );
    glDepthMask( GL_TRUE );
    glEnable( GL_CULL_FACE );
    glClearColor( 0.0f, 0.0f, 0.2f, 1.0f );

    // Clear the screen
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->paintGL( camera, projection );
    }
}

/**
 * @brief      Destroys any OpenGL data.
 */
void OGLWidget::teardownGL()
{
    QVectorIterator<Renderable*> i_renderable( renderables );
    while( i_renderable.hasNext() )
    {
        ( i_renderable.next() )->teardownGL();
    }
}

//
// QT SLOTS ////////////////////////////////////////////////////////////////////
// 

/**
 * @brief      Updates any user interactions and model transformations.
 */
void OGLWidget::update()
{
    Input::update();
    if( Input::keyPressed( Qt::Key_Escape ) )
        emit exitFlag();

    // Camera Transforms
    if( Input::buttonPressed( Qt::RightButton ) )
    {
        static const float cameraTranslationSpeed = 0.3f;
        static const float cameraRotationSpeed = 0.1f;

        camera.rotate( -cameraRotationSpeed * Input::mouseDelta().x(), 
            Camera3D::LocalUp );
{'fraction_non_alphanumeric': 0.1895327719993396, 'fraction_numerical': 0.013868251609707775, 'mean_word_length': 2.0094386487829112, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '3702507', 'n_tokens_mistral': 1935, 'n_tokens_neox': 1846, 'n_words': 438}