gpt4 book ai didi

iphone - 打开 GL 错误 : Use of undeclared identifier 'gl_FragColor'

转载 作者:可可西里 更新时间:2023-11-01 04:23:57 24 4
gpt4 key购买 nike

我不明白这里的错误是什么。请告诉我如何解决我是 openGL 开发新手的错误。它没有编译它显示这样的错误 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);
}

最佳答案

像这样修改行 2

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

您应该在片段着色器中编译片段。

关于iphone - 打开 GL 错误 : Use of undeclared identifier 'gl_FragColor' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11328792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com