Stellarium 0.15.2
StelOpenGL.hpp
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 
38 namespace StelOpenGL
39 {
41  extern QOpenGLContext* mainContext;
42 
44  const char* getGLErrorText(GLenum code);
46  int checkGLErrors(const char *file, int line);
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_
QOpenGLContext * mainContext
The main context as created by the StelMainView (only used for debugging)
int checkGLErrors(const char *file, int line)
Retrieves and prints all current OpenGL errors to console (glGetError in a loop)
void clearGLErrors()
Clears all queued-up OpenGL errors without handling them.
Namespace containing some OpenGL helpers.
Definition: StelOpenGL.hpp:38
const char * getGLErrorText(GLenum code)
Converts a GLenum from glGetError to a string.
Definition: inftrees.h:24