VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py@ 20509

Last change on this file since 20509 was 20083, checked in by vboxsync, 15 years ago

crOpenGL: tabs to spaces

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.2 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
6import sys
7
8import apiutil
9
10
11apiutil.CopyrightC()
12
13print """/* DO NOT EDIT - AUTOMATICALLY GENERATED BY packspu_beginend.py */
14#include "packspu.h"
15#include "assert.h"
16#include "cr_packfunctions.h"
17#include "packspu_proto.h"
18
19void PACKSPU_APIENTRY packspu_Begin( GLenum mode )
20{
21 GET_THREAD(thread);
22 CRPackBuffer *buf = &thread->BeginEndBuffer;
23
24 /* XXX comparing mode >= 0 here is not needed since mode is unsigned */
25 CRASSERT( mode >= GL_POINTS && mode <= GL_POLYGON );
26
27 if (pack_spu.swap)
28 {
29 crPackBeginSWAP( mode );
30 }
31 else
32 {
33 crPackBegin( mode );
34 }
35
36 if ( thread->netServer.conn->Barf ) {
37 thread->BeginEndMode = mode;
38 thread->BeginEndState = -1;
39 if ( mode == GL_LINES || mode == GL_TRIANGLES || mode == GL_QUADS || mode == GL_POLYGON )
40 {
41 CRASSERT(!buf->pack);
42
43 crPackReleaseBuffer( thread->packer );
44 buf->pack = crNetAlloc( thread->netServer.conn );
45 crPackInitBuffer( buf, buf->pack, thread->netServer.conn->buffer_size, thread->netServer.conn->mtu );
46 buf->holds_BeginEnd = 1;
47 buf->in_BeginEnd = 1;
48 crPackSetBuffer( thread->packer, buf );
49
50 thread->BeginEndState = 0;
51 }
52 }
53}
54
55void PACKSPU_APIENTRY packspu_End( void )
56{
57 GET_THREAD(thread);
58 CRPackBuffer *buf = &thread->BeginEndBuffer;
59
60 if ( thread->netServer.conn->Barf &&
61 (thread->BeginEndMode == GL_LINES
62 || thread->BeginEndMode == GL_TRIANGLES
63 || thread->BeginEndMode == GL_QUADS
64 || thread->BeginEndMode == GL_POLYGON ) )
65 {
66 CRASSERT(buf->pack);
67
68 crPackReleaseBuffer( thread->packer );
69 crPackSetBuffer( thread->packer, &thread->normBuffer );
70 if ( !crPackCanHoldBuffer( buf ) )
71 packspuFlush( (void *) thread );
72
73 crPackAppendBuffer( buf );
74 crNetFree( thread->netServer.conn, buf->pack );
75 buf->pack = NULL;
76 }
77
78 if (pack_spu.swap)
79 {
80 crPackEndSWAP();
81 }
82 else
83 {
84 crPackEnd();
85 }
86}
87
88static void DoVertex( void )
89{
90 GET_THREAD(thread);
91 CRPackBuffer *buf = &thread->BeginEndBuffer;
92 CRPackBuffer *gbuf = &thread->normBuffer;
93 int num_data;
94 int num_opcode;
95
96 /*crDebug( "really doing Vertex" );*/
97 crPackReleaseBuffer( thread->packer );
98 num_data = buf->data_current - buf->data_start;
99 num_opcode = buf->opcode_start - buf->opcode_current;
100 crPackSetBuffer( thread->packer, gbuf );
101 if ( !crPackCanHoldBuffer( buf ) )
102 /* doesn't hold, first flush gbuf*/
103 packspuFlush( (void *) thread );
104
105 crPackAppendBuffer( buf );
106 crPackReleaseBuffer( thread->packer );
107 crPackSetBuffer( thread->packer, buf );
108 crPackResetPointers(thread->packer);
109}
110
111static void RunState( void )
112{
113 GET_THREAD(thread);
114 if (! thread->netServer.conn->Barf ) return;
115 if (thread->BeginEndState == -1) return;
116 switch(thread->BeginEndMode) {
117 case GL_POLYGON:
118 return;
119 case GL_LINES:
120 thread->BeginEndState = (thread->BeginEndState + 1) % 2;
121 if (thread->BeginEndState)
122 return;
123 break;
124 case GL_TRIANGLES:
125 thread->BeginEndState = (thread->BeginEndState + 1) % 3;
126 if (thread->BeginEndState)
127 return;
128 break;
129 case GL_QUADS:
130 thread->BeginEndState = (thread->BeginEndState + 1) % 4;
131 if (thread->BeginEndState)
132 return;
133 break;
134 }
135 DoVertex();
136}
137"""
138
139keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
140
141for func_name in apiutil.AllSpecials( "packspu_vertex" ):
142 params = apiutil.Parameters(func_name)
143 print 'void PACKSPU_APIENTRY packspu_%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params) )
144 print '{'
145 print '\tif (pack_spu.swap)'
146 print '\t{'
147 print '\t\tcrPack%sSWAP( %s );' % ( func_name, apiutil.MakeCallString( params ) )
148 print '\t}'
149 print '\telse'
150 print '\t{'
151 print '\t\tcrPack%s( %s );' % ( func_name, apiutil.MakeCallString( params ) )
152 print '\t}'
153 print '\tRunState();'
154 print '}'
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