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

Function checkBufferColor

server/eglxfakerut.cpp:141–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140
141unsigned int checkBufferColor(void)
142{
143 int i, viewport[4], ps = 3; unsigned int ret = 0;
144 unsigned char *buf = NULL;
145
146 try
147 {
148 viewport[0] = viewport[1] = viewport[2] = viewport[3] = 0;
149 glGetIntegerv(GL_VIEWPORT, viewport);
150 if(viewport[2] < 1 || viewport[3] < 1)
151 THROW("Invalid viewport dimensions");
152
153 if((buf = (unsigned char *)malloc(viewport[2] * viewport[3] * ps)) == NULL)
154 THROW("Could not allocate buffer");
155 memset(buf, 128, viewport[2] * viewport[3] * ps);
156
157 glPixelStorei(GL_PACK_ALIGNMENT, 1);
158 glReadPixels(0, 0, viewport[2], viewport[3], GL_RGB, GL_UNSIGNED_BYTE,
159 buf);
160 for(i = 3; i < viewport[2] * viewport[3] * ps; i += ps)
161 {
162 if(buf[i] != buf[0] || buf[i + 1] != buf[1] || buf[i + 2] != buf[2])
163 THROW("Bogus data read back");
164 }
165 ret = buf[0] | (buf[1] << 8) | (buf[2] << 16);
166 free(buf);
167 return ret;
168 }
169 catch(...)
170 {
171 free(buf);
172 throw;
173 }
174}
175
176
177void checkWindowColor(Display *dpy, Window win, unsigned int color)

Callers

nothing calls this directly

Calls 2

glGetIntegervFunction · 0.85
glReadPixelsFunction · 0.85

Tested by

no test coverage detected