我应该如何调试这个?目前我正在使用 OpenGL Profiler,并打印日志以查看发生了什么。但是,似乎错误发生在其他地方,我不确定如何找出导致问题的原因。
我的代码:
vertexCount = 3;
GLfloat vertices[] = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
};
/* Create Buffer -- (I know this shoudn't be done every frame, but I wanted to be sure the buffer wasn't getting lost somehow */
GLuint buffer[1];
glGenBuffers(1, buffer);
// -- vertices
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * vertexCount, &vertices, GL_STATIC_DRAW);
/* Render */
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glVertexAttribPointer(
0, /* attribute */
1, /* size */
GL_FLOAT, /* type */
GL_FALSE, /* normalized? */
sizeof(GLfloat)*2, /* stride */
(void*)0 /* array buffer offset */
);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, vertexCount);
glDisableVertexAttribArray(0);
if(glGetError())
NSLog(@"Error!");
else
NSLog(@"No error");
...和控制台日志:
10/12/12 2:34:26.000 PM kernel[0]: NVDA(OpenGL): Channel exception! exception type = 0xd = GR: SW Notify Error
10/12/12 2:34:26.000 PM kernel[0]: IOVendorGLContext::ReportGPURestart
10/12/12 2:34:26.000 PM kernel[0]: 0000006e
10/12/12 2:34:26.000 PM kernel[0]: 00100000 00008597 00000474 00000000
10/12/12 2:34:26.000 PM kernel[0]: 0000047e 00000904 00008000 0000000e
10/12/12 2:34:26.000 PM kernel[0]: 00000000 00000000 00000000
10/12/12 2:34:26.000 PM kernel[0]: 00000000 0000000c