笔记:
挖了一圈,结果发现glCreateProgram()
一直返回 0。一旦我弄清楚这一点,我会发布一个修复程序。有知道是什么原因的小伙伴请留言^^
context
被正确创建。
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
谢谢。
此文件正在正确加载。它被保存为 cl.vsh
它加载正常,但在编译阶段失败。
这是 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;
}
这是编译部分。shaderString
是 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);
}
}
打印日志_
(lldb) p log
(GLchar *) $0 = 0x17420000
(lldb) po log
[no Objective-C description available]
(lldb) p *log
(GLchar) $2 = '\0'