diff --git a/CMakeLists.txt b/CMakeLists.txt index f4c624e549..c774b983e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,8 +169,10 @@ else() 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") + if (CMAKE_VERSION VERSION_LESS_EQUAL "3.26" OR CMAKE_SYSTEM_NAME STREQUAL Android) + # 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") + endif() find_package(OpenGL REQUIRED COMPONENTS GLES3) if(NOT TARGET OpenGL::GLES3) message(FATAL_ERROR "No suitable GLES3 library was found.") diff --git a/cmake/gles/README.md b/cmake/gles/README.md index 4ab81ff55e..5fdfffd52d 100644 --- a/cmake/gles/README.md +++ b/cmake/gles/README.md @@ -1,7 +1,7 @@ # GLES3 Find Script The OpenGL CMake find script in this directory contains additional code to find GLES versions 1 to 3. It was taken from -CMake 3.22 and patched accordingly. A merge request is underway upstream, so ideally, this will be part of CMake 3.23+. +CMake 3.22 and patched accordingly. A merge request was accepted upstream, it is part of CMake 3.27. -In the meantime, we'll use this script as a local copy if GLES3 support is requested. Will add a version check once it's -in upstream CMake so this file will only be used if the CMake version used to build projectM is too low. \ No newline at end of file +We use this script for CMake lower than 3.27 as a local copy if GLES3 support is requested to provide compatibility. A version check +compares the current CMake version so this file will only be used if the CMake version used to build projectM is too low. \ No newline at end of file diff --git a/src/libprojectM/Renderer/TextureManager.cpp b/src/libprojectM/Renderer/TextureManager.cpp index 858c7b7790..ebed793baf 100644 --- a/src/libprojectM/Renderer/TextureManager.cpp +++ b/src/libprojectM/Renderer/TextureManager.cpp @@ -212,13 +212,23 @@ auto TextureManager::LoadTexture(const ScannedFile& file) -> std::shared_ptr imageData(SOIL_load_image(file.filePath.c_str(), &width, &height, &channels, SOIL_LOAD_RGBA), SOIL_free_image_data); + + if (imageData == nullptr) + { + return {}; + } + + unsigned int const tex = SOIL_create_OGL_texture( + imageData.get(), + &width, &height, SOIL_LOAD_RGBA, SOIL_CREATE_NEW_ID, SOIL_FLAG_MULTIPLY_ALPHA); + imageData.reset(); + if (tex == 0) { return {}; diff --git a/src/libprojectM/UserSprites/MilkdropSprite.cpp b/src/libprojectM/UserSprites/MilkdropSprite.cpp index a5edd67ee3..aa5c4bf49b 100644 --- a/src/libprojectM/UserSprites/MilkdropSprite.cpp +++ b/src/libprojectM/UserSprites/MilkdropSprite.cpp @@ -28,6 +28,7 @@ namespace UserSprites { MilkdropSprite::MilkdropSprite() : m_mesh(Renderer::VertexBufferUsage::DynamicDraw, false, true) { + m_mesh.SetRenderPrimitiveType(Renderer::Mesh::PrimitiveType::TriangleStrip); m_mesh.SetVertexCount(4); } diff --git a/src/libprojectM/projectM4Config.cmake.in b/src/libprojectM/projectM4Config.cmake.in index 00244c4dff..49338e66c0 100644 --- a/src/libprojectM/projectM4Config.cmake.in +++ b/src/libprojectM/projectM4Config.cmake.in @@ -6,8 +6,14 @@ include(CMakeFindDependencyMacro) if(NOT "@ENABLE_EMSCRIPTEN@") # ENABLE_EMSCRIPTEN if("@ENABLE_GLES@") # ENABLE_GLES - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") - find_dependency(OpenGL COMPONENTS GLES3) + if (CMAKE_VERSION VERSION_LESS_EQUAL "3.26" OR CMAKE_SYSTEM_NAME STREQUAL Android) + set(PROJECTM4_PREV_MODULE_PATH ${CMAKE_MODULE_PATH}) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + find_dependency(OpenGL COMPONENTS GLES3) + set(CMAKE_MODULE_PATH ${PROJECTM4_PREV_MODULE_PATH}) + else() + find_dependency(OpenGL COMPONENTS GLES3) + endif() else() find_dependency(OpenGL) endif()