VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.c@ 28197

Last change on this file since 28197 was 27889, checked in by vboxsync, 15 years ago

crOpenGL: more code for multiscreen support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.7 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 */
6
7#include "cr_spu.h"
8#include "chromium.h"
9#include "cr_mem.h"
10#include "cr_net.h"
11#include "server_dispatch.h"
12#include "server.h"
13
14
15void SERVER_DISPATCH_APIENTRY crServerDispatchClear( GLenum mask )
16{
17 CRMuralInfo *mural = cr_server.curClient->currentMural;
18 const RunQueue *q = cr_server.run_queue;
19
20 if (cr_server.only_swap_once)
21 {
22 /* NOTE: we only do the clear for the _last_ client in the list.
23 * This is because in multi-threaded apps the zeroeth client may
24 * be idle and never call glClear at all. See threadtest.c
25 * It's pretty likely that the last client will be active.
26 */
27 if ((mask & GL_COLOR_BUFFER_BIT) &&
28 (cr_server.curClient != cr_server.clients[cr_server.numClients - 1]))
29 return;
30 }
31
32 cr_server.head_spu->dispatch_table.Clear( mask );
33}
34
35static void __draw_poly(CRPoly *p)
36{
37 int b;
38
39 cr_server.head_spu->dispatch_table.Begin(GL_POLYGON);
40 for (b=0; b<p->npoints; b++)
41 cr_server.head_spu->dispatch_table.Vertex2dv(p->points+2*b);
42 cr_server.head_spu->dispatch_table.End();
43}
44
45
46void SERVER_DISPATCH_APIENTRY
47crServerDispatchSwapBuffers( GLint window, GLint flags )
48{
49 CRMuralInfo *mural;
50
51 mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
52 if (!mural) {
53 return;
54 }
55
56
57 if (cr_server.only_swap_once)
58 {
59 /* NOTE: we only do the clear for the _last_ client in the list.
60 * This is because in multi-threaded apps the zeroeth client may
61 * be idle and never call glClear at all. See threadtest.c
62 * It's pretty likely that the last client will be active.
63 */
64 if (cr_server.curClient != cr_server.clients[cr_server.numClients - 1])
65 {
66 return;
67 }
68 }
69
70#if 0
71 if (cr_server.overlapBlending)
72 {
73 int a;
74 CRPoly *p;
75 GLboolean lighting, fog, blend, cull, tex[3];
76 GLenum mm, blendSrc, blendDst;
77 GLcolorf col;
78 CRContext *ctx = crStateGetCurrent();
79 const CRmatrix *baseProj;
80
81 /*
82 * I've probably missed some state here, or it
83 * might be easier just to push/pop it....
84 */
85 lighting = ctx->lighting.lighting;
86 fog = ctx->fog.enable;
87 tex[0] = 0;
88 for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
89 {
90 if (!ctx->texture.unit[a].enabled1D) continue;
91
92 tex[0] = 1;
93 break;
94 }
95 tex[1] = 0;
96 for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
97 {
98 if (!ctx->texture.unit[a].enabled2D) continue;
99
100 tex[1] = 1;
101 break;
102 }
103 tex[2] = 0;
104 for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
105 {
106 if (!ctx->texture.unit[a].enabled3D) continue;
107
108 tex[2] = 1;
109 break;
110 }
111
112 cull = ctx->polygon.cullFace;
113 blend = ctx->buffer.blend;
114 blendSrc = ctx->buffer.blendSrcRGB;
115 blendDst = ctx->buffer.blendDstRGB;
116 mm = ctx->transform.matrixMode;
117 col.r = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][0];
118 col.g = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][1];
119 col.b = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][2];
120 col.a = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][3];
121
122 baseProj = &(cr_server.curClient->currentMural->extents[0].baseProjection);
123
124 switch(mm)
125 {
126 case GL_PROJECTION:
127 cr_server.head_spu->dispatch_table.PushMatrix();
128 cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
129 cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
130 cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
131 cr_server.head_spu->dispatch_table.PushMatrix();
132 cr_server.head_spu->dispatch_table.LoadIdentity();
133 break;
134
135 default:
136 cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
137 /* fall through */
138
139 case GL_MODELVIEW:
140 cr_server.head_spu->dispatch_table.PushMatrix();
141 cr_server.head_spu->dispatch_table.LoadIdentity();
142 cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
143 cr_server.head_spu->dispatch_table.PushMatrix();
144 cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
145 cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
146 break;
147 }
148
149 /* fix state */
150 if (lighting)
151 cr_server.head_spu->dispatch_table.Disable(GL_LIGHTING);
152 if (fog)
153 cr_server.head_spu->dispatch_table.Disable(GL_FOG);
154 if (tex[0])
155 cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_1D);
156 if (tex[1])
157 cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_2D);
158 if (tex[2])
159 cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_3D);
160 if (cull)
161 cr_server.head_spu->dispatch_table.Disable(GL_CULL_FACE);
162
163 /* Regular Blending */
164 if (cr_server.overlapBlending == 1)
165 {
166 if (!blend)
167 cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
168 if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
169 cr_server.head_spu->dispatch_table.BlendFunc(GL_ZERO, GL_SRC_ALPHA);
170
171 /* draw the blends */
172 for (a=1; a<cr_server.num_overlap_levels; a++)
173 {
174 if (a-1 < cr_server.num_overlap_intens)
175 {
176 cr_server.head_spu->dispatch_table.Color4f(0, 0, 0,
177 cr_server.overlap_intens[a-1]);
178 }
179 else
180 {
181 cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
182 }
183
184 p = cr_server.overlap_geom[a];
185 while (p)
186 {
187 /* hopefully this isnt concave... */
188 __draw_poly(p);
189 p = p->next;
190 }
191 }
192
193 if (!blend)
194 cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
195 if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
196 cr_server.head_spu->dispatch_table.BlendFunc(blendSrc, blendDst);
197 }
198 else
199 /* Knockout Blending */
200 {
201 cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
202
203 if (blend)
204 cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
205 p = cr_server.overlap_knockout;
206 while (p)
207 {
208 __draw_poly(p);
209 p = p->next;
210 }
211 if (blend)
212 cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
213 }
214
215
216 /* return things to normal */
217 switch (mm)
218 {
219 case GL_PROJECTION:
220 cr_server.head_spu->dispatch_table.PopMatrix();
221 cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
222 cr_server.head_spu->dispatch_table.PopMatrix();
223 break;
224 case GL_MODELVIEW:
225 cr_server.head_spu->dispatch_table.PopMatrix();
226 cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
227 cr_server.head_spu->dispatch_table.PopMatrix();
228 break;
229 default:
230 cr_server.head_spu->dispatch_table.PopMatrix();
231 cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
232 cr_server.head_spu->dispatch_table.PopMatrix();
233 cr_server.head_spu->dispatch_table.MatrixMode(mm);
234 break;
235 }
236
237 if (lighting)
238 cr_server.head_spu->dispatch_table.Enable(GL_LIGHTING);
239 if (fog)
240 cr_server.head_spu->dispatch_table.Enable(GL_FOG);
241 if (tex[0])
242 cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_1D);
243 if (tex[1])
244 cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_2D);
245 if (tex[2])
246 cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_3D);
247 if (cull)
248 cr_server.head_spu->dispatch_table.Enable(GL_CULL_FACE);
249
250 cr_server.head_spu->dispatch_table.Color4f(col.r, col.g, col.b, col.a);
251 }
252#endif
253
254 /* Check if using a file network */
255 if (!cr_server.clients[0]->conn->actual_network && window == MAGIC_OFFSET)
256 window = 0;
257
258 if (crServerIsRedirectedToFBO())
259 {
260 crServerPresentFBO(mural);
261 }
262 else
263 {
264 cr_server.head_spu->dispatch_table.SwapBuffers( mural->spuWindow, flags );
265 }
266}
267
268void SERVER_DISPATCH_APIENTRY
269crServerDispatchFlush(void)
270{
271 cr_server.head_spu->dispatch_table.Flush();
272
273 if (crServerIsRedirectedToFBO())
274 {
275 crServerPresentFBO(cr_server.curClient->currentMural);
276 }
277}
278
279void SERVER_DISPATCH_APIENTRY
280crServerDispatchFinish(void)
281{
282 cr_server.head_spu->dispatch_table.Finish();
283
284 if (crServerIsRedirectedToFBO())
285 {
286 crServerPresentFBO(cr_server.curClient->currentMural);
287 }
288}
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