1 /**************************************************************************** 2 * MeshLab o o * 3 * An extendible mesh processor o o * 4 * _ O _ * 5 * Copyright(C) 2005, 2009 \/)\/ * 6 * Visual Computing Lab /\/| * 7 * ISTI - Italian National Research Council | * 8 * \ * 9 * All rights reserved. * 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 * This program is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 20 * for more details. * 21 * * 22 ****************************************************************************/ 23 24 #pragma once 25 #include <QMessageBox> 26 class checkGLError 27 { 28 public: makeString(const char * m)29 static QString makeString(const char* m) 30 { 31 QString message(m); 32 33 switch(glGetError()) { 34 case GL_NO_ERROR: return QString(); 35 36 case GL_INVALID_ENUM: message+=("invalid enum"); break; 37 case GL_INVALID_VALUE: message+=("invalid value"); break; 38 case GL_INVALID_OPERATION: message+=("invalid operation"); break; 39 case GL_STACK_OVERFLOW: message+=("stack overflow"); break; 40 case GL_STACK_UNDERFLOW: message+=("stack underflow"); break; 41 case GL_OUT_OF_MEMORY: message+=("out of memory"); break; 42 case GL_INVALID_FRAMEBUFFER_OPERATION: message+=("invalid framebuffer operation"); break; 43 } 44 return message; 45 } 46 debugInfo(const char * m)47 static void debugInfo(const char* m) { 48 QString message=makeString(m); 49 if(message.isEmpty()) return; 50 ::qDebug("%s",qPrintable(message)); 51 } 52 QMessageBox(const char * m,const char * title)53 static void QMessageBox(const char* m, const char* title) { 54 QString message=makeString(m); 55 QMessageBox::warning(0, title,message); 56 } QMessageBox(const char * m)57 static void QMessageBox(const char* m) {QMessageBox(m,"GL error");} 58 }; 59 60