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()
43 {
44  GLenum error_code;
45  if((error_code=glGetError())!=GL_NO_ERROR) {
46  LOG_VERBOSE("GL error: " << gluErrorString(error_code));
47  }
48 }
49 
50 inline void glVertex3v(double* v){
51  glVertex3dv(v);
52 }
53 
54 inline void glVertex3v(const double* v){
55  glVertex3dv(v);
56 }
57 
58 inline void glVertex3v(float* v){
59  glVertex3fv(v);
60 }
61 
62 
63 inline void glVertex3v(const float* v){
64  glVertex3fv(v);
65 }
66 
67 inline void glVertex3(const geom::Vec3& v)
68 {
69  glVertex3v(&v[0]);
70 }
71 
72 inline void glMultMatrix(float* v) {
73  glMultMatrixf(v);
74 }
75 
76 inline void glMultMatrix(double* v) {
77  glMultMatrixd(v);
78 }
79 
80 inline void glNormal3v(double* v){
81  glNormal3dv(v);
82 }
83 
84 inline void glNormal3v(float* v){
85  glNormal3fv(v);
86 }
87 
88 inline void glTexCoord2v(float* v){
89  glTexCoord2fv(v);
90 }
91 
92 inline void glTexCoord2v(double* v){
93  glTexCoord2dv(v);
94 }
95 
96 
97 inline void glGetv(GLenum pname, double* v){
98  glGetDoublev(pname, v);
99 }
100 
101 inline void glGetv(GLenum pname, float* v){
102  glGetFloatv(pname, v);
103 }
104 
105 
106 inline void glLoadMatrix(float* arr) {
107  glLoadMatrixf(arr);
108 }
109 
110 inline void glLoadMatrix(double* arr) {
111  glLoadMatrixd(arr);
112 }
113 
114 #if OST_SHADER_SUPPORT_ENABLED
115 
116 inline void glLoadTransposeMatrix(float* arr) {
117  glLoadTransposeMatrixf(arr);
118 }
119 
120 inline void glLoadTransposeMatrix(double* arr) {
121  glLoadTransposeMatrixd(arr);
122 }
123 
124 #endif
125 
126 #endif