Game Development Community

Simple Error Checking Routine For OpenGL

by Frank Carney · in Torque Game Engine · 01/27/2007 (6:19 pm) · 0 replies

This isn't really exciting and it did not find my problem, but I thought I would share. Feel free to add additional error codes:
GLenum glError = glGetError();
   if(GL_NO_ERROR != glError)
   {
      //Con::printf("glError:%d",glError);
      //Con::printf("gl Version:%s",glGetString(GL_VERSION));
      if(glError == GL_INVALID_ENUM)
         Con::printf("GL_INVALID_ENUM");
      else if(glError == GL_INVALID_VALUE)
         Con::printf("GL_INVALID_VALUE");
      else if(glError == GL_INVALID_OPERATION)
         Con::printf("GL_INVALID_OPERATION");      
      else
         Con::printf("GL_?_ERROR: %d",glError);
   }

Also, glu has a similar function, but Torque did not take kindly to trying to link it in.

About the author

I Started programming in HS and have never stopped. Now an 18 year vet of programming anything from assembler on a NES console to a nuclear waste processing system. If it can be programmed I may have tried to program it!