132001f49Smrg#include "framework.h"
232001f49Smrg
332001f49Smrgstatic void Display (void)
432001f49Smrg{
532001f49Smrg   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
632001f49Smrg   RenderScene ();
732001f49Smrg   glutSwapBuffers ();
832001f49Smrg}
932001f49Smrg
1032001f49Smrgstatic void Idle (void)
1132001f49Smrg{
1232001f49Smrg   glutPostRedisplay ();
1332001f49Smrg}
1432001f49Smrg
1532001f49Smrgvoid InitFramework (int *argc, char *argv[])
1632001f49Smrg{
1732001f49Smrg   glutInit (argc, argv);
1832001f49Smrg   glutInitWindowPosition (0, 0);
1932001f49Smrg   glutInitWindowSize (200, 200);
2032001f49Smrg   glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
2132001f49Smrg   glutCreateWindow (argv[0]);
2232001f49Smrg   glewInit();
2332001f49Smrg
2432001f49Smrg   printf ("VENDOR: %s\n", glGetString (GL_VENDOR));
2532001f49Smrg   printf ("RENDERER: %s\n", glGetString (GL_RENDERER));
2632001f49Smrg
2732001f49Smrg   InitScene ();
2832001f49Smrg
2932001f49Smrg   glutDisplayFunc (Display);
3032001f49Smrg   glutIdleFunc (Idle);
3132001f49Smrg   glutMainLoop ();
3232001f49Smrg}
3332001f49Smrg
3432001f49SmrgGLboolean CheckObjectStatus (GLhandleARB handle)
3532001f49Smrg{
3632001f49Smrg   GLint type, status, length;
3732001f49Smrg   GLcharARB *infolog;
3832001f49Smrg
3932001f49Smrg   glGetObjectParameterivARB (handle, GL_OBJECT_TYPE_ARB, &type);
4032001f49Smrg   if (type == GL_SHADER_OBJECT_ARB)
4132001f49Smrg      glGetObjectParameterivARB (handle, GL_OBJECT_COMPILE_STATUS_ARB, &status);
4232001f49Smrg   else if (type == GL_PROGRAM_OBJECT_ARB)
4332001f49Smrg      glGetObjectParameterivARB (handle, GL_OBJECT_LINK_STATUS_ARB, &status);
4432001f49Smrg   else {
4532001f49Smrg      assert (0);
4632001f49Smrg      return GL_FALSE;
4732001f49Smrg   }
4832001f49Smrg
4932001f49Smrg   if (status)
5032001f49Smrg      return GL_TRUE;
5132001f49Smrg
5232001f49Smrg   printf ("\n%s FAILED. INFO LOG FOLLOWS:\n",
5332001f49Smrg           type == GL_SHADER_OBJECT_ARB ? "SHADER COMPILE" : "PROGRAM LINK");
5432001f49Smrg
5532001f49Smrg   glGetObjectParameterivARB (handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
5632001f49Smrg   infolog = (GLcharARB *) (malloc (length));
5732001f49Smrg   if (infolog != NULL) {
5832001f49Smrg      glGetInfoLogARB (handle, length, NULL, infolog);
5932001f49Smrg      printf ("%s", infolog);
6032001f49Smrg      free (infolog);
6132001f49Smrg   }
6232001f49Smrg
6332001f49Smrg   printf ("\n");
6432001f49Smrg
6532001f49Smrg   return GL_FALSE;
6632001f49Smrg}
6732001f49Smrg
68