Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open GL Error: Use of undeclared identifier 'gl_FragColor'

Tags:

xcode

ios

iphone

I am not understanding what was the error here. Please tell me how to resolve the error i am new to openGL developement. It is not compiling it is showing error like this ERROR: 0:4: Use of undeclared identifier 'gl_FragColor'

-(void)compileShaders{
GLuint vertexShader = [self compileShader:@"SimpleVertex" withType:GL_VERTEX_SHADER];
GLuint fragmentShader = [self compileShader:@"SimpleFragment" withType:GL_VERTEX_SHADER];

GLuint programHandle = glCreateProgram();
glAttachShader(programHandle, vertexShader);
glAttachShader(programHandle, fragmentShader);
glLinkProgram(programHandle);

GLint linkSuccess;
glGetProgramiv(programHandle, GL_LINK_STATUS, &linkSuccess);
if (linkSuccess == GL_FALSE) {
    GLchar messages[256];
    glGetProgramInfoLog(programHandle, sizeof(messages), 0, &messages[0]);
    NSString *messageString = [NSString stringWithUTF8String:messages];
    NSLog(@"%@",messageString);
    exit(1);
}
glUseProgram(programHandle);
_positionSlot = glGetAttribLocation(programHandle, "Position");
_colorSlot = glGetAttribLocation(programHandle, "Sourcecolor");
glEnableVertexAttribArray(_positionSlot);
glEnableVertexAttribArray(_colorSlot);
}
like image 342
Sumanth Avatar asked Jul 04 '12 12:07

Sumanth


1 Answers

Modify the line 2 like this

GLuint fragmentShader = [self compileShader:@"SimpleFragment" withType:GL_FRAGMENT_SHADER];

You should compile fragments in Fragment shader.

like image 166
Sumanth Avatar answered Oct 19 '22 23:10

Sumanth