Hello,
For some reason whenever I set either a GLuint or a regular unsigned int equal to glCreateShader, it returns 0?? Take a look at this snippet of code:
The code is in viewDidLoad:
No compiling errors, yet my if statement testing for a NULL shader is called and the value of the shader is 0.
Could anyone assist me in finding what's happening?
Thanks!
For some reason whenever I set either a GLuint or a regular unsigned int equal to glCreateShader, it returns 0?? Take a look at this snippet of code:
The code is in viewDidLoad:
Code:
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
GLKView *view = (GLKView*)self.view;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat16;
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
int width = self.view.bounds.size.width;
int height = self.view.bounds.size.height;
// Read vertex shader source
NSString *vertexShaderSource = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"VertexShader" ofType:@"vsh"] encoding:NSUTF8StringEncoding error:nil];
const char *vertexShaderSourceCString = [vertexShaderSource cStringUsingEncoding:NSUTF8StringEncoding];
// Create and compile vertex shader
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vertexShaderSourceCString, NULL);
glCompileShader(vertexShader);
GLint compiled;
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &compiled);
if (!compiled) {
GLint infoLen = 0;
glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &infoLen);
if (infoLen > 1) {
char *infoLog = malloc(sizeof(char)*infoLen);
glGetShaderInfoLog(vertexShader, infoLen, NULL, infoLog);
NSLog(@"Error compiling shader: %s",infoLog);
free(infoLog);
}
exit(1);
}
if(vertexShader == 0){
NSLog(@"Some sort of vertex error");
}
NSLog(@"%i",vertexShader);
No compiling errors, yet my if statement testing for a NULL shader is called and the value of the shader is 0.
Could anyone assist me in finding what's happening?
Thanks!