1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | from __future__ import print_function
|
---|
7 | import sys
|
---|
8 |
|
---|
9 | import apiutil
|
---|
10 |
|
---|
11 |
|
---|
12 | apiutil.CopyrightC()
|
---|
13 |
|
---|
14 | print("""
|
---|
15 | /* DO NOT EDIT - generated by feedback.py */
|
---|
16 | #include <stdio.h>
|
---|
17 | #include "cr_spu.h"
|
---|
18 | #include "feedbackspu.h"
|
---|
19 | #include "feedbackspu_proto.h"
|
---|
20 | #include "cr_packfunctions.h"
|
---|
21 | #include "cr_glstate.h"
|
---|
22 |
|
---|
23 | """)
|
---|
24 |
|
---|
25 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
26 |
|
---|
27 | for func_name in keys:
|
---|
28 | return_type = apiutil.ReturnType(func_name)
|
---|
29 | params = apiutil.Parameters(func_name)
|
---|
30 | if apiutil.FindSpecial( "feedback", func_name ):
|
---|
31 | print('static %s FEEDBACKSPU_APIENTRY feedbackspu_%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params) ))
|
---|
32 | print('{')
|
---|
33 | print('\tfeedback_spu.super.%s(%s);' % ( func_name, apiutil.MakeCallString(params) ))
|
---|
34 | print('}')
|
---|
35 | print('')
|
---|
36 | print('static %s FEEDBACKSPU_APIENTRY feedbackspu_FeedbackWrap%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params) ))
|
---|
37 | print('{')
|
---|
38 | if len(params) == 0:
|
---|
39 | print('\tcrStateFeedback%s(&feedback_spu.StateTracker);' % ( func_name, ))
|
---|
40 | else:
|
---|
41 | print('\tcrStateFeedback%s(&feedback_spu.StateTracker, %s);' % ( func_name, apiutil.MakeCallString(params) ))
|
---|
42 | print('}')
|
---|
43 | if apiutil.FindSpecial( "select", func_name ):
|
---|
44 | print('static %s FEEDBACKSPU_APIENTRY feedbackspu_SelectWrap%s(%s)' % ( return_type, func_name, apiutil.MakeDeclarationString(params) ))
|
---|
45 | print('{')
|
---|
46 | if len(params) == 0:
|
---|
47 | print('\tcrStateSelect%s(&feedback_spu.StateTracker);' % ( func_name, ))
|
---|
48 | else:
|
---|
49 | print('\tcrStateSelect%s(&feedback_spu.StateTracker, %s);' % ( func_name, apiutil.MakeCallString(params) ))
|
---|
50 | print('}')
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | print("""
|
---|
55 | #define CHANGE(name, func) crSPUChangeInterface((void *)&(feedback_spu.self), (void *)feedback_spu.self.name, (void *)((SPUGenericFunction) func))
|
---|
56 |
|
---|
57 | static void __loadFeedbackAPI( void )
|
---|
58 | {
|
---|
59 | """)
|
---|
60 | for func_name in keys:
|
---|
61 | return_type = apiutil.ReturnType(func_name)
|
---|
62 | params = apiutil.Parameters(func_name)
|
---|
63 | if apiutil.FindSpecial( "feedback", func_name ):
|
---|
64 | print('\tCHANGE(%s, feedbackspu_FeedbackWrap%s);' % (func_name, func_name ))
|
---|
65 | print("""
|
---|
66 | }
|
---|
67 |
|
---|
68 | static void __loadSelectAPI( void )
|
---|
69 | {
|
---|
70 | """)
|
---|
71 | for func_name in keys:
|
---|
72 | if apiutil.FindSpecial( "select", func_name ):
|
---|
73 | print('\tCHANGE(%s, feedbackspu_SelectWrap%s);' % (func_name, func_name ))
|
---|
74 | elif apiutil.FindSpecial( "feedback", func_name ):
|
---|
75 | print('\tCHANGE(%s, feedbackspu_%s);' % (func_name, func_name ))
|
---|
76 | print("""
|
---|
77 | }
|
---|
78 |
|
---|
79 | static void __loadRenderAPI( void )
|
---|
80 | {
|
---|
81 | """)
|
---|
82 |
|
---|
83 | for func_name in keys:
|
---|
84 | return_type = apiutil.ReturnType(func_name)
|
---|
85 | if apiutil.FindSpecial( "feedback", func_name ) or apiutil.FindSpecial( "select", func_name ):
|
---|
86 | print('\tCHANGE(%s, feedbackspu_%s);' % (func_name, func_name ))
|
---|
87 | print("""
|
---|
88 | }
|
---|
89 | """)
|
---|
90 |
|
---|
91 | print("""
|
---|
92 | static GLint FEEDBACKSPU_APIENTRY feedbackspu_RenderMode ( GLenum mode )
|
---|
93 | {
|
---|
94 | feedback_spu.render_mode = mode;
|
---|
95 |
|
---|
96 | switch (mode) {
|
---|
97 | case GL_FEEDBACK:
|
---|
98 | /*printf("Switching to Feedback API\\n");*/
|
---|
99 | __loadFeedbackAPI( );
|
---|
100 | break;
|
---|
101 | case GL_SELECT:
|
---|
102 | /*printf("Switching to Selection API\\n");*/
|
---|
103 | __loadSelectAPI( );
|
---|
104 | break;
|
---|
105 | case GL_RENDER:
|
---|
106 | /*printf("Switching to Render API\\n");*/
|
---|
107 | __loadRenderAPI( );
|
---|
108 | break;
|
---|
109 | }
|
---|
110 |
|
---|
111 | return crStateRenderMode(&feedback_spu.StateTracker, mode );
|
---|
112 | }
|
---|
113 |
|
---|
114 | static void FEEDBACKSPU_APIENTRY feedbackspu_Begin ( GLenum mode )
|
---|
115 | {
|
---|
116 | if (feedback_spu.render_mode == GL_FEEDBACK)
|
---|
117 | crStateFeedbackBegin(&feedback_spu.StateTracker, mode );
|
---|
118 | else if (feedback_spu.render_mode == GL_SELECT)
|
---|
119 | crStateSelectBegin(&feedback_spu.StateTracker, mode );
|
---|
120 | else
|
---|
121 | {
|
---|
122 | crStateBegin(&feedback_spu.StateTracker, mode );
|
---|
123 | feedback_spu.super.Begin( mode );
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | static void FEEDBACKSPU_APIENTRY feedbackspu_End ( void )
|
---|
128 | {
|
---|
129 | if (feedback_spu.render_mode == GL_FEEDBACK)
|
---|
130 | crStateFeedbackEnd(&feedback_spu.StateTracker);
|
---|
131 | else if (feedback_spu.render_mode == GL_SELECT)
|
---|
132 | crStateSelectEnd(&feedback_spu.StateTracker);
|
---|
133 | else
|
---|
134 | {
|
---|
135 | crStateEnd(&feedback_spu.StateTracker);
|
---|
136 | feedback_spu.super.End( );
|
---|
137 | }
|
---|
138 | }
|
---|
139 |
|
---|
140 | static void FEEDBACKSPU_APIENTRY feedbackspu_Bitmap ( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap )
|
---|
141 | {
|
---|
142 | crStateBitmap(&feedback_spu.StateTracker, width, height, xorig, yorig, xmove, ymove, bitmap );
|
---|
143 |
|
---|
144 | if (feedback_spu.render_mode == GL_FEEDBACK)
|
---|
145 | crStateFeedbackBitmap(&feedback_spu.StateTracker, width, height, xorig, yorig, xmove, ymove, bitmap );
|
---|
146 | else if (feedback_spu.render_mode == GL_SELECT)
|
---|
147 | crStateSelectBitmap(&feedback_spu.StateTracker, width, height, xorig, yorig, xmove, ymove, bitmap );
|
---|
148 | else
|
---|
149 | feedback_spu.super.Bitmap( width, height, xorig, yorig, xmove, ymove, bitmap );
|
---|
150 | }
|
---|
151 |
|
---|
152 | static void FEEDBACKSPU_APIENTRY feedbackspu_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type )
|
---|
153 | {
|
---|
154 | if (feedback_spu.render_mode == GL_FEEDBACK)
|
---|
155 | crStateFeedbackCopyPixels(&feedback_spu.StateTracker, x, y, width, height, type );
|
---|
156 | else if (feedback_spu.render_mode == GL_SELECT)
|
---|
157 | crStateSelectCopyPixels(&feedback_spu.StateTracker, x, y, width, height, type );
|
---|
158 | else
|
---|
159 | feedback_spu.super.CopyPixels( x, y, width, height, type );
|
---|
160 | }
|
---|
161 |
|
---|
162 | static void FEEDBACKSPU_APIENTRY feedbackspu_DrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
|
---|
163 | {
|
---|
164 | if (feedback_spu.render_mode == GL_FEEDBACK)
|
---|
165 | crStateFeedbackDrawPixels(&feedback_spu.StateTracker, width, height, format, type, pixels );
|
---|
166 | else if (feedback_spu.render_mode == GL_SELECT)
|
---|
167 | crStateSelectDrawPixels(&feedback_spu.StateTracker, width, height, format, type, pixels );
|
---|
168 | else
|
---|
169 | feedback_spu.super.DrawPixels( width, height, format, type, pixels );
|
---|
170 | }
|
---|
171 |
|
---|
172 | static void FEEDBACKSPU_APIENTRY feedbackspu_GetBooleanv( GLenum pname, GLboolean *params )
|
---|
173 |
|
---|
174 | {
|
---|
175 | if (pname == GL_FEEDBACK_BUFFER_SIZE ||
|
---|
176 | pname == GL_FEEDBACK_BUFFER_TYPE ||
|
---|
177 | pname == GL_SELECTION_BUFFER_SIZE)
|
---|
178 | crStateFeedbackGetBooleanv(&feedback_spu.StateTracker, pname, params );
|
---|
179 | else
|
---|
180 | if (pname == GL_VIEWPORT && feedback_spu.default_viewport)
|
---|
181 | crStateGetBooleanv(&feedback_spu.StateTracker, pname, params );
|
---|
182 | else
|
---|
183 | feedback_spu.super.GetBooleanv( pname, params );
|
---|
184 | }
|
---|
185 |
|
---|
186 | static void FEEDBACKSPU_APIENTRY feedbackspu_GetDoublev( GLenum pname, GLdouble *params )
|
---|
187 |
|
---|
188 | {
|
---|
189 | if (pname == GL_FEEDBACK_BUFFER_SIZE ||
|
---|
190 | pname == GL_FEEDBACK_BUFFER_TYPE ||
|
---|
191 | pname == GL_SELECTION_BUFFER_SIZE)
|
---|
192 | crStateFeedbackGetDoublev(&feedback_spu.StateTracker, pname, params );
|
---|
193 | else
|
---|
194 | if (pname == GL_VIEWPORT && feedback_spu.default_viewport)
|
---|
195 | crStateGetDoublev(&feedback_spu.StateTracker, pname, params );
|
---|
196 | else
|
---|
197 | feedback_spu.super.GetDoublev( pname, params );
|
---|
198 | }
|
---|
199 |
|
---|
200 | static void FEEDBACKSPU_APIENTRY feedbackspu_GetFloatv( GLenum pname, GLfloat *params )
|
---|
201 |
|
---|
202 | {
|
---|
203 | if (pname == GL_FEEDBACK_BUFFER_SIZE ||
|
---|
204 | pname == GL_FEEDBACK_BUFFER_TYPE ||
|
---|
205 | pname == GL_SELECTION_BUFFER_SIZE)
|
---|
206 | crStateFeedbackGetFloatv(&feedback_spu.StateTracker, pname, params );
|
---|
207 | else
|
---|
208 | if (pname == GL_VIEWPORT && feedback_spu.default_viewport)
|
---|
209 | crStateGetFloatv(&feedback_spu.StateTracker, pname, params );
|
---|
210 | else
|
---|
211 | feedback_spu.super.GetFloatv( pname, params );
|
---|
212 | }
|
---|
213 |
|
---|
214 | static void FEEDBACKSPU_APIENTRY feedbackspu_GetIntegerv( GLenum pname, GLint *params )
|
---|
215 |
|
---|
216 | {
|
---|
217 | if (pname == GL_FEEDBACK_BUFFER_SIZE ||
|
---|
218 | pname == GL_FEEDBACK_BUFFER_TYPE ||
|
---|
219 | pname == GL_SELECTION_BUFFER_SIZE)
|
---|
220 | crStateFeedbackGetIntegerv(&feedback_spu.StateTracker, pname, params );
|
---|
221 | else
|
---|
222 | if (pname == GL_VIEWPORT && feedback_spu.default_viewport)
|
---|
223 | crStateGetIntegerv(&feedback_spu.StateTracker, pname, params );
|
---|
224 | else
|
---|
225 | feedback_spu.super.GetIntegerv( pname, params );
|
---|
226 | }
|
---|
227 |
|
---|
228 | SPUNamedFunctionTable _cr_feedback_table[] = {
|
---|
229 | """)
|
---|
230 |
|
---|
231 | for func_name in keys:
|
---|
232 | if apiutil.FindSpecial( "feedback_state", func_name ):
|
---|
233 | print('\t{ "%s", (SPUGenericFunction) feedbackspu_%s }, ' % ( func_name, func_name ))
|
---|
234 | print("""
|
---|
235 | { "GetBooleanv", (SPUGenericFunction) feedbackspu_GetBooleanv },
|
---|
236 | { "GetDoublev", (SPUGenericFunction) feedbackspu_GetDoublev },
|
---|
237 | { "GetFloatv", (SPUGenericFunction) feedbackspu_GetFloatv },
|
---|
238 | { "GetIntegerv", (SPUGenericFunction) feedbackspu_GetIntegerv },
|
---|
239 | { "FeedbackBuffer", (SPUGenericFunction) crStateFeedbackBuffer },
|
---|
240 | { "SelectBuffer", (SPUGenericFunction) crStateSelectBuffer },
|
---|
241 | { "InitNames", (SPUGenericFunction) crStateInitNames },
|
---|
242 | { "LoadName", (SPUGenericFunction) crStateLoadName },
|
---|
243 | { "PushName", (SPUGenericFunction) crStatePushName },
|
---|
244 | { "PopName", (SPUGenericFunction) crStatePopName },
|
---|
245 | { "Begin", (SPUGenericFunction) feedbackspu_Begin },
|
---|
246 | { "End", (SPUGenericFunction) feedbackspu_End },
|
---|
247 | { "Bitmap", (SPUGenericFunction) feedbackspu_Bitmap },
|
---|
248 | { "CopyPixels", (SPUGenericFunction) feedbackspu_CopyPixels },
|
---|
249 | { "DrawPixels", (SPUGenericFunction) feedbackspu_DrawPixels },
|
---|
250 | { "TexCoord1d", (SPUGenericFunction) feedbackspu_TexCoord1d },
|
---|
251 | { "TexCoord1dv", (SPUGenericFunction) feedbackspu_TexCoord1dv },
|
---|
252 | { "TexCoord1f", (SPUGenericFunction) feedbackspu_TexCoord1f },
|
---|
253 | { "TexCoord1fv", (SPUGenericFunction) feedbackspu_TexCoord1fv },
|
---|
254 | { "TexCoord1s", (SPUGenericFunction) feedbackspu_TexCoord1s },
|
---|
255 | { "TexCoord1sv", (SPUGenericFunction) feedbackspu_TexCoord1sv },
|
---|
256 | { "TexCoord1i", (SPUGenericFunction) feedbackspu_TexCoord1i },
|
---|
257 | { "TexCoord1iv", (SPUGenericFunction) feedbackspu_TexCoord1iv },
|
---|
258 | { "TexCoord2d", (SPUGenericFunction) feedbackspu_TexCoord2d },
|
---|
259 | { "TexCoord2dv", (SPUGenericFunction) feedbackspu_TexCoord2dv },
|
---|
260 | { "TexCoord2f", (SPUGenericFunction) feedbackspu_TexCoord2f },
|
---|
261 | { "TexCoord2fv", (SPUGenericFunction) feedbackspu_TexCoord2fv },
|
---|
262 | { "TexCoord2s", (SPUGenericFunction) feedbackspu_TexCoord2s },
|
---|
263 | { "TexCoord2sv", (SPUGenericFunction) feedbackspu_TexCoord2sv },
|
---|
264 | { "TexCoord2i", (SPUGenericFunction) feedbackspu_TexCoord2i },
|
---|
265 | { "TexCoord2iv", (SPUGenericFunction) feedbackspu_TexCoord2iv },
|
---|
266 | { "TexCoord3d", (SPUGenericFunction) feedbackspu_TexCoord3d },
|
---|
267 | { "TexCoord3dv", (SPUGenericFunction) feedbackspu_TexCoord3dv },
|
---|
268 | { "TexCoord3f", (SPUGenericFunction) feedbackspu_TexCoord3f },
|
---|
269 | { "TexCoord3fv", (SPUGenericFunction) feedbackspu_TexCoord3fv },
|
---|
270 | { "TexCoord3s", (SPUGenericFunction) feedbackspu_TexCoord3s },
|
---|
271 | { "TexCoord3sv", (SPUGenericFunction) feedbackspu_TexCoord3sv },
|
---|
272 | { "TexCoord3i", (SPUGenericFunction) feedbackspu_TexCoord3i },
|
---|
273 | { "TexCoord3iv", (SPUGenericFunction) feedbackspu_TexCoord3iv },
|
---|
274 | { "TexCoord4d", (SPUGenericFunction) feedbackspu_TexCoord4d },
|
---|
275 | { "TexCoord4dv", (SPUGenericFunction) feedbackspu_TexCoord4dv },
|
---|
276 | { "TexCoord4f", (SPUGenericFunction) feedbackspu_TexCoord4f },
|
---|
277 | { "TexCoord4fv", (SPUGenericFunction) feedbackspu_TexCoord4fv },
|
---|
278 | { "TexCoord4s", (SPUGenericFunction) feedbackspu_TexCoord4s },
|
---|
279 | { "TexCoord4sv", (SPUGenericFunction) feedbackspu_TexCoord4sv },
|
---|
280 | { "TexCoord4i", (SPUGenericFunction) feedbackspu_TexCoord4i },
|
---|
281 | { "TexCoord4iv", (SPUGenericFunction) feedbackspu_TexCoord4iv },
|
---|
282 | { "RenderMode", (SPUGenericFunction) feedbackspu_RenderMode },
|
---|
283 | { NULL, NULL }
|
---|
284 | };
|
---|
285 | """)
|
---|