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