MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / draw_loop

Function draw_loop

demos/glthreadsint.c:261–327  ·  view source on GitHub ↗

* We have an instance of this for each thread. */

Source from the content-addressed store, hash-verified

259 * We have an instance of this for each thread.
260 */
261static void
262draw_loop(struct winthread *wt)
263{
264 while (!ExitFlag) {
265
266 pthread_mutex_lock(&wt->Ready);
267 if (ExitFlag) break;
268
269 LOCK(wt->Dpy);
270
271 glXMakeCurrent(wt->Dpy, wt->Win, wt->Context);
272 if (!wt->Initialized) {
273 printf("glthreads: %d: GL_RENDERER = %s\n", wt->Index,
274 (char *) glGetString(GL_RENDERER));
275 if (Texture /*&& wt->Index == 0*/) {
276 MakeNewTexture(wt);
277 }
278 wt->Initialized = GL_TRUE;
279 }
280
281 UNLOCK(wt->Dpy);
282
283 glEnable(GL_DEPTH_TEST);
284
285 if (wt->NewSize) {
286 GLfloat w = (float) wt->WinWidth / (float) wt->WinHeight;
287 glViewport(0, 0, wt->WinWidth, wt->WinHeight);
288 glMatrixMode(GL_PROJECTION);
289 glLoadIdentity();
290 glFrustum(-w, w, -1.0, 1.0, 1.5, 10);
291 glMatrixMode(GL_MODELVIEW);
292 glLoadIdentity();
293 glTranslatef(0, 0, -2.5);
294 wt->NewSize = GL_FALSE;
295 }
296
297 if (wt->MakeNewTexture) {
298 MakeNewTexture(wt);
299 wt->MakeNewTexture = GL_FALSE;
300 }
301
302 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
303
304 glPushMatrix();
305 glRotatef(wt->AngleY, 1, 0, 0);
306 glRotatef(wt->AngleX, 0, 1, 0);
307 glScalef(0.7, 0.7, 0.7);
308 draw_object();
309 glPopMatrix();
310
311 LOCK(wt->Dpy);
312
313 glXSwapBuffers(wt->Dpy, wt->Win);
314
315 UNLOCK(wt->Dpy);
316
317 if (Animate) {
318 usleep(5000);

Callers 1

thread_functionFunction · 0.70

Calls 6

glXMakeCurrentFunction · 0.85
glGetStringFunction · 0.85
glViewportFunction · 0.85
glXSwapBuffersFunction · 0.85
MakeNewTextureFunction · 0.70
draw_objectFunction · 0.70

Tested by

no test coverage detected