flyx / OpenGLAda

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

Trouble reading pixel data #103

Closed rogermc2 closed 6 years ago

rogermc2 commented 6 years ago

I am having a problem trying to "read pixels" with the following code:

   type Pixels_Array is array (Positive range <>) of aliased Integer;
   procedure Read_Pix is new
     GL.Framebuffer.Read_Pixels (Element_Type => Integer,
                                 Index_Type   => Positive,
                                 Array_Type   => Pixels_Array);

...

      Pixel_Data      : Pixels_Array (1 .. 4);

.....

Read_Pix (1, 1, 1024 / 2, 768 / 2, GL.Pixels.RGBA, GL.Pixels.Unsigned_Byte, Pixel_Data);

The above code produces the warning:

main_loop.adb:145:07: warning: variable "Pixel_Data" is read but never assigned

This suggests that Read_Pix is reading from Pixel_Data instead of writing to it as glReadPixels is specified to do. OpenGLAda declarations for Read_Pixels appear OK. Am I doing something wrong?

flyx commented 6 years ago

The Data parameter of Read_Pixels is missing an out qualifier. You can add it yourself if you want.

rogermc2 commented 6 years ago

Of course but I missed seeing that. I fixed it in the framebuffer files and it compiles OK now. Does anything need to be done in API.Read_Pixels. Thanks

flyx commented 6 years ago

I think the API import is fine.

rogermc2 commented 6 years ago

OK. Thanks. My program is crashing on the Read_Pix instruction but presumably that's something else that I will have to sort out.