]> Dogcows Code - chaz/yoink/blob - src/Moof/OpenGL.hh
fixed permissions for stlplus files
[chaz/yoink] / src / Moof / OpenGL.hh
1
2 /*******************************************************************************
3
4 Copyright (c) 2009, Charles McGarvey
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 *******************************************************************************/
28
29 #ifndef _MOOF_OPENGL_HH_
30 #define _MOOF_OPENGL_HH_
31
32 #include <SDL/SDL_opengl.h>
33
34 #include <Moof/Math.hh>
35
36 #if HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40
41 // generic function arguments
42
43 #define ARGS_P const GLscalar* p
44 #define PASS_P p
45
46 #define ARGS_M const Mf::Matrix4& m
47 #define PASS_M m.data()
48
49 // ordinal function arguments
50
51 #define ARGS_S2 GLscalar a, GLscalar b
52 #define PASS_S2 a, b
53 #define ARGS_S3 GLscalar a, GLscalar b, GLscalar c
54 #define PASS_S3 a, b, c
55 #define ARGS_S4 GLscalar a, GLscalar b, GLscalar c, GLscalar d
56 #define PASS_S4 a, b, c, d
57
58 #define ARGS_P2 const Mf::Vector2& p
59 #define PASS_P2 p.data()
60 #define ARGS_P3 const Mf::Vector3& p
61 #define PASS_P3 p.data()
62 #define ARGS_P4 const Mf::Vector4& p
63 #define PASS_P4 p.data()
64
65 #define ARGS_V2 const Mf::Vector2& v
66 #define PASS_V2 v[0], v[1]
67 #define ARGS_V3 const Mf::Vector3& v
68 #define PASS_V3 v[0], v[1], v[2]
69 #define ARGS_V4 const Mf::Vector4& v
70 #define PASS_V4 v[0], v[1], v[2], v[3]
71
72
73 #if USE_DOUBLE_PRECISION
74
75 #define OPENGL_GENERIC_FUNC(R, N, L) \
76 inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
77
78 #define OPENGL_ORDINAL_FUNC(R, N, K) \
79 inline R gl##N(ARGS_##S##K) { gl##N##K##d(PASS_##S##K); } \
80 inline R gl##N(ARGS_##P##K) { gl##N##K##d##v(PASS_##P##K); }//
81
82 #else
83
84 #define OPENGL_GENERIC_FUNC(R, N, L) \
85 inline R gl##N(ARGS_##L) { gl##N##f(PASS_##L); }//
86
87 #define OPENGL_ORDINAL_FUNC(R, N, K) \
88 inline R gl##N(ARGS_##S##K) { gl##N##K##f(PASS_##S##K); } \
89 inline R gl##N(ARGS_##P##K) { gl##N##K##f##v(PASS_##P##K); }//
90
91 #endif
92
93
94 OPENGL_GENERIC_FUNC(void, LoadMatrix, P);
95 OPENGL_GENERIC_FUNC(void, LoadMatrix, M);
96 OPENGL_GENERIC_FUNC(void, MultMatrix, P);
97 OPENGL_GENERIC_FUNC(void, MultMatrix, M);
98
99 OPENGL_GENERIC_FUNC(void, Scale, S3);
100 OPENGL_GENERIC_FUNC(void, Scale, V3);
101 OPENGL_GENERIC_FUNC(void, Rotate, S4);
102 OPENGL_GENERIC_FUNC(void, Rotate, V4);
103 OPENGL_GENERIC_FUNC(void, Translate, S3);
104 OPENGL_GENERIC_FUNC(void, Translate, V3);
105
106 OPENGL_ORDINAL_FUNC(void, Color, 3);
107 OPENGL_ORDINAL_FUNC(void, Color, 4);
108
109 OPENGL_ORDINAL_FUNC(void, Vertex, 2);
110 OPENGL_ORDINAL_FUNC(void, Vertex, 3);
111 OPENGL_ORDINAL_FUNC(void, Vertex, 4);
112
113 OPENGL_ORDINAL_FUNC(void, TexCoord, 2);
114 OPENGL_ORDINAL_FUNC(void, TexCoord, 3);
115 OPENGL_ORDINAL_FUNC(void, TexCoord, 4);
116
117
118 #if USE_DOUBLE_PRECISION
119 inline void glGetScalar(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
120 #else
121 inline void glGetScalar(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
122 #endif
123
124
125 #endif // _MOOF_OPENGL_HH_
126
127 /** vim: set ts=4 sw=4 tw=80: *************************************************/
128
This page took 0.037568 seconds and 4 git commands to generate.