/*
 *  bufftst.c
 *  Display the harware config
 */
//#include <GL/glut.h> // this assumes your glut-path is known to the operating system
#include "glut.h" // this is a local "glut.h" file
#include <stdlib.h>

int query[11] = {
    GL_RED_BITS,
    GL_GREEN_BITS,
    GL_BLUE_BITS,
    GL_ALPHA_BITS,
    GL_INDEX_BITS,
    GL_DEPTH_BITS,
    GL_STENCIL_BITS,
    GL_ACCUM_RED_BITS,
    GL_ACCUM_GREEN_BITS,
    GL_ACCUM_BLUE_BITS,
    GL_ACCUM_ALPHA_BITS};

char querystr[11][30] = {
    "GL_RED_BITS",
    "GL_GREEN_BITS",
    "GL_BLUE_BITS",
    "GL_ALPHA_BITS",
    "GL_INDEX_BITS",
    "GL_DEPTH_BITS",
    "GL_STENCIL_BITS",
    "GL_ACCUM_RED_BITS",
    "GL_ACCUM_GREEN_BITS",
    "GL_ACCUM_BLUE_BITS",
    "GL_ACCUM_ALPHA_BITS"};

void init (void) 
{
   int i, q;

   glClearStencil(0x0);
   glEnable(GL_STENCIL_TEST);
   for (i=0; i<11; i++) {
       glGetIntegerv(query[i], &q);
       printf("%s %d\n", querystr[i], q);
    }
}


void display(void)
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

}

/*  Whenever the window is reshaped, redefine the 
 *  coordinate system and redraw the stencil area.
 */
void reshape(int w, int h)
{
   glViewport(0, 0, (GLsizei) w, (GLsizei) h);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   if (w <= h)
      gluOrtho2D(-3.0, 3.0, -3.0*(GLfloat)h/(GLfloat)w,
                 3.0*(GLfloat)h/(GLfloat)w);
   else
      gluOrtho2D(-3.0*(GLfloat)w/(GLfloat)h,
                 3.0*(GLfloat)w/(GLfloat)h, -3.0, 3.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glTranslatef(0.0, 0.0, -5.0);
}

void keyboard(unsigned char key, int x, int y)
{
   switch (key) {
      case 27:
         exit(0);
         break;
   }
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB 
                        | GLUT_DEPTH | GLUT_STENCIL);
   glutInitWindowSize (400, 400);
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   init ();
   glutReshapeFunc(reshape);
   glutDisplayFunc(display);
   glutKeyboardFunc(keyboard);
   glutMainLoop();
   return 0;
}

