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