flyx / OpenGLAda

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

glfw puzzle #71

Closed ohenley closed 7 years ago

ohenley commented 7 years ago
  1. Instructions on how to install glfw would be great. Right now I am on windows.

a) glfw 2.x.x is not available for download at official site anymore. Maybe remove binding to version 2. b) if I am not mistaken, in all case, we need the mingw 32 bits version of the bins. Like 4 others type of bins are hand out in the distribution zip archive. c) the simpler I found was to c&p the glfw bins right next to ld.exe used by my gnat installation. Probably there is better way but never learned how. d) In opengl_glfw.gpr this snippet does not work: when "3" => GLFW_Sources := GLFW_Sources & "src\glfw\v3"; Shared_Test_Sources := Shared_Test_Sources & "tests/shared/glfw3_backend"; GLFW_Lib := "-lglfw";

We should read GLFW_Lib := "-lglfw3";

Thx.

flyx commented 7 years ago

Maybe remove binding to version 2.

Will not happen because it's working. GLFW 2 is still available in most package managers.

if I am not mistaken, in all case, we need the mingw 32 bits version of the bins.

Depends on your target, of course. You can perfectly compile your Ada code to 64bit binary, for example with the mingw64-x86_64-gcc-ada package from MinGW. But if you are using AdaCore's binaries, then you do need the 32bit binaries.

the simpler I found was to c&p the glfw bins right next to ld.exe used by my gnat installation.

You can also provide a flag -L/path/to/glfw/bins to the linker.

In opengl_glfw.gpr this snippet does not work:

when "3" =>
GLFW_Sources := GLFW_Sources & "src\glfw\v3";
Shared_Test_Sources := Shared_Test_Sources & "tests/shared/glfw3_backend";
GLFW_Lib := "-lglfw";

We should read GLFW_Lib := "-lglfw3";

The problem is that some Linux distributions switched to taking -lglfw instead of -lglfw3 for linking to GLFW. Same is true for macOS. This is why the line is at it is – it supports the majority of operating systems. Sadly, this means that Windows users need to adapt the file. This should be better documented.

On the long run, it might make sense to generate the *.gpr files with a configure script and provide an installation mechanism. I might have a look at GPRConfig at some point and see if it can solve these problems. However, this is a lot of work for a project that has as few maintainers as this one. I cannot guarantee that I find the time to make this work reliably.

ohenley commented 7 years ago

this works:

case GLFW_Version is
      when "2" =>
         GLFW_Sources := GLFW_Sources & "src/glfw/v2";
         Shared_Test_Sources := Shared_Test_Sources & "tests/shared/glfw2_backend";
         GLFW_Lib := "-lglfw";
      when "3" =>
         GLFW_Sources := GLFW_Sources & "src\glfw\v3";
         Shared_Test_Sources := Shared_Test_Sources & "tests/shared/glfw3_backend";

         case OpenGL_Shared.Windowing_System is
            when "quartz" =>
               GLFW_Lib := "-lglfw";
            when "windows" =>
               GLFW_Lib := "-lglfw3";
            when "x11" =>
               GLFW_Lib := "-lglfw";
         end case;

end case;