When rendering to framebuffer that is not the default one there'll be error 'GL_INVALID_FRAMEBUFFER_OPERATION'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

When rendering to framebuffer that is not the default one there'll be error 'GL_INVALID_FRAMEBUFFER_OPERATION'

HamudHaa
I designed a constructor function that will run when init method of the implemented GLEventListener is called. Then I have glGetError in display method .
Inside the constructor function I designed , I have glBindFramebuffer which binds a user-defined fbo to GL_FRAMEBUFFER .
The problem is , when my program is launched :
1.If I bind that fbo to GL_FRAMEBUFFER . The glGetError in display will output GL_INVALID_FRAMEBUFFER_OPERATION error .
2.If I bind 0 to GL_FRAMEBUFFER( I guess it means default ?) , then no error
I'm sure the user-defined FBO is okay . Because even if I had it to firstly execute glBindFramebuffer( not the 0 one)  then secondly execute glBindFramebuffer( the 0 one)  there's no error.
So I wonder if you really have to render things into the default frame buffer when the program is initialized
Reply | Threaded
Open this post in threaded view
|

Re: When rendering to framebuffer that is not the default one there'll be error 'GL_INVALID_FRAMEBUFFER_OPERATION'

HamudHaa
Alright . Immediately after I sent this pose , I realized what I've ignored . The problem happens each time I'm writing something into my user-defined buffer. So when the program is writing things into it , there's an error . I discovered this by glCheckFramebufferStatus , which is hidden if there's nothing going to be written into that problem buffer . In this case , I soon replaced it with the default one .
The problem I got is GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT . This is not given by glGetError
Reply | Threaded
Open this post in threaded view
|

Re: When rendering to framebuffer that is not the default one there'll be error 'GL_INVALID_FRAMEBUFFER_OPERATION'

HamudHaa
Can anyone help me with my codes ? I can't really figure out what went wrong . They are keeping GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT all through . But I do think I have attached the image to the attachpoint . Thanks for your replies
GL3 gl = Drawable.getGL().getGL3();
gl.glGenFramebuffers(1, RenderTarget);
gl.glBindFramebuffer(GL3.GL_FRAMEBUFFER, RenderTarget.get(0));
gl.glGenTextures(0, Texture);
gl.glBindTexture(GL3.GL_TEXTURE_2D, Texture.get(0));
gl.glTexImage2D(GL3.GL_TEXTURE_2D, 0, GL3.GL_RGB, TargetFrameSize, TargetFrameSize, 0, GL3.GL_RGB, GL3.GL_UNSIGNED_BYTE, null);
gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_MAG_FILTER, GL3.GL_NEAREST);
gl.glTexParameteri(GL3.GL_TEXTURE_2D, GL3.GL_TEXTURE_MIN_FILTER, GL3.GL_NEAREST);
gl.glFramebufferTexture(GL3.GL_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, Texture.get(0), 0);
IntBuffer Control = IntBuffer.allocate(1);
Control.put(GL3.GL_COLOR_ATTACHMENT0);
Control.flip();
gl.glDrawBuffers(1, Control);
gl.glViewport(0, 0, TargetFrameSize, TargetFrameSize);
gl.glBindTexture(GL3.GL_TEXTURE_2D, 0);
RenderToScreen(Drawable);
Utils.getErrors(gl,"wtf");


_____
EDIT:
lol my brain must have exploded . I wrote gl.glGenTextures(0, Texture); omg