ABRG-Models / morphologica

A library of supporting code for numerical modelling (JSON config, HDF5 data, Modern OpenGL visualization)
https://abrg-models.github.io/morphologica/
Apache License 2.0
255 stars 29 forks source link

This project can run under Windows with msys2 and gcc #152

Closed asmwarrior closed 6 months ago

asmwarrior commented 10 months ago

Hi, I have just tried this project. Looks good!

I'm testing a very simple hello world project under: Windows 10, Code::Blocks IDE, msys2. Note that msys2 supplied many packages, include: freetype, glfw3, flew, opencv.

Here is the screen shot:

image

I'm not good at CMake, I can only supply Code::Blocks project files.

asmwarrior commented 10 months ago

image

The above image is my another test to run the test file: examples\graph1.cpp.

When I start the program, an ampty window will first pop up, and I need to wait a few seconds to see the actual graph inside the window, I'm not sure this is by design, I see it also happens in the "hello world" sample code.

asmwarrior commented 10 months ago

I see an error message in the console window, see below:

image

This message happens in many test cases.

sebjameswml commented 10 months ago

Hi! Thanks for experimenting with the code on Windows. I'm glad you had some success.

The delays you report between window and graphics are not expected, so that's definitely an issue. I wonder what's happening...

The error about failing to make the context current may well be related. you could experiment with Visual::setContext - perhaps theres a short time with this platform during which the GL env is not ready.

sebjameswml commented 10 months ago

Would you like to contribute build instructions for msys2?

asmwarrior commented 10 months ago

I can help, but I'm not good at cmake. In-fact, I'm good at Code::Blocks.

I have a change to my fork: under msys2+gcc, I have to comment out the header files, because I have no such header files, but the build still look OK

With this change, I can build your project under msys2 and mingw64 gcc.

Also, here is the Code::Blocks cbp file content:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
    <FileVersion major="1" minor="6" />
    <Project>
        <Option title="glfwtest" />
        <Option pch_mode="2" />
        <Option compiler="gcc" />
        <Build>
            <Target title="Debug">
                <Option output="bin/Debug/glfwtest" prefix_auto="1" extension_auto="1" />
                <Option object_output="obj/Debug/" />
                <Option type="1" />
                <Option compiler="gcc" />
                <Compiler>
                    <Add option="-g" />
                </Compiler>
            </Target>
            <Target title="Release">
                <Option output="bin/Release/glfwtest" prefix_auto="1" extension_auto="1" />
                <Option object_output="obj/Release/" />
                <Option type="1" />
                <Option compiler="gcc" />
                <Compiler>
                    <Add option="-O2" />
                </Compiler>
                <Linker>
                    <Add option="-s" />
                </Linker>
            </Target>
        </Build>
        <Compiler>
            <Add option="-Wall" />
            <Add option="-fexceptions" />
            <Add option="-DUSE_GLEW" />
            <Add option="-D__WIN__" />
            <Add directory="F:/code/morphologica/" />
            <Add directory="F:/msys2/mingw64/include/freetype2/" />
            <Add directory="F:/code/morphologica/include" />
        </Compiler>
        <Linker>
            <Add option="`pkg-config --libs glm`" />
            <Add option="`pkg-config --libs glfw3`" />
            <Add option="`pkg-config --libs glew`" />
            <Add option="`pkg-config --cflags freetype2`" />
            <Add library="opengl32" />
            <Add library="freetype" />
        </Linker>
        <Unit filename="main.cpp" />
        <Extensions />
    </Project>
</CodeBlocks_project_file>

You can see the include paths in the cbp file, also you can see the linker options in this cbp file.

sebjameswml commented 10 months ago

Thanks for the info.

sebjameswml commented 6 months ago

Closing this issue as I've incorporated the discussion into the code now.