#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 #define MIN(x, y) (((x) <= (y)) ? (x) : (y)) GLenum *bufs; GLint nDrawBufs; static void GetBufferInfo() { GLint i, j; GLsizei nBufs, nMaxBufs, nAuxBufs, totalBufs; GLint doingStereo, doingDoubleBuffer; GLenum bufList[4] = { GL_FRONT_LEFT, GL_BACK_LEFT, GL_FRONT_RIGHT, GL_BACK_RIGHT}; // Find out the maximum number of buffers that we can simultaneously // draw into. glGetIntegerv(GL_MAX_DRAW_BUFFERS, &nMaxBufs); // Get the number of aux buffers that are available. glGetIntegerv(GL_AUX_BUFFERS, &nAuxBufs); // Find out if we are doing double buffering or stereo. glGetIntegerv(GL_DOUBLEBUFFER, &doingDoubleBuffer); glGetIntegerv(GL_STEREO, &doingStereo); // Calculate the number of front & back buffers. nBufs = (1 + doingDoubleBuffer) * (1 + doingStereo); // Allocate an array where we can put the DrawBuffers list. totalBufs = nBufs + nAuxBufs; nDrawBufs = MIN(totalBufs, nMaxBufs); bufs = malloc(nDrawBufs * sizeof(GLenum)); printf("max buffers number: %d\n", nMaxBufs); printf("aux buffers number: %d\n", nAuxBufs); printf("double buffers: %d\n", doingDoubleBuffer); printf("stereo buffers: %d\n", doingStereo); printf("draw buffers number: %d\n", nDrawBufs); for (i=0; i 0.01) || (fabs(pixBuf[1] - expected[1]) > 0.01) || (fabs(pixBuf[2] - expected[2]) > 0.01) || (fabs(pixBuf[3] - expected[3]) > 0.01) ) { printf("error! i is: %d\n", i); printf("expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]); printf("actual: %f %f %f %f\n", pixBuf[0], pixBuf[1], pixBuf[2], pixBuf[3]); printf("\n"); } } exit(0); } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0); //gluOrtho2D(0, WINDSIZEX, 0, WINDSIZEY); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(WINDSIZEX, WINDSIZEY); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }