Ticket #34: svx123-gl-fixes.patch

File svx123-gl-fixes.patch, 1.7 KB (added by Olly Betts, 12 years ago)

fix to not use gl before it is initialised

  • src/gla-gl.cc

     
    138138//            (thus it must not be called from BeginLines(), etc., or within a
    139139//             BeginLines()/EndLines() block etc.)
    140140#define CHECK_GL_ERROR(M, F) do { \
     141    if (!opengl_initialised) { \
     142        wxLogError(wxT(__FILE__":"STRING(__LINE__)": OpenGL not initialised before (call "F" in method "M")")); \
     143    } \
    141144    GLenum error_code_ = glGetError(); \
    142145    if (error_code_ != GL_NO_ERROR) { \
    143146        wxLogError(wxT(__FILE__":"STRING(__LINE__)": OpenGL error: %s " \
     
    244247    m_Fog = false;
    245248    m_AntiAlias = false;
    246249    list_flags = 0;
    247     // Set the background colour of the canvas to black.
    248     glClearColor(0.0, 0.0, 0.0, 1.0);
    249     CHECK_GL_ERROR("GLACanvas", "glClearColor");
    250250}
    251251
    252252GLACanvas::~GLACanvas()
     
    268268
    269269    SetCurrent();
    270270    opengl_initialised = true;
     271
     272    // Set the background colour of the canvas to black.
     273    glClearColor(0.0, 0.0, 0.0, 1.0);
     274    CHECK_GL_ERROR("FirstShow", "glClearColor");
     275
     276    // Set viewport.
     277    glViewport(0, 0, x_size, y_size);
     278    CHECK_GL_ERROR("FirstShow", "glViewport");
     279
    271280    save_hints = false;
    272281    vendor = wxString((const char *)glGetString(GL_VENDOR), wxConvUTF8);
    273282    renderer = wxString((const char *)glGetString(GL_RENDERER), wxConvUTF8);
     
    490499    // This apparently is (or at least was) needed for Mac OS X.
    491500    wxGLCanvas::OnSize(event);
    492501
     502    if (!opengl_initialised) return;
     503
    493504    // Set viewport.
    494505    glViewport(0, 0, x_size, y_size);
    495506    CHECK_GL_ERROR("OnSize", "glViewport");