1 /* 2 * Stellarium 3 * Copyright (C) 2014 Fabien Chereau 4 * Copyright (C) 2016 Florian Schaukowitsch 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 19 */ 20 21 #ifndef STELOPENGL_HPP 22 #define STELOPENGL_HPP 23 24 #include <QOpenGLFunctions> 25 26 #ifndef QT_NO_DEBUG 27 # define GL(line) do { \ 28 /*for debugging, we make sure we use our main context*/\ 29 Q_ASSERT(StelOpenGL::mainContext == QOpenGLContext::currentContext());\ 30 line;\ 31 Q_ASSERT_X(!StelOpenGL::checkGLErrors(__FILE__, __LINE__), "GL macro", "OpenGL errors encountered");\ 32 } while(0) 33 #else 34 # define GL(line) line 35 #endif 36 37 //! Namespace containing some OpenGL helpers 38 namespace StelOpenGL 39 { 40 //! The main context as created by the StelMainView (only used for debugging) 41 extern QOpenGLContext* mainContext; 42 43 //! Converts a GLenum from glGetError to a string 44 const char* getGLErrorText(GLenum code); 45 //! Retrieves and prints all current OpenGL errors to console (glGetError in a loop). Returns number of errors. 46 int checkGLErrors(const char *file, int line); 47 //! Clears all queued-up OpenGL errors without handling them 48 void clearGLErrors(); 49 } 50 51 // This is still needed for the ARM platform (armhf) 52 53 #if defined(QT_OPENGL_ES_2) 54 #ifndef GL_DOUBLE 55 #define GL_DOUBLE GL_FLOAT 56 #endif 57 #endif 58 59 #endif // STELOPENGL_HPP 60