flyx / OpenGLAda

Thick Ada binding for OpenGL and GLFW
flyx.github.io/OpenGLAda/
MIT License
96 stars 13 forks source link

Problem Clearing Framebuffer #24

Closed rogermc2 closed 7 years ago

rogermc2 commented 7 years ago

I am trying to implement: glBindFramebuffer(GL_FRAMEBUFFER, fbo); glViewport(0, 0, 512, 512); glClearBufferfv(GL_COLOR, 0, sb7::color::Green); By: Read_And_Draw_Target.Bind(Frame_Buffer); GL.Window.Set_Viewport(0, 0, 512, 512); gl.Buffers.Clear((True, False, True, True)); gl.Buffers.Set_Color_Clear_Value(Green); but gl.Buffers.Clear((True, False, True, True)); raises the exception GL.ERRORS.INVALID_FRAMEBUFFER_OPERATION_ERROR : gl-raise_exception_on_opengl_error.adb:26 I have declared: subtype tFrame_Buffer is GL.Objects.Framebuffers.Framebuffer; Frame_Buffer : tFrame_Buffer; Green : GL.Types.Colors.Color := (0.0, 1.0, 0.0, 1.0);

gl.Buffers.Set_Color_Clear_Value(Green); seems OK as no error occurs when I comment out the gl.Buffers.Clear line. This code works OK for the default framebuffer (Read_And_Draw_Target.Bind(Default_Framebuffer)) I have also tried gl.Buffers.Clear_Color_Buffers(gl.Buffers.Back, Green); but this also raises an error.

flyx commented 7 years ago

Did you call Initialize_Id on the framebuffer? Also, check Status on the framebuffer. It must be Complete in order for any operation to succeed.

rogermc2 commented 7 years ago

I did call Initialize_Id on the framebuffer in a deeper initialization routine, but apparently I did something wrong in the calling sequence. Moving it to a higher level routine seems to have fixed my problem and may be a clue to other problems I'm having. Could it be that something goes out of scope when I leave the original initialization routine even though I've used Frame_Buffer : in out tFrame_Buffer as one of the initialization routine's parameters? Thanks for the clue. I'll also make use of the Status function.

flyx commented 7 years ago

If you want an answer to that question, you'd need to show me the full source code.

rogermc2 commented 7 years ago

OK; if I can't figure it out myself. However, I suspect that your comments against my pull request program may provide the answer.