OpenStructure
Loading...
Searching...
No Matches
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-2020 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/*
20Author: 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
42inline 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
54inline void glVertex3v(double* v){
55 glVertex3dv(v);
56}
57
58inline void glVertex3v(const double* v){
59 glVertex3dv(v);
60}
61
62inline void glVertex3v(float* v){
63 glVertex3fv(v);
64}
65
66
67inline void glVertex3v(const float* v){
68 glVertex3fv(v);
69}
70
71inline void glVertex3(const geom::Vec3& v)
72{
73 glVertex3v(&v[0]);
74}
75
76inline void glMultMatrix(float* v) {
77 glMultMatrixf(v);
78}
79
80inline void glMultMatrix(double* v) {
81 glMultMatrixd(v);
82}
83
84inline void glNormal3v(double* v){
85 glNormal3dv(v);
86}
87
88inline void glNormal3v(float* v){
89 glNormal3fv(v);
90}
91
92inline void glTexCoord2v(float* v){
93 glTexCoord2fv(v);
94}
95
96inline void glTexCoord2v(double* v){
97 glTexCoord2dv(v);
98}
99
100
101inline void glGetv(GLenum pname, double* v){
102 glGetDoublev(pname, v);
103}
104
105inline void glGetv(GLenum pname, float* v){
106 glGetFloatv(pname, v);
107}
108
109
110inline void glLoadMatrix(float* arr) {
111 glLoadMatrixf(arr);
112}
113
114inline void glLoadMatrix(double* arr) {
115 glLoadMatrixd(arr);
116}
117
118#if OST_SHADER_SUPPORT_ENABLED
119
120inline void glLoadTransposeMatrix(float* arr) {
121 glLoadTransposeMatrixf(arr);
122}
123
124inline void glLoadTransposeMatrix(double* arr) {
125 glLoadTransposeMatrixd(arr);
126}
127
128#endif
129
130#endif
Three dimensional vector class, using Real precision.
Definition vec3.hh:48
void glVertex3v(double *v)
Definition gl_helper.hh:54
void glVertex3(const geom::Vec3 &v)
Definition gl_helper.hh:71
void glGetv(GLenum pname, double *v)
Definition gl_helper.hh:101
void glNormal3v(double *v)
Definition gl_helper.hh:84
void glMultMatrix(float *v)
Definition gl_helper.hh:76
void glLoadMatrix(float *arr)
Definition gl_helper.hh:110
void check_gl_error(const std::string &m="")
Definition gl_helper.hh:42
void glTexCoord2v(float *v)
Definition gl_helper.hh:92
#define LOG_VERBOSE(m)
Definition log.hh:88