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 """#include "cr_spu.h"
|
---|
14 | #include "chromium.h"
|
---|
15 | #include "cr_error.h"
|
---|
16 | #include "cr_mem.h"
|
---|
17 | #include "cr_net.h"
|
---|
18 | #include "server_dispatch.h"
|
---|
19 | #include "server.h"
|
---|
20 | """
|
---|
21 |
|
---|
22 | from get_sizes import *;
|
---|
23 |
|
---|
24 |
|
---|
25 | funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
|
---|
26 | types = [ 'GLint', 'GLfloat', 'GLdouble', 'GLboolean' ]
|
---|
27 |
|
---|
28 | for index in range(len(funcs)):
|
---|
29 | func_name = funcs[index]
|
---|
30 | params = apiutil.Parameters(func_name)
|
---|
31 | print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params))
|
---|
32 | print '{'
|
---|
33 | print '\t%s *get_values;' % types[index]
|
---|
34 | print '\tint tablesize;'
|
---|
35 | print """
|
---|
36 | #ifdef CR_ARB_texture_compression
|
---|
37 | if (GL_COMPRESSED_TEXTURE_FORMATS_ARB == pname)
|
---|
38 | {
|
---|
39 | GLint numtexfmts = 0;
|
---|
40 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numtexfmts);
|
---|
41 | tablesize = numtexfmts * sizeof(%s);
|
---|
42 | }
|
---|
43 | else
|
---|
44 | #endif
|
---|
45 | {
|
---|
46 | tablesize = __numValues( pname ) * sizeof(%s);
|
---|
47 | }
|
---|
48 | """ % (types[index], types[index])
|
---|
49 | print '\t(void) params;'
|
---|
50 | print '\tget_values = (%s *) crAlloc( tablesize );' % types[index]
|
---|
51 | print '\tif (tablesize>0)'
|
---|
52 | print '\tcr_server.head_spu->dispatch_table.%s( pname, get_values );' % func_name
|
---|
53 | print """
|
---|
54 | if (GL_TEXTURE_BINDING_1D==pname
|
---|
55 | || GL_TEXTURE_BINDING_2D==pname
|
---|
56 | || GL_TEXTURE_BINDING_3D==pname
|
---|
57 | || GL_TEXTURE_BINDING_RECTANGLE_ARB==pname
|
---|
58 | || GL_TEXTURE_BINDING_CUBE_MAP_ARB==pname)
|
---|
59 | {
|
---|
60 | GLuint texid;
|
---|
61 | CRASSERT(tablesize/sizeof(%s)==1);
|
---|
62 | texid = (GLuint) *get_values;
|
---|
63 | *get_values = (%s) crStateTextureHWIDtoID(texid);
|
---|
64 | }
|
---|
65 | else if (GL_CURRENT_PROGRAM==pname)
|
---|
66 | {
|
---|
67 | GLuint programid;
|
---|
68 | CRASSERT(tablesize/sizeof(%s)==1);
|
---|
69 | programid = (GLuint) *get_values;
|
---|
70 | *get_values = (%s) crStateGLSLProgramHWIDtoID(programid);
|
---|
71 | }
|
---|
72 | else if (GL_FRAMEBUFFER_BINDING_EXT==pname
|
---|
73 | ||GL_READ_FRAMEBUFFER_BINDING==pname)
|
---|
74 | {
|
---|
75 | GLuint fboid;
|
---|
76 | CRASSERT(tablesize/sizeof(%s)==1);
|
---|
77 | fboid = (GLuint) *get_values;
|
---|
78 | if (crServerIsRedirectedToFBO()
|
---|
79 | && (fboid==cr_server.curClient->currentMural->aidFBOs[0]
|
---|
80 | || fboid==cr_server.curClient->currentMural->aidFBOs[1]))
|
---|
81 | {
|
---|
82 | fboid = 0;
|
---|
83 | }
|
---|
84 | else
|
---|
85 | {
|
---|
86 | fboid = crStateFBOHWIDtoID(fboid);
|
---|
87 | }
|
---|
88 | *get_values = (%s) fboid;
|
---|
89 | }
|
---|
90 | else if (GL_READ_BUFFER==pname)
|
---|
91 | {
|
---|
92 | if (crServerIsRedirectedToFBO()
|
---|
93 | && cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurReadBuffer]
|
---|
94 | && !crStateGetCurrent()->framebufferobject.readFB)
|
---|
95 | {
|
---|
96 | *get_values = (%s) crStateGetCurrent()->buffer.readBuffer;
|
---|
97 | }
|
---|
98 | }
|
---|
99 | else if (GL_DRAW_BUFFER==pname)
|
---|
100 | {
|
---|
101 | if (crServerIsRedirectedToFBO()
|
---|
102 | && cr_server.curClient->currentMural->aidFBOs[cr_server.curClient->currentMural->iCurDrawBuffer]
|
---|
103 | && !crStateGetCurrent()->framebufferobject.drawFB)
|
---|
104 | {
|
---|
105 | *get_values = (%s) crStateGetCurrent()->buffer.drawBuffer;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | else if (GL_RENDERBUFFER_BINDING_EXT==pname)
|
---|
109 | {
|
---|
110 | GLuint rbid;
|
---|
111 | CRASSERT(tablesize/sizeof(%s)==1);
|
---|
112 | rbid = (GLuint) *get_values;
|
---|
113 | *get_values = (%s) crStateRBOHWIDtoID(rbid);
|
---|
114 | }
|
---|
115 | else if (GL_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
116 | || GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
117 | || GL_VERTEX_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
118 | || GL_NORMAL_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
119 | || GL_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
120 | || GL_INDEX_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
121 | || GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
122 | || GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
123 | || GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
124 | || GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB==pname
|
---|
125 | || GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB==pname)
|
---|
126 | {
|
---|
127 | GLuint bufid;
|
---|
128 | CRASSERT(tablesize/sizeof(%s)==1);
|
---|
129 | bufid = (GLuint) *get_values;
|
---|
130 | *get_values = (%s) crStateBufferHWIDtoID(bufid);
|
---|
131 | }
|
---|
132 | else if (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS==pname)
|
---|
133 | {
|
---|
134 | if (CR_MAX_TEXTURE_UNITS < (GLuint)*get_values)
|
---|
135 | {
|
---|
136 | *get_values = (%s)CR_MAX_TEXTURE_UNITS;
|
---|
137 | }
|
---|
138 | }
|
---|
139 | """ % (types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index], types[index])
|
---|
140 | print '\tcrServerReturnValue( get_values, tablesize );'
|
---|
141 | print '\tcrFree(get_values);'
|
---|
142 | print '}\n'
|
---|