]> Dogcows Code - chaz/yoink/blob - src/Moof/OpenGL.hh
removed logging from script to fix compile error
[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 #include <SDL/SDL_opengl.h>
16
17 #include <Moof/Math.hh>
18
19 #if HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23
24 // generic function arguments
25
26 #define ARGS_P const GLscalar* p
27 #define PASS_P p
28
29 #define ARGS_M const Mf::Matrix4& m
30 #define PASS_M m.data()
31
32 // ordinal function arguments
33
34 #define ARGS_S2 GLscalar a, GLscalar b
35 #define PASS_S2 a, b
36 #define ARGS_S3 GLscalar a, GLscalar b, GLscalar c
37 #define PASS_S3 a, b, c
38 #define ARGS_S4 GLscalar a, GLscalar b, GLscalar c, GLscalar d
39 #define PASS_S4 a, b, c, d
40
41 #define ARGS_P2 const Mf::Vector2& p
42 #define PASS_P2 p.data()
43 #define ARGS_P3 const Mf::Vector3& p
44 #define PASS_P3 p.data()
45 #define ARGS_P4 const Mf::Vector4& p
46 #define PASS_P4 p.data()
47
48 #define ARGS_V2 const Mf::Vector2& v
49 #define PASS_V2 v[0], v[1]
50 #define ARGS_V3 const Mf::Vector3& v
51 #define PASS_V3 v[0], v[1], v[2]
52 #define ARGS_V4 const Mf::Vector4& v
53 #define PASS_V4 v[0], v[1], v[2], v[3]
54
55
56 #if USE_DOUBLE_PRECISION
57
58 #define OPENGL_GENERIC_FUNC(R, N, L) \
59 inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
60
61 #define OPENGL_ORDINAL_FUNC(R, N, K) \
62 inline R gl##N(ARGS_##S##K) { gl##N##K##d(PASS_##S##K); } \
63 inline R gl##N(ARGS_##P##K) { gl##N##K##d##v(PASS_##P##K); }//
64
65 #else
66
67 #define OPENGL_GENERIC_FUNC(R, N, L) \
68 inline R gl##N(ARGS_##L) { gl##N##f(PASS_##L); }//
69
70 #define OPENGL_ORDINAL_FUNC(R, N, K) \
71 inline R gl##N(ARGS_##S##K) { gl##N##K##f(PASS_##S##K); } \
72 inline R gl##N(ARGS_##P##K) { gl##N##K##f##v(PASS_##P##K); }//
73
74 #endif
75
76
77 OPENGL_GENERIC_FUNC(void, LoadMatrix, P);
78 OPENGL_GENERIC_FUNC(void, LoadMatrix, M);
79 OPENGL_GENERIC_FUNC(void, MultMatrix, P);
80 OPENGL_GENERIC_FUNC(void, MultMatrix, M);
81
82 OPENGL_GENERIC_FUNC(void, Scale, S3);
83 OPENGL_GENERIC_FUNC(void, Scale, V3);
84 OPENGL_GENERIC_FUNC(void, Rotate, S4);
85 OPENGL_GENERIC_FUNC(void, Rotate, V4);
86 OPENGL_GENERIC_FUNC(void, Translate, S3);
87 OPENGL_GENERIC_FUNC(void, Translate, V3);
88
89 OPENGL_ORDINAL_FUNC(void, Color, 3);
90 OPENGL_ORDINAL_FUNC(void, Color, 4);
91
92 OPENGL_ORDINAL_FUNC(void, Vertex, 2);
93 OPENGL_ORDINAL_FUNC(void, Vertex, 3);
94 OPENGL_ORDINAL_FUNC(void, Vertex, 4);
95
96 OPENGL_ORDINAL_FUNC(void, TexCoord, 2);
97 OPENGL_ORDINAL_FUNC(void, TexCoord, 3);
98 OPENGL_ORDINAL_FUNC(void, TexCoord, 4);
99
100 OPENGL_GENERIC_FUNC(void, Rect, S4);
101 OPENGL_GENERIC_FUNC(void, Rect, V4);
102
103
104 #if USE_DOUBLE_PRECISION
105 inline void glGetScalar(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
106 #else
107 inline void glGetScalar(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
108 #endif
109
110
111 #endif // _MOOF_OPENGL_HH_
112
This page took 0.035531 seconds and 4 git commands to generate.