]>
Dogcows Code - chaz/yoink/blob - src/Moof/OpenGL.hh
2 /*******************************************************************************
4 Copyright (c) 2009, Charles McGarvey
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
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.
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.
27 *******************************************************************************/
29 #ifndef _MOOF_OPENGL_HH_
30 #define _MOOF_OPENGL_HH_
32 #include <SDL/SDL_opengl.h>
34 #include <Moof/Math.hh>
41 // generic function arguments
43 #define ARGS_P const GLscalar* p
46 #define ARGS_M const Mf::Matrix4& m
47 #define PASS_M m.data()
49 // ordinal function arguments
51 #define ARGS_S2 GLscalar a, GLscalar 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
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()
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]
73 #if USE_DOUBLE_PRECISION
75 #define OPENGL_GENERIC_FUNC(R, N, L) \
76 inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
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); }//
84 #define OPENGL_GENERIC_FUNC(R, N, L) \
85 inline R gl##N(ARGS_##L) { gl##N##f(PASS_##L); }//
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); }//
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
);
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
);
106 OPENGL_ORDINAL_FUNC(void, Color
, 3);
107 OPENGL_ORDINAL_FUNC(void, Color
, 4);
109 OPENGL_ORDINAL_FUNC(void, Vertex
, 2);
110 OPENGL_ORDINAL_FUNC(void, Vertex
, 3);
111 OPENGL_ORDINAL_FUNC(void, Vertex
, 4);
113 OPENGL_ORDINAL_FUNC(void, TexCoord
, 2);
114 OPENGL_ORDINAL_FUNC(void, TexCoord
, 3);
115 OPENGL_ORDINAL_FUNC(void, TexCoord
, 4);
118 #if USE_DOUBLE_PRECISION
119 inline void glGetScalar(GLenum a
, GLscalar
* b
) { glGetDoublev(a
, b
); }
121 inline void glGetScalar(GLenum a
, GLscalar
* b
) { glGetFloatv(a
, b
); }
125 #endif // _MOOF_OPENGL_HH_
127 /** vim: set ts=4 sw=4 tw=80: *************************************************/
This page took 0.042965 seconds and 4 git commands to generate.