Results 1 to 3 of 3

Thread: writing a shader error checker in C

  1. #1
    Member Contributor
    Join Date
    Jun 2013

    writing a shader error checker in C

    hi im writing a simple shader error checker in C to check for errors on compilation and link time. im having a big problem with getting the glShaderSource() function to work. i first create space for the code using malloc(codelength * sizeof(char)) then i attach the source to a created shader object with this line glShaderSource(shader, 1, (const char **) &code, NULL);. i belive the problem is with this line. ive even tried changing NULL to the length of the code but to no avail. when i try to get info on the shader it returns zero to glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &compileloglength); and zero to glGetShaderiv(shaders[0], GL_COMPILE_STATUS, &compileloglength); please donbe t point me to a shader error checker that is already out there, unless it has relevant code because i like doing little projects like these. any help would be great. thanks

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Code :
    bool  CompileShaderFromMemory(GLuint p_ID, const char* p_ShaderString)
        glShaderSource( p_ID, 1, (const char **)&p_ShaderString, 0 );
        // Compile the shader, and check if there were compilation errors
         glCompileShader( p_ID );
        GLint compiled = 0;
        glGetShaderiv( p_ID, GL_COMPILE_STATUS, &compiled);
        // If there were compile errors, we might want to print them out.
        if (!compiled)
          GLint l,l1;
            GLchar* compilerSpew = new GLchar[l+1];
            glGetShaderInfoLog(p_ID, l+1, &l1, compilerSpew);
            Util_Warning(_T("Shader compile failed"));
          delete [] compilerSpew;
            return false;
        glAttachShader( c_ProgramID, p_ID );
      return true;

  3. #3
    Member Contributor
    Join Date
    Jun 2013
    k i figured it out. i didnt realize i had to make an opengl context for the functions to work

Similar Threads

  1. created a shader error checker
    By sandbucket in forum OpenGL: Linux
    Replies: 0
    Last Post: 10-05-2013, 11:19 AM
  2. Problem writing to SBO in geometry shader
    By urhere in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 08-07-2013, 08:20 AM
  3. Shader Compile Error: ERROR: 0:1: '' : syntax error #version
    By Blakeasd in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 07-25-2013, 07:35 PM
  4. Writing a hand-drawn cel-shader
    By Curagea in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 05-15-2008, 10:19 AM
  5. Fragment shader appears to be writing all 1's
    By elchuppa in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-19-2003, 05:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean