Skip to content

Commit

Permalink
Added projectM-Eval as submodule, flipped rendering stuff around a bi…
Browse files Browse the repository at this point in the history
…t more.
  • Loading branch information
kblaschke committed Apr 4, 2023
1 parent 3d7b363 commit e506701
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/projectm-eval"]
path = vendor/projectm-eval
url = https://github.com/projectM-visualizer/projectm-eval.git
5 changes: 4 additions & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ If you want to use a stable version of projectM, download the latest release fro
the [Releases page on GitHub](https://github.com/projectM-visualizer/projectm/releases) and unpack it. You can then skip
to the next step.

If you prefer a bleeding-edge version or want to modify the code, clone the Git repository:
If you prefer a bleeding-edge version or want to modify the code, clone the Git repository and initialize any
submodules:

```bash
sudo apt install git # Probably already installed
git clone https://github.com/projectM-visualizer/projectm.git /path/to/local/repo
cd /path/to/local/repo
git fetch --all --tags
git submodule init
git submodule update
```

### Build and install projectM
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ option(ENABLE_SYSTEM_GLM "Enable use of system-install GLM library" OFF)
cmake_dependent_option(ENABLE_LLVM "Enable experimental LLVM JIT support" OFF "NOT ENABLE_EMSCRIPTEN" OFF)
option(ENABLE_CXX_INTERFACE "Enable exporting C++ symbols for ProjectM and PCM classes, not only the C API. Warning: This is not very portable." OFF)

find_package(projectM-Eval REQUIRED)

if(ENABLE_SYSTEM_GLM)
find_package(GLM REQUIRED)
else()
Expand Down
3 changes: 1 addition & 2 deletions src/libprojectM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ add_library(projectM
$<TARGET_OBJECTS:hlslparser>
$<TARGET_OBJECTS:SOIL2>
$<TARGET_OBJECTS:projectM_main>
$<TARGET_OBJECTS:projectM::Eval>
)

target_include_directories(projectM
Expand All @@ -101,8 +102,6 @@ target_include_directories(projectM
)

target_link_libraries(projectM
PRIVATE
projectM::Eval
PUBLIC
${PROJECTM_OPENGL_LIBRARIES}
libprojectM::API
Expand Down
6 changes: 3 additions & 3 deletions src/libprojectM/MilkdropPreset/CustomShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void CustomShape::Draw()
if (static_cast<int>(*m_perFrameContext.textured) != 0)
{
m_presetState.texturedShader.Bind();
m_presetState.texturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjectionFlipped);
m_presetState.texturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjection);
m_presetState.texturedShader.SetUniformInt("texture_sampler", 0);

// Textured shape, either main texture or texture from "image" key
Expand Down Expand Up @@ -234,7 +234,7 @@ void CustomShape::Draw()
glBufferData(GL_ARRAY_BUFFER, sizeof(TexturedPoint) * (sides + 2), vertexData.data(), GL_DYNAMIC_DRAW);

m_presetState.untexturedShader.Bind();
m_presetState.untexturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjectionFlipped);
m_presetState.untexturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjection);

glBindVertexArray(m_vaoIdUntextured);
glDrawArrays(GL_TRIANGLE_FAN, 0, sides + 2);
Expand All @@ -252,7 +252,7 @@ void CustomShape::Draw()
}

m_presetState.untexturedShader.Bind();
m_presetState.untexturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjectionFlipped);
m_presetState.untexturedShader.SetUniformMat4x4("vertex_transformation", PresetState::orthogonalProjection);

glVertexAttrib4f(1,
static_cast<float>(*m_perFrameContext.border_r),
Expand Down
2 changes: 1 addition & 1 deletion src/libprojectM/MilkdropPreset/IdlePreset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ per_frame_29=q3 = if(above(frame,60),1, frame/60.0);
per_frame_30=oldq8 = if(above(oldq8,1000),0,oldq8);
per_frame_31=cx = cx + 0.3 * (0.6 * sin(0.245 * time) + 0.4 * sin(0.123 * time));
per_frame_31=cy = cy + 0.3 * (0.6 * sin(0.263 * time) + 0.4 * sin(0.117 * time));
per_frame_32=q9 = 0.12; // Headphones Y offset
per_frame_32=q9 = -0.12; // Headphones Y offset
per_frame_33=q10 = 0.5 * sin(time * 0.5623); // Logo tilt
per_pixel_1=zoom = log(sqrt(sin(time * .5) * 0.5 + 2.5) - .5 * rad) + 0.4;
)";
Expand Down
4 changes: 2 additions & 2 deletions src/libprojectM/ProjectMCWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ char* projectm_get_version_string()
{
auto versionLength = strlen(PROJECTM_VERSION_STRING);
auto buffer = projectm_alloc_string(versionLength + 1);
strncpy(buffer, PROJECTM_VERSION_STRING, versionLength);
strncpy(buffer, PROJECTM_VERSION_STRING, versionLength + 1);
return buffer;
}

char* projectm_get_vcs_version_string()
{
auto versionLength = strlen(PROJECTM_VERSION_VCS);
auto buffer = projectm_alloc_string(versionLength + 1);
strncpy(buffer, PROJECTM_VERSION_VCS, versionLength);
strncpy(buffer, PROJECTM_VERSION_VCS, versionLength + 1);
return buffer;
}

Expand Down
13 changes: 8 additions & 5 deletions src/libprojectM/Renderer/TextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void TextureManager::Preload()
M_bytes,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA, &width, &height);
SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA, &width, &height);


auto newTex = std::make_shared<Texture>("idlem", tex, GL_TEXTURE_2D, width, height, false);
Expand All @@ -77,7 +77,7 @@ void TextureManager::Preload()
headphones_bytes,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA, &width, &height);
SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MULTIPLY_ALPHA, &width, &height);

newTex = std::make_shared<Texture>("idleheadphones", tex, GL_TEXTURE_2D, width, height, false);
m_textures["idleheadphones"] = newTex;
Expand Down Expand Up @@ -192,11 +192,14 @@ void TextureManager::PurgeTextures()
{
return;
}

// Purge one texture. No need to inform presets, as the texture shouldn't be in use anymore.
// If this really happens for some reason, it'll simply be reloaded on the next frame.
m_textures.erase(m_textures.find(biggestName));
m_textureStats.erase(m_textureStats.find(biggestName));

#ifdef DEBUG
std::cerr << "Purged texture " << biggestName << std::endl;
#endif
}

TextureSamplerDescriptor TextureManager::TryLoadingTexture(const std::string& name)
Expand Down Expand Up @@ -233,14 +236,14 @@ TextureSamplerDescriptor TextureManager::TryLoadingTexture(const std::string& na
if (!texDesc.Empty())
{
#ifdef DEBUG
std::cerr << "Located texture " << unqualifiedName << std::endl;
std::cerr << "Loaded texture " << unqualifiedName << std::endl;
#endif
return texDesc;
}
}

#ifdef DEBUG
std::cerr << "Failed to locate texture " << unqualifiedName << std::endl;
std::cerr << "Failed to find texture " << unqualifiedName << std::endl;
#endif

// Return a placeholder.
Expand Down
1 change: 1 addition & 0 deletions vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(hlslparser)
add_subdirectory(omptl)
add_subdirectory(projectm-eval)
add_subdirectory(SOIL2)
1 change: 1 addition & 0 deletions vendor/projectm-eval
Submodule projectm-eval added at 4fe469

0 comments on commit e506701

Please sign in to comment.