diff --git a/CMakeLists.txt b/CMakeLists.txt index 32c47e71ea..7e61f52664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,36 +166,12 @@ else() if(ENABLE_GLES) message(STATUS "Building for OpenGL Embedded Profile") - if(NOT CMAKE_SYSTEM_NAME STREQUAL Linux - AND NOT CMAKE_SYSTEM_NAME STREQUAL Android) - message(FATAL_ERROR "OpenGL ES 3 support is currently only available for Linux platforms. You're building for ${CMAKE_SYSTEM_NAME}.") - endif() - - # We use a local find script for OpenGL::GLES3 until the proposed changes are merged upstream. - list(APPEND CMAKE_MODULE_PATH "${PROJECTM_SOURCE_DIR}/cmake/gles") - find_package(OpenGL REQUIRED COMPONENTS GLES3) - if(NOT TARGET OpenGL::GLES3) - message(FATAL_ERROR "No suitable GLES3 library was found.") - endif() - - set(PROJECTM_OPENGL_LIBRARIES OpenGL::GLES3) set(USE_GLES ON) 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() + if(WIN32) + find_package(OpenGL REQUIRED) + set(PROJECTM_OPENGL_LIBRARIES OpenGL::GL) endif() endif() endif() diff --git a/src/api/include/projectM-4/core.h b/src/api/include/projectM-4/core.h index b54e698682..9a42545ac0 100644 --- a/src/api/include/projectM-4/core.h +++ b/src/api/include/projectM-4/core.h @@ -32,18 +32,51 @@ extern "C" { #endif +/** + * @brief Callback function for resolving function pointers. + * + * This callback functions is used to resolve platform-dependent GL function pointers. + * + * @param name The name of the function to resolve. + * @param user_data A user-defined data pointer that is passed along with the load proc call, + * e.g. context information. + * @since 4.2.0 + */ +typedef void* (*projectm_load_proc)(const char* name, void* user_data); + /** * @brief Creates a new projectM instance. * * If this function returns NULL, in most cases the OpenGL context is not initialized, not made * current or insufficient to render projectM visuals. * + * The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc(). + * All projectM instances share the same resolver. + * * @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.0.0 */ 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. + * + * The OpenGL resolver is initialized on the first call to either projectm_create() or projectm_create_with_opengl_load_proc(). + * All projectM instances share the same resolver, and subsequent calls ignore the provided load_proc. + * + * @param load_proc Callback function used to resolve OpenGL function pointers. Optional, may be NULL. + * @param user_data Custom user data pointer to pass along to the load_proc call, e.g. context information. Optional, may be NULL. + * @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(projectm_load_proc load_proc, 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 1e226458fc..8768b7d0e4 100644 --- a/src/libprojectM/CMakeLists.txt +++ b/src/libprojectM/CMakeLists.txt @@ -6,6 +6,10 @@ add_compile_definitions( $,STBI_NO_DDS,> ) +include_directories( + "${PROJECTM_SOURCE_DIR}/vendor/glad/include" + ) + add_subdirectory(Audio) add_subdirectory(MilkdropPreset) add_subdirectory(Renderer) @@ -70,6 +74,7 @@ add_library(projectM $ $ $ + $ ) target_include_directories(projectM @@ -84,6 +89,7 @@ if(ENABLE_CXX_INTERFACE) ) endif() +# PROJECTM_OPENGL_LIBRARIES is present for WIN32/Desktop GL only target_link_libraries(projectM PUBLIC ${PROJECTM_OPENGL_LIBRARIES} @@ -261,20 +267,12 @@ if(ENABLE_INSTALL) PATH_VARS PROJECTM_BIN_DIR PROJECTM_INCLUDE_DIR ) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/libprojectM/projectM4ConfigVersion.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/libprojectM/projectM4Config.cmake" - DESTINATION "${PROJECTM_LIB_DIR}/cmake/projectM4" - COMPONENT Devel - ) - - if(NOT ENABLE_EMSCRIPTEN AND ENABLE_GLES) - install(FILES - "${PROJECTM_SOURCE_DIR}/cmake/gles/FindOpenGL.cmake" - DESTINATION "${PROJECTM_LIB_DIR}/cmake/projectM4" - COMPONENT Devel - ) - endif() + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/libprojectM/projectM4ConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/libprojectM/projectM4Config.cmake" + DESTINATION "${PROJECTM_LIB_DIR}/cmake/projectM4" + COMPONENT Devel + ) install(EXPORT libprojectMTargets FILE projectM4Targets.cmake diff --git a/src/libprojectM/MilkdropPreset/CMakeLists.txt b/src/libprojectM/MilkdropPreset/CMakeLists.txt index f8d8657cfa..d6682ae8a1 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(BUILD_SHARED_LIBS) diff --git a/src/libprojectM/ProjectMCWrapper.cpp b/src/libprojectM/ProjectMCWrapper.cpp index ad31a10d49..cd2bca2f2e 100644 --- a/src/libprojectM/ProjectMCWrapper.cpp +++ b/src/libprojectM/ProjectMCWrapper.cpp @@ -1,10 +1,13 @@ #include "ProjectMCWrapper.hpp" +#include "Renderer/Platform/GladLoader.hpp" + #include #include #include