KiCad PCB EDA Suite
include/gal/opengl/utils.h File Reference
#include <string>

Go to the source code of this file.

Functions

int checkGlError (const std::string &aInfo, bool aThrow=true)
 Checks if one of recent OpenGL operations has failed. More...
 

Function Documentation

int checkGlError ( const std::string &  aInfo,
bool  aThrow = true 
)

Checks if one of recent OpenGL operations has failed.

If so, it displays appropriate message, starting with aInfo string to give more details.

Parameters
aInfois the beginning of the error message.
aThrowan exception is thrown when true, otherwise only an error message is displayed.
Returns
GL_NO_ERROR in case of no errors or one of GL_ constants returned by glGetError().

Definition at line 30 of file utils.cpp.

References DisplayError(), and Format().

Referenced by KIGFX::GPU_CACHED_MANAGER::BeginDrawing(), KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::OPENGL_COMPOSITOR::bindFb(), KIGFX::OPENGL_COMPOSITOR::CreateBuffer(), KIGFX::CACHED_CONTAINER::defragmentResize(), KIGFX::CACHED_CONTAINER::defragmentResizeMemcpy(), KIGFX::ANTIALIASING_SUPERSAMPLING::Init(), KIGFX::CACHED_CONTAINER::init(), KIGFX::OPENGL_COMPOSITOR::Initialize(), KIGFX::ANTIALIASING_SMAA::loadShaders(), KIGFX::CACHED_CONTAINER::Map(), KIGFX::ANTIALIASING_SUPERSAMPLING::Present(), KIGFX::ANTIALIASING_SMAA::Present(), KIGFX::OPENGL_COMPOSITOR::SetBuffer(), KIGFX::CACHED_CONTAINER::Unmap(), and KIGFX::ANTIALIASING_SMAA::updateUniforms().

31 {
32  int result = glGetError();
33  wxString errorMsg;
34 
35  switch( result )
36  {
37  case GL_NO_ERROR:
38  // all good
39  break;
40 
41  case GL_INVALID_ENUM:
42  errorMsg = wxString::Format( "Error: %s: invalid enum", aInfo );
43  break;
44 
45  case GL_INVALID_VALUE:
46  errorMsg = wxString::Format( "Error: %s: invalid value", aInfo );
47  break;
48 
49  case GL_INVALID_OPERATION:
50  errorMsg = wxString::Format( "Error: %s: invalid operation", aInfo );
51  break;
52 
53  case GL_INVALID_FRAMEBUFFER_OPERATION:
54  errorMsg = wxString::Format( "Error: %s: invalid framebuffer operation", aInfo );
55  break;
56 
57  case GL_OUT_OF_MEMORY:
58  errorMsg = wxString::Format( "Error: %s: out of memory", aInfo );
59  break;
60 
61  case GL_STACK_UNDERFLOW:
62  errorMsg = wxString::Format( "Error: %s: stack underflow", aInfo );
63  break;
64 
65  case GL_STACK_OVERFLOW:
66  errorMsg = wxString::Format( "Error: %s: stack overflow", aInfo );
67  break;
68 
69  default:
70  errorMsg = wxString::Format( "Error: %s: unknown error", aInfo );
71  break;
72  }
73 
74  if( result != GL_NO_ERROR )
75  {
76  if( aThrow )
77  throw std::runtime_error( (const char*) errorMsg.char_str() );
78  else
79  DisplayError( nullptr, errorMsg );
80  }
81 
82  return result;
83 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69