I am trying to write a simple OpenGL 3.2 (with GLSL 1.5) program using GLUT on Mac OS X (Mountian Lion), but I keep getting error from glValidateProgram:
我正在尝试编写一个简单的OpenGL 3.2(使用GLSL 1.5)程序,使用Mac OS X (Mountian Lion)上的供过于求。
'Validation Failed: Current draw framebuffer is invalid.'
“验证失败:当前绘制框架缓冲区无效。”
What could cause this error to occur?
什么会导致这个错误发生?
3 个解决方案
#1
1
Like the OP i have encountered some code that uses this, and without knowing any better I implemented it immediately after the program link step. Got the same error.
和OP一样,我也遇到过一些使用这种方法的代码,我在程序链接步骤之后立即实现了它。有同样的错误。
I am no expert here but based on a few observations i thought I'd clarify what @robinjam seems to be saying (which echoes what the GL docs say about glValidateProgram
).
我不是这方面的专家,但基于一些观察,我认为我应该澄清@robinjam似乎在说什么(这与GL文档中关于glValidateProgram的说法不谋而合)。
The sample code I was using was Apple's iOS test OpenGL ES 2.0 demo project, and I haven't run this exact piece of code on a device yet but the Simulator gives me this Validation Failed: Current draw framebuffer is invalid.
error. However, it is relevant to note that the method which runs this, - (BOOL)validateProgram:(GLuint)prog
, is included in the ViewController.mm
(not .m
because I infected it with C++ early on) but there is no code provided with this sample code that actually calls it.
我使用的示例代码是苹果的iOS测试OpenGL ES 2.0演示项目,我还没有在设备上运行这段代码,但是模拟器给我的验证失败了:当前绘制框架缓冲区无效。错误。但是,需要注意的是,运行这个(BOOL)validateProgram:(GLuint)prog的方法被包含在ViewController中。mm(不是.m,因为我在早期就用c++感染了它),但是这个示例代码没有提供实际调用它的代码。
So the purpose of glValidateProgram is not to use it as an added "check" step after linking the program, because the GL and application state is hardly ready for actually using that program at this point, probably it's even before we get around to initializing the default framebuffer (its bitdepth, its multisample buffers, etc), and that's what the error hints at.
glValidateProgram的目的是为了使用它作为一个额外的“检查”步骤链接程序后,因为GL和应用程序状态很难准备好实际使用这个项目在这一点上,甚至是在我们去之前初始化默认framebuffer(bitdepth,multisample缓冲区,等等),这就是错误的暗示。
An appropriate place to call glValidateProgram would be right before you make a real render call.
在进行真正的渲染调用之前,调用glValidateProgram的适当位置是正确的。
It would be useful for debugging. It's an optional way for us to give a way for the driver to help us out when something seems to have gone wrong. It would be silly to call this every time we render in a non-debugging situation where everything is working smoothly.
这对于调试是有用的。这是一种可选的方式,当事情似乎出了问题时,我们可以让司机帮我们。每当我们在非调试的情况下,一切都运行得很顺利时,调用这个函数是很愚蠢的。
#2
0
If this helps, the code below creates a valid frame buffer for writing that is different from the default screen render buffer, writes to it then resets the screen buffer.
如果有帮助,下面的代码将创建一个有效的框架缓冲区,用于编写与默认屏幕呈现缓冲区不同的内容,然后对其进行写入,然后重新设置屏幕缓冲区。
// ************************************** 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);
#3
0
It's old question.
这是老问题。
When I use GLKView and GLKViewcontroller in iOS, trying validation in viewDidLoad makes this error.
当我在iOS中使用GLKView和GLKViewcontroller时,在viewDidLoad尝试验证会导致这个错误。
Do it in ViewDidAppear when the framebuffer is ready.
在ViewDidAppear中执行时,框架缓冲区已经准备好。
#1
1
Like the OP i have encountered some code that uses this, and without knowing any better I implemented it immediately after the program link step. Got the same error.
和OP一样,我也遇到过一些使用这种方法的代码,我在程序链接步骤之后立即实现了它。有同样的错误。
I am no expert here but based on a few observations i thought I'd clarify what @robinjam seems to be saying (which echoes what the GL docs say about glValidateProgram
).
我不是这方面的专家,但基于一些观察,我认为我应该澄清@robinjam似乎在说什么(这与GL文档中关于glValidateProgram的说法不谋而合)。
The sample code I was using was Apple's iOS test OpenGL ES 2.0 demo project, and I haven't run this exact piece of code on a device yet but the Simulator gives me this Validation Failed: Current draw framebuffer is invalid.
error. However, it is relevant to note that the method which runs this, - (BOOL)validateProgram:(GLuint)prog
, is included in the ViewController.mm
(not .m
because I infected it with C++ early on) but there is no code provided with this sample code that actually calls it.
我使用的示例代码是苹果的iOS测试OpenGL ES 2.0演示项目,我还没有在设备上运行这段代码,但是模拟器给我的验证失败了:当前绘制框架缓冲区无效。错误。但是,需要注意的是,运行这个(BOOL)validateProgram:(GLuint)prog的方法被包含在ViewController中。mm(不是.m,因为我在早期就用c++感染了它),但是这个示例代码没有提供实际调用它的代码。
So the purpose of glValidateProgram is not to use it as an added "check" step after linking the program, because the GL and application state is hardly ready for actually using that program at this point, probably it's even before we get around to initializing the default framebuffer (its bitdepth, its multisample buffers, etc), and that's what the error hints at.
glValidateProgram的目的是为了使用它作为一个额外的“检查”步骤链接程序后,因为GL和应用程序状态很难准备好实际使用这个项目在这一点上,甚至是在我们去之前初始化默认framebuffer(bitdepth,multisample缓冲区,等等),这就是错误的暗示。
An appropriate place to call glValidateProgram would be right before you make a real render call.
在进行真正的渲染调用之前,调用glValidateProgram的适当位置是正确的。
It would be useful for debugging. It's an optional way for us to give a way for the driver to help us out when something seems to have gone wrong. It would be silly to call this every time we render in a non-debugging situation where everything is working smoothly.
这对于调试是有用的。这是一种可选的方式,当事情似乎出了问题时,我们可以让司机帮我们。每当我们在非调试的情况下,一切都运行得很顺利时,调用这个函数是很愚蠢的。
#2
0
If this helps, the code below creates a valid frame buffer for writing that is different from the default screen render buffer, writes to it then resets the screen buffer.
如果有帮助,下面的代码将创建一个有效的框架缓冲区,用于编写与默认屏幕呈现缓冲区不同的内容,然后对其进行写入,然后重新设置屏幕缓冲区。
// ************************************** 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);
#3
0
It's old question.
这是老问题。
When I use GLKView and GLKViewcontroller in iOS, trying validation in viewDidLoad makes this error.
当我在iOS中使用GLKView和GLKViewcontroller时,在viewDidLoad尝试验证会导致这个错误。
Do it in ViewDidAppear when the framebuffer is ready.
在ViewDidAppear中执行时,框架缓冲区已经准备好。