PerduGames
PerduGames

Reputation: 1218

How to check shader and program error in cl-opengl?

I'm learning opengl ES 2.0. I'm learning to check errors in C, but I don't know as make the same in cl-opengl, because I don't see any function like gl:get-shaderiv or gl:get-programiv, so, how to make the same that the code below do? However in cl-opengl.

// Check the compile status
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if(!compiled) {
  GLint info
  Len = 0;
  glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
  if(infoLen > 1) {
    char* infoLog = malloc(sizeof(char) * infoLen);
    glGetShaderInfoLog(shader, infoLen, NULL, infoLog);
    esLogMessage("Error compiling shader:\n%s\n", infoLog);
    free(infoLog);
  }
  glDeleteShader(shader);
  return 0;
}


// Check the link status
glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
if(!linked) {
  GLint infoLen = 0;
  glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
  if(infoLen > 1) {
    char* infoLog = malloc(sizeof(char) * infoLen);
    glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
    esLogMessage("Error linking program:\n%s\n", infoLog);
    free(infoLog);
  }
  glDeleteProgram(programObject);
  return FALSE;
}

Upvotes: 2

Views: 232

Answers (1)

PerduGames
PerduGames

Reputation: 1218

There are two ways for get it:

First:

(gl:get-shader shader :compile-status) 

or you can use the second option:

%gl:get-shader-iv

In this way you need allocate manually a pointer for &compiled.

Upvotes: 2

Related Questions