Reputation: 12616
I've done a simple API on top of GLES2. Everything seems OK, but the state of GL_COMPILE_STATUS
is GL_FALSE
.
I've got a structure like this:
typedef struct MyGLShader__
{
GLuint uiHandle;
GLenum eType;
const char *pcSource;
} MyGLShader;
I initialize it this way and create a shader using a function of mine:
MyGLShader shader = {0, GL_VERTEX_SHADER, MY_VERTEX_SHADER_SOURCE};
shader_create(&shader);
This function should be creating the shader:
MyStatus shader_create(MyGLShader *pShader)
{
MyStatus eStatus;
pShader->uiHandle = glCreateShader(pShader->eType);
MY_GL_VALIDATE("glCreateShader");
glShaderSource(pShader->uiHandle, 1, &pShader->pcSource, NULL);
MY_GL_VALIDATE("glShaderSource");
glCompileShader(pShader->uiHandle);
eStatus = shader_check(pShader);
if (eStatus != MY_STATUS_OK)
{
return eStatus;
}
return MY_STATUS_OK;
}
It goes without trouble until it calls shader_check()
:
static MyStatus shader_check(MyGLShader *pShader)
{
GLint status;
LOGI("Checking shader compilation status...");
glGetShaderiv(pShader->uiHandle, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE)
{
LOGE("Shader compilation has failed");
shader_log_infolog(pShader);
return MY_STATUS_ERROR;
}
return MY_STATUS_OK;
}
Which stumbles on: if (status != GL_TRUE)
.
After that, when it tries to print the infolog in shader_log_infolog
:
static void shader_log_infolog(
MyGLShader *pShader, MyStatus eStatus)
{
char acbuffer[INFO_LENGTH];
glGetShaderInfoLog(pShader->uiHandle, INFO_LENGTH, NULL, (char *) &acbuffer);
LOGE("Shader Log: %s", acbuffer)
}
It doesn't print any log, i.e. it only prints
Shader Log:
Any ideas what I may be doing wrong with the initialization. MY_GL_VALIDATE
checks for gl errors using glGetError()
and I can confirm it works fine.
Here's the Shader source definition:
#define MY_VERTEX_SHADER_SOURCE \
\
" \
attribute vec4 a_Position; \
\
void main() { \
gl_Position = a_Position; \
} \
\
"
Upvotes: 3
Views: 477
Reputation: 12616
I had forgotten to setup the EGL to use GLES2. It was using the defaults which are for GLES1. Strangely enough, the drivers didn't complain for using GLES2 functions in a GLES1 context.
Upvotes: 1