nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 #include "GLResource.h" 00023 #include "FontTexture.h" 00024 #include "GLError.h" 00025 00026 namespace nux 00027 { 00028 #ifdef NUX_DEBUG 00029 static bool bBreakOnGLErrors = FALSE; 00030 #endif 00031 00032 // WARNING: never call glGetError between glBegin and glEnd. 00033 int CheckGLError (const TCHAR *GLcall, const TCHAR *file, int line) 00034 { 00035 GLenum glErr; 00036 int retCode = 0; 00037 00038 while ( (glErr = glGetError() ) != GL_NO_ERROR) 00039 { 00040 00041 switch (glErr) 00042 { 00043 case GL_INVALID_ENUM: 00044 nuxWarningMsg (TEXT ("[CheckGLError] GL_INVALID_ENUM error in File %s at line: %d"), file, line); 00045 break; 00046 case GL_INVALID_VALUE: 00047 nuxWarningMsg (TEXT ("[CheckGLError] GL_INVALID_VALUE error in File %s at line: %d"), file, line); 00048 break; 00049 case GL_INVALID_OPERATION: 00050 nuxWarningMsg (TEXT ("[CheckGLError] GL_INVALID_OPERATION error in File %s at line: %d"), file, line); 00051 break; 00052 case GL_STACK_OVERFLOW: 00053 nuxWarningMsg (TEXT ("[CheckGLError] GL_STACK_OVERFLOW error in File %s at line: %d"), file, line); 00054 break; 00055 case GL_STACK_UNDERFLOW: 00056 nuxWarningMsg (TEXT ("[CheckGLError] GL_STACK_UNDERFLOW error in File %s at line: %d"), file, line); 00057 break; 00058 case GL_OUT_OF_MEMORY: 00059 nuxWarningMsg (TEXT ("[CheckGLError] GL_OUT_OF_MEMORY error in File %s at line: %d"), file, line); 00060 break; 00061 default: 00062 nuxWarningMsg (TEXT ("[CheckGLError] UNKNOWN ERROR in File %s at line: %d"), file, line); 00063 } 00064 00065 nuxWarningMsg (TEXT ("[CheckGLError] OpenGL Error %d ( %s ) in File %s at line: %d \n"), glErr, ANSI_TO_TCHAR (gluErrorString (glErr) ), ANSI_TO_TCHAR (file), line); 00066 retCode = 1; 00067 00068 #ifdef NUX_DEBUG 00069 00070 // break on errors if asked to 00071 if (bBreakOnGLErrors) 00072 #endif 00073 inlDebugBreak(); 00074 } 00075 00076 return retCode; 00077 } 00078 00079 }