1#include "framework.h" 2 3static void Display (void) 4{ 5 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 6 RenderScene (); 7 glutSwapBuffers (); 8} 9 10static void Idle (void) 11{ 12 glutPostRedisplay (); 13} 14 15void InitFramework (int *argc, char *argv[]) 16{ 17 glutInit (argc, argv); 18 glutInitWindowPosition (0, 0); 19 glutInitWindowSize (200, 200); 20 glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); 21 glutCreateWindow (argv[0]); 22 glewInit(); 23 24 printf ("VENDOR: %s\n", glGetString (GL_VENDOR)); 25 printf ("RENDERER: %s\n", glGetString (GL_RENDERER)); 26 27 InitScene (); 28 29 glutDisplayFunc (Display); 30 glutIdleFunc (Idle); 31 glutMainLoop (); 32} 33 34GLboolean CheckObjectStatus (GLhandleARB handle) 35{ 36 GLint type, status, length; 37 GLcharARB *infolog; 38 39 glGetObjectParameterivARB (handle, GL_OBJECT_TYPE_ARB, &type); 40 if (type == GL_SHADER_OBJECT_ARB) 41 glGetObjectParameterivARB (handle, GL_OBJECT_COMPILE_STATUS_ARB, &status); 42 else if (type == GL_PROGRAM_OBJECT_ARB) 43 glGetObjectParameterivARB (handle, GL_OBJECT_LINK_STATUS_ARB, &status); 44 else { 45 assert (0); 46 return GL_FALSE; 47 } 48 49 if (status) 50 return GL_TRUE; 51 52 printf ("\n%s FAILED. INFO LOG FOLLOWS:\n", 53 type == GL_SHADER_OBJECT_ARB ? "SHADER COMPILE" : "PROGRAM LINK"); 54 55 glGetObjectParameterivARB (handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); 56 infolog = (GLcharARB *) (malloc (length)); 57 if (infolog != NULL) { 58 glGetInfoLogARB (handle, length, NULL, infolog); 59 printf ("%s", infolog); 60 free (infolog); 61 } 62 63 printf ("\n"); 64 65 return GL_FALSE; 66} 67 68