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

Function clearFB

util/glreadtest.cpp:314–349  ·  view source on GitHub ↗

Makes sure the frame buffer has been cleared prior to a write

Source from the content-addressed store, hash-verified

312
313// Makes sure the frame buffer has been cleared prior to a write
314void clearFB(void)
315{
316 unsigned char *buf = NULL;
317 size_t bufSize = drawableWidth * drawableHeight * 3;
318
319 if((buf = (unsigned char *)malloc(bufSize)) == NULL)
320 THROW("Could not allocate buffer");
321 memset(buf, 0xFF, bufSize);
322 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
323 glPixelStorei(GL_PACK_ALIGNMENT, 1);
324 #ifdef GL_EXT_framebuffer_object
325 if(useFBO)
326 {
327 glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
328 glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
329 }
330 else
331 #endif
332 {
333 glDrawBuffer(GL_FRONT);
334 glReadBuffer(GL_FRONT);
335 }
336 glClearColor(0., 0., 0., 0.);
337 glClear(GL_COLOR_BUFFER_BIT);
338 glReadPixels(0, 0, drawableWidth, drawableHeight, GL_RGB, GL_UNSIGNED_BYTE,
339 buf);
340 check_errors("frame buffer read");
341 for(size_t i = 0; i < bufSize; i++)
342 {
343 if(buf[i] != 0)
344 {
345 fprintf(stderr, "Buffer was not cleared\n"); break;
346 }
347 }
348 free(buf);
349}
350
351
352// Generic GL write test

Callers 1

writeTestFunction · 0.70

Calls 4

glDrawBufferFunction · 0.85
glReadBufferFunction · 0.85
glReadPixelsFunction · 0.85
check_errorsFunction · 0.85

Tested by

no test coverage detected