Legolas
Legolas

Reputation: 12335

glCreateProgram() fails?

Note:

After digging around, it turns out glCreateProgram() is returning 0 all the time. I will post a fix once I figure this out. If you guys know what might be causing it, please leave a comment ^^

context is created properly.

context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

Thanks.


This file is being loaded properly. It is saved as cl.vsh

It is loaded fine, but fails in the compilation stage.

This is the code in cl.vsh

attribute vec4 position;
attribute vec3 normal;

uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat3 normalMatrix;

uniform float time;

varying vec3 eyespaceNormal;
varying vec4 eyespacePosition;
varying vec3 noiseVector;


void main()
{

    int i = 0;
//    vec3 translation = vec3(1.0, 1.0, 1.0) * time / 20.0;
//    noiseVector = position.xyz + translation;
//    
//    eyespaceNormal = normalMatrix * normal;
//    eyespacePosition = modelViewMatrix * position;
//    gl_Position = modelViewProjectionMatrix * position;
}

This is the compilation part. shaderString is the exact code of cl.vsh

 GLint status;
    const GLchar *source;

    source = 
      (GLchar *)[shaderString UTF8String];
    if (!source)
    {
        NSLog(@"Failed to load vertex shader");
        return NO;
    }

    *shader = glCreateShader(type);
    glShaderSource(*shader, 1, &source, NULL);
    glCompileShader(*shader);

    glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);

    if (status != GL_TRUE)
    {
        GLint logLength;
        glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);
        if (logLength > 0)
        {
            GLchar *log = (GLchar *)malloc(logLength);
            glGetShaderInfoLog(*shader, logLength, &logLength, log);
            NSLog(@"Shader compile log:\n%s", log);
            free(log);
        }
    }   

printing out log_

(lldb) p log
(GLchar *) $0 = 0x17420000
(lldb) po log
[no Objective-C description available]
(lldb) p *log
(GLchar) $2 = '\0'

Upvotes: 1

Views: 3295

Answers (1)

Legolas
Legolas

Reputation: 12335

After some digging, I realized I need to set my context as current context. FML. This was the problem

[EAGLContext setCurrentContext:context];

The problem is now FIXED.

Upvotes: 7

Related Questions