#include "PrimaryGLContext.h" #include "wx/wxprec.h" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #if !wxUSE_GLCANVAS #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library" #endif #include "CubicSDR.h" #include "CubicSDRDefs.h" #include "AppFrame.h" #include GLFont *PrimaryGLContext::font = NULL; wxString PrimaryGLContext::glGetwxString(GLenum name) { const GLubyte *v = glGetString(name); if (v == 0) { // The error is not important. It is GL_INVALID_ENUM. // We just want to clear the error stack. glGetError(); return wxString(); } return wxString((const char*) v); } void PrimaryGLContext::CheckGLError() { GLenum errLast = GL_NO_ERROR; for (;;) { GLenum err = glGetError(); if (err == GL_NO_ERROR) return; if (err == errLast) { wxLogError (wxT("OpenGL error state couldn't be reset.")); return; } errLast = err; wxLogError (wxT("OpenGL error %d"), err); } } PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContext) : wxGLContext(canvas, sharedContext) { SetCurrent(*canvas); CheckGLError(); } GLFont *PrimaryGLContext::getFont() { if (font == NULL) { font = new GLFont(); font->loadFont("vera_sans_mono.fnt"); } return font; }