#include #include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init (void) { int i; GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; glClearColor (0.0, 0.0, 0.0, 1.0); glColor4fv (white); glDisable (GL_DITHER); } static void test (void) { int i, j; const int MAX = 2; GLint maxBuf = -1, n, val; GLenum buffers[MAX], err; GLint initDrawBuffer; glGetIntegerv(GL_DRAW_BUFFER, &initDrawBuffer); glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxBuf); if (maxBuf < 1) { return; } n = maxBuf < MAX ? maxBuf : MAX; for (i = 0; i < n; i++) { buffers[i] = (i & 1) ? GL_FRONT_LEFT : GL_BACK_LEFT; } glDrawBuffers(n, buffers); for (i = 0; i < n; i++) { glGetIntegerv(GL_DRAW_BUFFER0 + i, &val); if (val != (GLint) buffers[i]) { printf("glGetIntegerv(GL_DRAW_BUFFER%c) returns wrong buffer\n", '0'+i); } } } void display (void) { glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0, WINDSIZEX, 0, WINDSIZEX); test (); } int main (int argc, char **argv) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize (WINDSIZEX, WINDSIZEY); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc (display); glutMainLoop (); return 0; }