Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5320 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Oct 8, 2005, 3:31:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: better error-checking in the Shaders

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/shader.cc

    r5319 r5320  
    4747   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    4848     {
     49       GLint status = 0;
     50
    4951       this->shaderProgram = glCreateProgramObjectARB();
    5052
     
    5355       if (fragmentShaderFile != NULL)
    5456         this->loadShaderProgramm(SHADER_FRAGMENT, fragmentShaderFile);
    55        try  {
    56          glLinkProgramARB(this->shaderProgram); }
    57        catch(GLenum errorCode)  {
    58          this->printError(this->shaderProgram); }
    59      }
     57       glLinkProgramARB(this->shaderProgram);
     58       // link error checking
     59       glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
     60       if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     61         this->printError(this->shaderProgram);
     62    }
    6063   else
    6164     {
     
    120123  if (shader != 0)
    121124  {
     125    GLint status = 0;
    122126    glShaderSourceARB(shader, program->getCount(), (const GLcharARB**)program->getArray(), NULL);
    123       glCompileShaderARB(shader);
    124         this->printError(shader);
    125     glAttachObjectARB(this->shaderProgram, shader);
     127    glCompileShaderARB(shader);
     128    // checking on error.
     129    glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
     130    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     131      this->printError(shader);
     132    else
     133      glAttachObjectARB(this->shaderProgram, shader);
    126134  }
    127135  for (unsigned int i=0; i< program->getCount(); i++)
     
    201209void Shader::deleteProgram(SHADER_TYPE type)
    202210{
     211  GLint status;
    203212  if (type == SHADER_VERTEX && this->vertexShader != 0)
    204213  {
     
    206215    this->vertexShaderFile = NULL;
    207216    glDeleteObjectARB(this->vertexShader);
     217    glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
     218    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     219      Shader::printError(this->vertexShader);
    208220    this->vertexShader = 0;
    209221  }
     
    213225    this->fragmentShaderFile = NULL;
    214226    glDeleteObjectARB(this->fragmentShader);
     227    glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
     228    if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
     229      Shader::printError(this->fragmentShader);
    215230    this->fragmentShader = 0;
    216231  }
Note: See TracChangeset for help on using the changeset viewer.