VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/feedback/feedback.py@ 76447

Last change on this file since 76447 was 63942, checked in by vboxsync, 8 years ago

OpenGL: fixed the most annoying coding style flaws, mainly removing spaces after '(' and before ')', no semantic change

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette