Commit 5235d7e5 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Modified error handling for OpenGL backend, now error messages should be visible.

parent 73ca1ed7
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -93,7 +93,10 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
    Connect( KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE,
             wxEventHandler( EDA_DRAW_PANEL_GAL::onEvent ), NULL, this );

    // Set up timer that prevents too frequent redraw commands
    m_refreshTimer.SetOwner( this );
    m_pendingRefresh = false;
    m_drawing = false;
    Connect( wxEVT_TIMER, wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), NULL, this );

    this->SetFocus();
@@ -121,6 +124,10 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
    m_pendingRefresh = false;
    m_lastRefresh = wxGetLocalTimeMillis();

    if( !m_drawing )
    {
        m_drawing = true;

        m_gal->BeginDrawing();
        m_gal->SetBackgroundColor( KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
        m_gal->ClearScreen();
@@ -133,6 +140,9 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
        m_gal->DrawCursor( m_viewControls->GetCursorPosition() );

        m_gal->EndDrawing();

        m_drawing = false;
    }
}


+4 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <gal/opengl/vertex_manager.h>
#include <gal/opengl/vertex_item.h>
#include <gal/opengl/shader.h>
#include <confirm.h>
#include <wx/log.h>
#include <list>
#ifdef __WXDEBUG__
@@ -315,7 +316,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )

        if( aTarget == NULL )
        {
            wxLogError( wxT( "Run out of memory" ) );
            DisplayError( NULL, wxT( "Run out of memory" ) );
            return false;
        }
    }
@@ -439,7 +440,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )

        if( newContainer == NULL )
        {
            wxLogError( wxT( "Run out of memory" ) );
            DisplayError( NULL, wxT( "Run out of memory" ) );
            return false;
        }

@@ -458,7 +459,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )

        if( newContainer == NULL )
        {
            wxLogError( wxT( "Run out of memory" ) );
            DisplayError( NULL, wxT( "Run out of memory" ) );
            return false;
        }

+6 −3
Original line number Diff line number Diff line
@@ -32,9 +32,12 @@
#include <gal/opengl/noncached_container.h>
#include <gal/opengl/shader.h>
#include <typeinfo>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <confirm.h>
#ifdef __WXDEBUG__
#include <profile.h>
#include <wx/debug.h>
#include <wx/log.h>
#endif

using namespace KIGFX;
@@ -70,7 +73,7 @@ void GPU_MANAGER::SetShader( SHADER& aShader )

    if( m_shaderAttrib == -1 )
    {
        wxLogFatalError( wxT( "Could not get the shader attribute location" ) );
        DisplayError( NULL, wxT( "Could not get the shader attribute location" ) );
    }
}

@@ -205,7 +208,7 @@ void GPU_CACHED_MANAGER::uploadToGpu()

    if( glGetError() != GL_NO_ERROR )
    {
        wxLogError( wxT( "Error during data upload to the GPU memory" ) );
        DisplayError( NULL, wxT( "Error during data upload to the GPU memory" ) );
    }

#ifdef __WXDEBUG__
+15 −14
Original line number Diff line number Diff line
@@ -29,7 +29,8 @@
 */

#include <gal/opengl/opengl_compositor.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <confirm.h>

using namespace KIGFX;

@@ -97,8 +98,8 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()

    if( usedBuffers() >= m_maxBuffers )
    {
        wxLogError( wxT( "Cannot create more framebuffers. OpenGL rendering backend requires at"
                         "least 3 framebuffers. You may try to update/change "
        DisplayError( NULL, wxT( "Cannot create more framebuffers. OpenGL rendering "
                        "backend requires at least 3 framebuffers. You may try to update/change "
                        "your graphic drivers." ) );
        return 0;    // Unfortunately we have no more free buffers left
    }
@@ -131,38 +132,38 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
        switch( status )
        {
        case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
            wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
            DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
            break;

        case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
            wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) );
            DisplayError( NULL, wxT( "The framebuffer attachment points are incomplete." ) );
            break;

        case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
            wxLogFatalError( wxT( "The framebuffer does not have at least "
            DisplayError( NULL, wxT( "The framebuffer does not have at least "
                                        "one image attached to it." ) );
            break;

        case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
            wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) );
            DisplayError( NULL, wxT( "The framebuffer read buffer is incomplete." ) );
            break;

        case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
            wxLogFatalError( wxT( "The combination of internal formats of the attached images "
            DisplayError( NULL, wxT( "The combination of internal formats of the attached images "
                                  "violates an implementation-dependent set of restrictions." ) );
            break;

        case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
            wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
            DisplayError( NULL, wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
                                  "for all attached renderbuffers" ) );
            break;

        case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
            wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) );
            DisplayError( NULL, wxT( "Framebuffer incomplete layer targets errors." ) );
            break;

        default:
            wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
            DisplayError( NULL, wxT( "Cannot create the framebuffer." ) );
            break;
        }

@@ -223,7 +224,7 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )

    if( aBufferHandle == 0 || aBufferHandle > usedBuffers() )
    {
        wxLogError( wxT( "Wrong framebuffer handle" ) );
        DisplayError( NULL, wxT( "Wrong framebuffer handle" ) );
        return;
    }

+24 −11
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <wx/log.h>
#include <macros.h>
#include <confirm.h>
#ifdef __WXDEBUG__
#include <profile.h>
#endif /* __WXDEBUG__ */
@@ -93,7 +94,8 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,

    if( tesselator == NULL )
    {
        wxLogFatalError( wxT( "Could not create the tesselator" ) );
        DisplayError( parentWindow, wxT( "Could not create the tesselator" ) );
        exit( 1 );
    }

    gluTessProperty( tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
@@ -144,13 +146,22 @@ void OPENGL_GAL::BeginDrawing()
    if( !isShaderInitialized )
    {
        if( !shader.LoadBuiltinShader( 0, SHADER_TYPE_VERTEX ) )
            wxLogFatalError( wxT( "Cannot compile vertex shader!" ) );
        {
            DisplayError( parentWindow, wxT( "Cannot compile vertex shader!" ) );
            exit( 1 );
        }

        if( !shader.LoadBuiltinShader( 1, SHADER_TYPE_FRAGMENT ) )
            wxLogFatalError( wxT( "Cannot compile fragment shader!" ) );
        {
            DisplayError( parentWindow, wxT( "Cannot compile fragment shader!" ) );
            exit( 1 );
        }

        if( !shader.Link() )
            wxLogFatalError( wxT( "Cannot link the shaders!" ) );
        {
            DisplayError( parentWindow, wxT( "Cannot link the shaders!" ) );
            exit( 1 );
        }

        // Make VBOs use shaders
        cachedManager.SetShader( shader );
@@ -915,7 +926,7 @@ void OPENGL_GAL::initGlew()

    if( GLEW_OK != err )
    {
        wxLogError( wxString::FromUTF8( (char*) glewGetErrorString( err ) ) );
        DisplayError( parentWindow, wxString::FromUTF8( (char*) glewGetErrorString( err ) ) );
        exit( 1 );
    }
    else
@@ -931,21 +942,21 @@ void OPENGL_GAL::initGlew()
    }
    else
    {
        wxLogError( wxT( "OpenGL Version 2.1 is not supported!" ) );
        DisplayError( parentWindow, wxT( "OpenGL Version 2.1 is not supported!" ) );
        exit( 1 );
    }

    // Framebuffers have to be supported
    if( !GLEW_EXT_framebuffer_object )
    {
        wxLogError( wxT( "Framebuffer objects are not supported!" ) );
        DisplayError( parentWindow, wxT( "Framebuffer objects are not supported!" ) );
        exit( 1 );
    }

    // Vertex buffer have to be supported
    if( !GLEW_ARB_vertex_buffer_object )
    {
        wxLogError( wxT( "Vertex buffer objects are not supported!" ) );
        DisplayError( parentWindow, wxT( "Vertex buffer objects are not supported!" ) );
        exit( 1 );
    }

@@ -1040,10 +1051,12 @@ void CALLBACK EdgeCallback( GLboolean aEdgeFlag )

void CALLBACK ErrorCallback( GLenum aErrorCode )
{
    const GLubyte* estring;
    const GLubyte* eString = gluErrorString( aErrorCode );

    DisplayError( NULL, wxString( std::string( "Tessellation error: " ) +
            std::string( (const char*)( eString ) ) ) );

    estring = gluErrorString( aErrorCode );
    wxLogError( wxT( "Tessellation Error: %s" ), (char*) estring );
    exit( 1 );
}


Loading