OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gl_helper.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 /*
20 Author: Juergen Haas
21 */
22 
23 #ifndef OST_GFX_GL_HELPER_HH
24 #define OST_GFX_GL_HELPER_HH
25 
26 /*
27  must be included before any other gfx headers for gl and glext to
28  be correctly
29 */
30 #ifdef OST_GFX_GLEXT_INCLUDE_HH
31 #error gl_helper.hh must be included before any occurence of glext_include.hh
32 #endif
33 #ifdef OST_GFX_GL_INCLUDE_HH
34 #error gl_helper.hh must be included before any occurence of gl_include.hh
35 #endif
36 #include <ost/geom/vec3.hh>
37 
38 #include "glext_include.hh"
39 
40 #include <ost/log.hh>
41 
42 inline void check_gl_error(const std::string& m="")
43 {
44  #ifndef NDEBUG
45  GLenum error_code;
46  if((error_code=glGetError())!=GL_NO_ERROR) {
47  if(!m.empty()) {
48  LOG_VERBOSE("GL error in [" << m << "]: " << gluErrorString(error_code));
49  }
50  }
51  #endif
52 }
53 
54 inline void glVertex3v(double* v){
55  glVertex3dv(v);
56 }
57 
58 inline void glVertex3v(const double* v){
59  glVertex3dv(v);
60 }
61 
62 inline void glVertex3v(float* v){
63  glVertex3fv(v);
64 }
65 
66 
67 inline void glVertex3v(const float* v){
68  glVertex3fv(v);
69 }
70 
71 inline void glVertex3(const geom::Vec3& v)
72 {
73  glVertex3v(&v[0]);
74 }
75 
76 inline void glMultMatrix(float* v) {
77  glMultMatrixf(v);
78 }
79 
80 inline void glMultMatrix(double* v) {
81  glMultMatrixd(v);
82 }
83 
84 inline void glNormal3v(double* v){
85  glNormal3dv(v);
86 }
87 
88 inline void glNormal3v(float* v){
89  glNormal3fv(v);
90 }
91 
92 inline void glTexCoord2v(float* v){
93  glTexCoord2fv(v);
94 }
95 
96 inline void glTexCoord2v(double* v){
97  glTexCoord2dv(v);
98 }
99 
100 
101 inline void glGetv(GLenum pname, double* v){
102  glGetDoublev(pname, v);
103 }
104 
105 inline void glGetv(GLenum pname, float* v){
106  glGetFloatv(pname, v);
107 }
108 
109 
110 inline void glLoadMatrix(float* arr) {
111  glLoadMatrixf(arr);
112 }
113 
114 inline void glLoadMatrix(double* arr) {
115  glLoadMatrixd(arr);
116 }
117 
118 #if OST_SHADER_SUPPORT_ENABLED
119 
120 inline void glLoadTransposeMatrix(float* arr) {
121  glLoadTransposeMatrixf(arr);
122 }
123 
124 inline void glLoadTransposeMatrix(double* arr) {
125  glLoadTransposeMatrixd(arr);
126 }
127 
128 #endif
129 
130 #endif