2012-07-04 53 views
5

我不明白這裏的錯誤是什麼。請告訴我如何解決我對openGL開發的新錯誤。它不是編譯它顯示像這樣ERROR: 0:4: Use of undeclared identifier 'gl_FragColor'打開GL錯誤:使用未聲明的標識符'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); 
} 

回答

9

錯誤修改行2這樣

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

你應該在片段着色器編譯片段。

相關問題