EQMG / Acid

A high speed C++17 Vulkan game engine
https://equilibrium.games
MIT License
1.75k stars 153 forks source link

Clarity on OpenAL Use #85

Closed LukePrzyb closed 4 years ago

LukePrzyb commented 4 years ago

Hello,

I am trying to compile together all the external libraries required, using Visual Studio 2019. So far, all libraries, except for OpenAL, are working perfectly fine when I attempt to compile a test executable (TestFont).

Sample of error coming from building TestFont:

Error   C2664   'ALCcontext *alcCreateContext(ALCdevice *,const ALCint *)': cannot convert argument 1 from 'ALCdevice *' to 'ALCdevice *'   C:\...\Visual Studio 2019\External Libraries\Acid\CMakeLists.txt    C:\...\Visual Studio 2019\Sources\Audio\Audio.cpp   line 15     

I suspect this is due to how I link OpenAL to acid in CMakeSettings.json . I am using:

OPENAL_INCLUDE_DIR  C:/.../Visual Studio 2019/External Libraries/openal-soft/include/AL
OPENAL_LIBRARY  C:/.../Visual Studio 2019/External Libraries/openal-soft/out/build/x64-Debug/OpenAL32.lib

Note: I am partially using vcpkg for some components, and not for others.

Any help would be appreciated. I will try to provide documentation details using visual studio for other people who would like to use this strategy.

mattparks commented 4 years ago

Currently I'm forward declaring both ALCdevice and ALCcontext with these signatures:

typedef struct ALCdevice_struct ALCdevice;
typedef struct ALCcontext_struct ALCcontext;

Located here: https://github.com/EQMG/Acid/blob/master/Sources/Audio/Audio.hpp#L6

If you are using openal-soft these forward-declarations will need to match their implementation:

typedef struct ALCdevice ALCdevice;
typedef struct ALCcontext ALCcontext;

Right now I'm using the OpenAL API common on Windows, Linux, and macOS. vcpkg will install openal-soft for some other projects, CMake will probably pull that version in if you don't have OPENALDIR in your path. Source: https://github.com/Kitware/CMake/blob/master/Modules/FindOpenAL.cmake

LukePrzyb commented 4 years ago

Thank you for the response.

I have changed my OpenAL include and lib to point at:

OPENAL_INCLUDE_DIR  C:/.../vcpkg/installed/x64-windows/include/AL
OPENAL_LIBRARY  C:/.../vcpkg/installed/x64-windows/lib/OpenAL32.lib

as a result, your recommendations were not necessary. Additional corrections had to be made (strange SPIR and physfs include pointing from vcpkg, stay on release to avoid LNK errors with debug).

I will provide some documentation information in the near future for your README once I feel confident with building your project, and can correctly recreate it in the future. Regardless, thank you for the speedy assistance.