Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5271 in orxonox.OLD for trunk/src/lib/graphics/shader.cc


Ignore:
Timestamp:
Sep 28, 2005, 6:04:59 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: better checking, and not loading shader if it is non-existent

File:
1 edited

Legend:

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

    r5269 r5271  
    8080
    8181  const char* program = fileRead(fileName);
     82  if (program == NULL)
     83    return false;
    8284  GLenum shader = 0;
    8385  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
     
    116118  int count = 0;
    117119
    118   if (fileName != NULL) {
    119     fileHandle = fopen(fileName, "rt");
    120 
    121     if (fileHandle != NULL) {
    122 
    123       fseek(fileHandle, 0, SEEK_END);
    124       count = ftell(fileHandle);
    125       rewind(fileHandle);
    126 
    127       if (count > 0) {
    128         content = new char[count+1];
    129         count = fread(content, sizeof(char), count, fileHandle);
    130         content[count] = '\0';
    131       }
    132       fclose(fileHandle);
    133     }
    134   }
    135   return content;
     120  if (fileName == NULL)
     121    return NULL;
     122
     123  fileHandle = fopen(fileName, "rt");
     124
     125  if (fileHandle == NULL)
     126    return NULL;
     127  fseek(fileHandle, 0, SEEK_END);
     128  count = ftell(fileHandle);
     129  rewind(fileHandle);
     130  if (count > 0) {
     131     content = new char[count+1];
     132     count = fread(content, sizeof(char), count, fileHandle);
     133     content[count] = '\0';
     134   }
     135   fclose(fileHandle);
     136 return content;
    136137}
    137138
Note: See TracChangeset for help on using the changeset viewer.