Skip to content
Open
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
6 changes: 3 additions & 3 deletions cmake/gles/README.md
Original file line number Diff line number Diff line change
@@ -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.
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.
16 changes: 13 additions & 3 deletions src/libprojectM/Renderer/TextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,23 @@ auto TextureManager::LoadTexture(const ScannedFile& file) -> std::shared_ptr<Tex

int width{};
int height{};
int channels{};

unsigned int const tex = SOIL_load_OGL_texture(
file.filePath.c_str(),
SOIL_LOAD_RGBA,
std::unique_ptr<unsigned char, decltype(&SOIL_free_image_data)> 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 {};
Expand Down
1 change: 1 addition & 0 deletions src/libprojectM/UserSprites/MilkdropSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 8 additions & 2 deletions src/libprojectM/projectM4Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading