diff --git a/BUILDING-cmake.md b/BUILDING-cmake.md index ee27dee7fe..d169e3815d 100644 --- a/BUILDING-cmake.md +++ b/BUILDING-cmake.md @@ -11,7 +11,6 @@ Required tools and dependencies: - CMake 3.21 or higher. - A working toolchain, e.g. Visual Studio on Windows or the `build-essentials` package on Ubuntu Linux. - Main OpenGL libraries and development files. -- The `GLEW` Library on Windows. To use the library in other projects, it is required to install it. Use `CMAKE_INSTALL_PREFIX` to specify the installation directory. diff --git a/BUILDING.md b/BUILDING.md index 9a3fe3127d..64b0415c4e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -100,11 +100,6 @@ development files. To build projectM, both binaries and development files need t library dependencies and/or using CMake to configure the build. Mainly used on Windows, but also works for Linux and macOS. -### Only relevant for Windows: - -* [**GLEW**](http://glew.sourceforge.net/): The OpenGL Extension Wrangler Library. Only required if using CMake to - configure the build, the pre-created solutions use a bundled copy of GLEW. - ## Building on Linux and macOS ### Installing dependencies diff --git a/CMakeLists.txt b/CMakeLists.txt index 32000a1bb8..7c170890de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,19 +183,6 @@ else() message(STATUS "Building for OpenGL Core Profile") find_package(OpenGL REQUIRED) set(PROJECTM_OPENGL_LIBRARIES OpenGL::GL) - # GLX is required by SOIL2 on platforms with the X Window System (e.g. most Linux distributions) - if(TARGET OpenGL::GLX) - list(APPEND PROJECTM_OPENGL_LIBRARIES OpenGL::GLX) - endif() - if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - find_package(GLEW REQUIRED) - # Prefer shared, but check for static lib if shared is not available. - if(TARGET GLEW::glew) - list(APPEND PROJECTM_OPENGL_LIBRARIES GLEW::glew) - elseif(TARGET GLEW::glew_s) - list(APPEND PROJECTM_OPENGL_LIBRARIES GLEW::glew_s) - endif() - endif() endif() endif() diff --git a/docs/building.rst b/docs/building.rst index 9a82b2e6a4..07b8735f4c 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -138,9 +138,6 @@ Only relevant for Windows: library dependencies and/or using CMake to configure the build. - `NuGet `__: Dependency manager for .NET. Required to build the EyeTune app. -- `GLEW `__: The OpenGL Extension - Wrangler Library. Only required if using CMake to configure the - build, the pre-created solutions use a bundled copy of GLEW. Building on Linux and macOS --------------------------- diff --git a/src/api/include/projectM-4/core.h b/src/api/include/projectM-4/core.h index b54e698682..5a30564d4a 100644 --- a/src/api/include/projectM-4/core.h +++ b/src/api/include/projectM-4/core.h @@ -44,6 +44,20 @@ extern "C" { */ PROJECTM_EXPORT projectm_handle projectm_create(); + +/** + * @brief Creates a new projectM instance using the given function to resolve GL api functions. + * + * The load_proc function accepts a function name and a user data pointer. + * If this function returns NULL, in most cases the OpenGL context is not initialized, not made + * current or insufficient to render projectM visuals. + * + * @return A projectM handle for the newly created instance that must be used in subsequent API calls. + * NULL if the instance could not be created successfully. + * @since 4.2.0 + */ +PROJECTM_EXPORT projectm_handle projectm_create_with_opengl_load_proc(void* (*load_proc)(const char*, void*), void* user_data); + /** * @brief Destroys the given instance and frees the resources. * diff --git a/src/libprojectM/CMakeLists.txt b/src/libprojectM/CMakeLists.txt index 2fc1c3160e..fe2638768f 100644 --- a/src/libprojectM/CMakeLists.txt +++ b/src/libprojectM/CMakeLists.txt @@ -6,11 +6,21 @@ add_compile_definitions( $,STBI_NO_DDS,> ) +include_directories( + "${PROJECTM_SOURCE_DIR}/vendor/glad/include" + ) + add_subdirectory(Audio) add_subdirectory(MilkdropPreset) add_subdirectory(Renderer) add_subdirectory(UserSprites) +set(PROJECTM_LINK_GL_LIBS "") +if (WIN32) + # windows libs need to link to opengl32.dll + set(PROJECTM_LINK_GL_LIBS "${PROJECTM_OPENGL_LIBRARIES}") +endif() + add_library(projectM_main OBJECT "${PROJECTM_EXPORT_HEADER}" Logging.cpp @@ -70,6 +80,7 @@ add_library(projectM $ $ $ + $ ) target_include_directories(projectM @@ -79,9 +90,9 @@ target_include_directories(projectM target_link_libraries(projectM PUBLIC - ${PROJECTM_OPENGL_LIBRARIES} libprojectM::API ${PROJECTM_FILESYSTEM_LIBRARY} + ${PROJECTM_LINK_GL_LIBS} ) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -107,6 +118,7 @@ if(BUILD_SHARED_LIBS) target_link_libraries(projectM PUBLIC ${CMAKE_DL_LIBS} + ${PROJECTM_LINK_GL_LIBS} ) else() target_compile_definitions(projectM_main diff --git a/src/libprojectM/MilkdropPreset/CMakeLists.txt b/src/libprojectM/MilkdropPreset/CMakeLists.txt index 6889d8ad2f..3231a97279 100644 --- a/src/libprojectM/MilkdropPreset/CMakeLists.txt +++ b/src/libprojectM/MilkdropPreset/CMakeLists.txt @@ -140,7 +140,6 @@ target_link_libraries(MilkdropPreset PUBLIC hlslparser GLM::GLM - ${PROJECTM_OPENGL_LIBRARIES} ) if(NOT BUILD_SHARED_LIBS) diff --git a/src/libprojectM/ProjectMCWrapper.cpp b/src/libprojectM/ProjectMCWrapper.cpp index 0c89ba64e2..1b6e1f9d7a 100644 --- a/src/libprojectM/ProjectMCWrapper.cpp +++ b/src/libprojectM/ProjectMCWrapper.cpp @@ -6,6 +6,10 @@ #include