]> Dogcows Code - chaz/yoink/blob - src/moof/opengl.hh
configuration cleanup and bugfixes
[chaz/yoink] / src / moof / opengl.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_OPENGL_HH_
13 #define _MOOF_OPENGL_HH_
14
15 /**
16 * \file opengl.hh
17 * Defines macros for OpenGL functions that operate on scalars, vectors,
18 * and matrices.
19 */
20
21 #include "config.h"
22
23 #include <SDL/SDL_opengl.h>
24
25 #include <moof/math.hh>
26
27
28 // generic function arguments
29
30 #define ARGS_P const GLscalar* p
31 #define PASS_P p
32
33 #define ARGS_M const moof::matrix4& m
34 #define PASS_M m.data()
35
36 // ordinal function arguments
37
38 #define ARGS_S2 GLscalar a, GLscalar b
39 #define PASS_S2 a, b
40 #define ARGS_S3 GLscalar a, GLscalar b, GLscalar c
41 #define PASS_S3 a, b, c
42 #define ARGS_S4 GLscalar a, GLscalar b, GLscalar c, GLscalar d
43 #define PASS_S4 a, b, c, d
44
45 #define ARGS_P2 const moof::vector2& p
46 #define PASS_P2 p.data()
47 #define ARGS_P3 const moof::vector3& p
48 #define PASS_P3 p.data()
49 #define ARGS_P4 const moof::vector4& p
50 #define PASS_P4 p.data()
51
52 #define ARGS_V2 const moof::vector2& v
53 #define PASS_V2 v[0], v[1]
54 #define ARGS_V3 const moof::vector3& v
55 #define PASS_V3 v[0], v[1], v[2]
56 #define ARGS_V4 const moof::vector4& v
57 #define PASS_V4 v[0], v[1], v[2], v[3]
58
59
60 #if USE_DOUBLE_PRECISION
61
62 #define OPENGL_GENERIC_FUNC(R, N, L) \
63 inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
64
65 #define OPENGL_ORDINAL_FUNC(R, N, K) \
66 inline R gl##N(ARGS_##S##K) { gl##N##K##d(PASS_##S##K); } \
67 inline R gl##N(ARGS_##P##K) { gl##N##K##d##v(PASS_##P##K); }//
68
69 #else
70
71 #define OPENGL_GENERIC_FUNC(R, N, L) \
72 inline R gl##N(ARGS_##L) { gl##N##f(PASS_##L); }//
73
74 #define OPENGL_ORDINAL_FUNC(R, N, K) \
75 inline R gl##N(ARGS_##S##K) { gl##N##K##f(PASS_##S##K); } \
76 inline R gl##N(ARGS_##P##K) { gl##N##K##f##v(PASS_##P##K); }//
77
78 #endif
79
80
81 OPENGL_GENERIC_FUNC(void, LoadMatrix, P);
82 OPENGL_GENERIC_FUNC(void, LoadMatrix, M);
83 OPENGL_GENERIC_FUNC(void, MultMatrix, P);
84 OPENGL_GENERIC_FUNC(void, MultMatrix, M);
85
86 OPENGL_GENERIC_FUNC(void, Scale, S3);
87 OPENGL_GENERIC_FUNC(void, Scale, V3);
88 OPENGL_GENERIC_FUNC(void, Rotate, S4);
89 OPENGL_GENERIC_FUNC(void, Rotate, V4);
90 OPENGL_GENERIC_FUNC(void, Translate, S3);
91 OPENGL_GENERIC_FUNC(void, Translate, V3);
92
93 OPENGL_ORDINAL_FUNC(void, Color, 3);
94 OPENGL_ORDINAL_FUNC(void, Color, 4);
95
96 OPENGL_ORDINAL_FUNC(void, Vertex, 2);
97 OPENGL_ORDINAL_FUNC(void, Vertex, 3);
98 OPENGL_ORDINAL_FUNC(void, Vertex, 4);
99
100 OPENGL_ORDINAL_FUNC(void, TexCoord, 2);
101 OPENGL_ORDINAL_FUNC(void, TexCoord, 3);
102 OPENGL_ORDINAL_FUNC(void, TexCoord, 4);
103
104 OPENGL_GENERIC_FUNC(void, Rect, S4);
105 OPENGL_GENERIC_FUNC(void, Rect, V4);
106
107
108 #if USE_DOUBLE_PRECISION
109 inline void glGetScalar(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
110 #else
111 inline void glGetScalar(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
112 #endif
113
114
115 #endif // _MOOF_OPENGL_HH_
116
This page took 0.036046 seconds and 5 git commands to generate.