我正在尝试使用GLUT在Mac OS X(Mountain Lion)上编写一个简单的OpenGL 3.2(带有GLSL 1.5)程序,但我一直从glValidateProgram中收到错误:
'验证失败:当前绘制帧缓冲无效。'
这个错误可能是由什么引起的?
我正在尝试使用GLUT在Mac OS X(Mountain Lion)上编写一个简单的OpenGL 3.2(带有GLSL 1.5)程序,但我一直从glValidateProgram中收到错误:
'验证失败:当前绘制帧缓冲无效。'
这个错误可能是由什么引起的?
- (BOOL)validateProgram:(GLuint)prog
包含在 ViewController.mm
(不是 .m
因为我早期感染了C ++),但是这个示例代码并没有提供任何调用它的代码。// ************************************** Save the Current Viewport Size
GLint screenViewPort[4];
glGetIntegerv(GL_VIEWPORT, screenViewPort);
// ***************************** Define a Second Output Buffer and Bind it for Writing
glGenFramebuffersEXT(1, wispSecondOutputBuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wispSecondOutputBuffer[0]);
// ******************************* Set the Viewport to the Texture Size and Reshape
glViewport(0,0,TEXTUREWIDTH, TEXTUREHEIGHT);
[self resizeTextureGL]; // Calculates new Model, View and Projection Matrices
// ************************************** Create the Output Imgage Texture
glGenTextures( 1, wispOutputTexture);
glBindTexture(GL_TEXTURE_2D, wispOutputTexture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)TEXTUREWIDTH, (GLsizei)TEXTUREHEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// ********************************* Attach the Output Texture to the Frame Buffer
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, wispOutputTexture[0], 0);
GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers);
// ************************************ Check that the Frame Buffer is Complete
GLenum frameBufferStatus;
frameBufferStatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if(frameBufferStatus != GL_FRAMEBUFFER_COMPLETE_EXT) NSLog(@"There is a problem with the output frame buffer");
// ****************************************** Render to the Texture
[self runTextureShaders];
[self runTextureShaders2];
// ************************************ Reset the Viewport and Frame Buffer
glViewport(screenViewPort[0],screenViewPort[1],(GLsizei)screenViewPort[2], (GLsizei)screenViewPort[3]);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
这是个老问题。
在iOS中使用GLKView和GLKViewController时,尝试在viewDidLoad中进行验证会导致此错误。
当framebuffer准备就绪时,在ViewDidAppear中进行操作。