mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-05 14:05:29 +00:00
Deleted lots of unused files and code.
This commit is contained in:
@ -26,18 +26,11 @@
|
||||
* you'll find it online
|
||||
*/
|
||||
|
||||
#include <numeric>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wipemalloc.h"
|
||||
|
||||
#include "BeatDetect.hpp"
|
||||
#include "PCM.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
namespace libprojectM {
|
||||
namespace Audio {
|
||||
|
||||
@ -26,9 +26,6 @@ add_library(projectM_main OBJECT
|
||||
Audio/PCM.hpp
|
||||
Audio/fftsg.cpp
|
||||
Audio/fftsg.h
|
||||
Common.hpp
|
||||
HungarianMethod.hpp
|
||||
IdleTextures.hpp
|
||||
Preset.hpp
|
||||
PresetFactory.cpp
|
||||
PresetFactory.hpp
|
||||
@ -41,11 +38,7 @@ add_library(projectM_main OBJECT
|
||||
RandomNumberGenerators.hpp
|
||||
TimeKeeper.cpp
|
||||
TimeKeeper.hpp
|
||||
fatal.h
|
||||
glError.h
|
||||
gltext.h
|
||||
projectM-opengl.h
|
||||
resource.h
|
||||
wipemalloc.cpp
|
||||
wipemalloc.h
|
||||
)
|
||||
@ -168,7 +161,6 @@ if(ENABLE_CXX_INTERFACE)
|
||||
endif()
|
||||
|
||||
install(FILES
|
||||
Common.hpp
|
||||
Audio/PCM.hpp
|
||||
ProjectM.hpp
|
||||
DESTINATION "${PROJECTM_INCLUDE_DIR}/projectM-4"
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
/**
|
||||
* projectM -- Milkdrop-esque visualisation SDK
|
||||
* Copyright (C)2003-2007 projectM Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
||||
//CPP17: std::filesystem::path::preferred_separator
|
||||
/** Per-platform path separators */
|
||||
#ifdef _WIN32
|
||||
char constexpr pathSeparator{'\\'};
|
||||
#else
|
||||
char constexpr pathSeparator{'/'};
|
||||
#endif /** _WIN32 */
|
||||
|
||||
size_t constexpr maxTokenSize{512};
|
||||
size_t constexpr maxPathSize{4096};
|
||||
|
||||
//CPP23: uz suffix (https://en.cppreference.com/w/cpp/language/integer_literal)
|
||||
size_t constexpr stringBufferSize{static_cast<size_t>(1024 * 150)};
|
||||
size_t constexpr stringLineSize{1024};
|
||||
|
||||
double constexpr maxDoubleSize{10000000.0};
|
||||
double constexpr minDoubleSize{-maxDoubleSize};
|
||||
|
||||
int constexpr maxIntSize{10000000};
|
||||
int constexpr minIntSize{-maxIntSize};
|
||||
|
||||
/* default float initial value */
|
||||
double constexpr defaultDoubleIv{0.0};
|
||||
|
||||
/* default float lower bound */
|
||||
double constexpr defaultDoubleLb{minDoubleSize};
|
||||
|
||||
/* default float upper bound */
|
||||
double constexpr defaultDoubleUb{maxDoubleSize};
|
||||
|
||||
unsigned int const numQVariables(32);
|
||||
|
||||
//CPP17: std::filesystem::path::extension
|
||||
inline auto ParseExtension(const std::string& filename) -> std::string
|
||||
{
|
||||
const auto start = filename.find_last_of('.');
|
||||
|
||||
if (start == std::string::npos || start >= (filename.length() - 1)) {
|
||||
return "";
|
||||
}
|
||||
std::string ext = filename.substr(start + 1, filename.length());
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
||||
return ext;
|
||||
}
|
||||
|
||||
//CPP17: std::filesystem::path::filename
|
||||
inline auto ParseFilename(const std::string& filename) -> std::string
|
||||
{
|
||||
const auto start = filename.find_last_of('/');
|
||||
|
||||
if (start == std::string::npos || start >= (filename.length() - 1)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return filename.substr(start + 1, filename.length());
|
||||
}
|
||||
@ -1,191 +0,0 @@
|
||||
#ifndef HUNGARIAN_METHOD_HPP
|
||||
#define HUNGARIAN_METHOD_HPP
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
/// A function object which calculates the maximum-weighted bipartite matching between
|
||||
/// two sets via the hungarian method.
|
||||
template <int N=20>
|
||||
class HungarianMethod {
|
||||
public :
|
||||
static const size_t MAX_SIZE = N;
|
||||
|
||||
private:
|
||||
size_t n, max_match; //n workers and n jobs
|
||||
double lx[N], ly[N]; //labels of X and Y parts
|
||||
int xy[N]; //xy[x] - vertex that is matched with x,
|
||||
int yx[N]; //yx[y] - vertex that is matched with y
|
||||
bool S[N], T[N]; //sets S and T in algorithm
|
||||
double slack[N]; //as in the algorithm description
|
||||
double slackx[N]; //slackx[y] such a vertex, that
|
||||
// l(slackx[y]) + l(y) - w(slackx[y],y) = slack[y]
|
||||
int prev[N]; //array for memorizing alternating paths
|
||||
|
||||
void init_labels(const double cost[N][N])
|
||||
{
|
||||
memset(lx, 0, sizeof(lx));
|
||||
memset(ly, 0, sizeof(ly));
|
||||
for (unsigned int x = 0; x < n; x++)
|
||||
for (unsigned int y = 0; y < n; y++)
|
||||
lx[x] = std::max(lx[x], cost[x][y]);
|
||||
}
|
||||
|
||||
void augment(const double cost[N][N]) //main function of the algorithm
|
||||
{
|
||||
if (max_match == n) return; //check wether matching is already perfect
|
||||
unsigned int x, y, root = 0; //just counters and root vertex
|
||||
int q[N], wr = 0, rd = 0; //q - queue for bfs, wr,rd - write and read
|
||||
//pos in queue
|
||||
memset(S, false, sizeof(S)); //init set S
|
||||
memset(T, false, sizeof(T)); //init set T
|
||||
memset(prev, -1, sizeof(prev)); //init set prev - for the alternating tree
|
||||
for (x = 0; x < n; x++) //finding root of the tree
|
||||
if (xy[x] == -1)
|
||||
{
|
||||
q[wr++] = root = x;
|
||||
prev[x] = -2;
|
||||
S[x] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (y = 0; y < n; y++) //initializing slack array
|
||||
{
|
||||
slack[y] = lx[root] + ly[y] - cost[root][y];
|
||||
slackx[y] = root;
|
||||
}
|
||||
while (true) //main cycle
|
||||
{
|
||||
while (rd < wr) //building tree with bfs cycle
|
||||
{
|
||||
x = q[rd++]; //current vertex from X part
|
||||
for (y = 0; y < n; y++) //iterate through all edges in equality graph
|
||||
if (cost[x][y] == lx[x] + ly[y] && !T[y])
|
||||
{
|
||||
if (yx[y] == -1) break; //an exposed vertex in Y found, so
|
||||
//augmenting path exists!
|
||||
T[y] = true; //else just add y to T,
|
||||
q[wr++] = yx[y]; //add vertex yx[y], which is matched
|
||||
//with y, to the queue
|
||||
add_to_tree(yx[y], x, cost); //add edges (x,y) and (y,yx[y]) to the tree
|
||||
}
|
||||
if (y < n) break; //augmenting path found!
|
||||
}
|
||||
if (y < n) break; //augmenting path found!
|
||||
|
||||
update_labels(); //augmenting path not found, so improve labeling
|
||||
wr = rd = 0;
|
||||
for (y = 0; y < n; y++)
|
||||
//in this cycle we add edges that were added to the equality graph as a
|
||||
//result of improving the labeling, we add edge (slackx[y], y) to the tree if
|
||||
//and only if !T[y] && slack[y] == 0, also with this edge we add another one
|
||||
//(y, yx[y]) or augment the matching, if y was exposed
|
||||
if (!T[y] && slack[y] == 0)
|
||||
{
|
||||
if (yx[y] == -1) //exposed vertex in Y found - augmenting path exists!
|
||||
{
|
||||
x = slackx[y];
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
T[y] = true; //else just add y to T,
|
||||
if (!S[yx[y]])
|
||||
{
|
||||
q[wr++] = yx[y]; //add vertex yx[y], which is matched with
|
||||
//y, to the queue
|
||||
add_to_tree(yx[y], slackx[y],cost); //and add edges (x,y) and (y,
|
||||
//yx[y]) to the tree
|
||||
}
|
||||
}
|
||||
}
|
||||
if (y < n) break; //augmenting path found!
|
||||
}
|
||||
|
||||
if (y < n) //we found augmenting path!
|
||||
{
|
||||
max_match++; //increment matching
|
||||
//in this cycle we inverse edges along augmenting path
|
||||
for (int cx = x, cy = y, ty; cx != -2; cx = prev[cx], cy = ty)
|
||||
{
|
||||
ty = xy[cx];
|
||||
yx[cy] = cx;
|
||||
xy[cx] = cy;
|
||||
}
|
||||
augment(cost); //recall function, go to step 1 of the algorithm
|
||||
}
|
||||
}//end of augment() function
|
||||
|
||||
void update_labels()
|
||||
{
|
||||
unsigned int x, y;
|
||||
double delta = std::numeric_limits<double>::max();
|
||||
for (y = 0; y < n; y++) //calculate delta using slack
|
||||
if (!T[y])
|
||||
delta = std::min(delta, slack[y]);
|
||||
for (x = 0; x < n; x++) //update X labels
|
||||
if (S[x]) lx[x] -= delta;
|
||||
for (y = 0; y < n; y++) //update Y labels
|
||||
if (T[y]) ly[y] += delta;
|
||||
for (y = 0; y < n; y++) //update slack array
|
||||
if (!T[y])
|
||||
slack[y] -= delta;
|
||||
}
|
||||
|
||||
void add_to_tree(int x, int prevx, const double cost[N][N])
|
||||
//x - current vertex,prevx - vertex from X before x in the alternating path,
|
||||
//so we add edges (prevx, xy[x]), (xy[x], x)
|
||||
{
|
||||
S[x] = true; //add x to S
|
||||
prev[x] = prevx; //we need this when augmenting
|
||||
for (unsigned int y = 0; y < n; y++) //update slacks, because we add new vertex to S
|
||||
if (lx[x] + ly[y] - cost[x][y] < slack[y])
|
||||
{
|
||||
slack[y] = lx[x] + ly[y] - cost[x][y];
|
||||
slackx[y] = x;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
/// Computes the best matching of two sets given its cost matrix.
|
||||
/// See the matching() method to get the computed match result.
|
||||
/// \param cost a matrix of two sets I,J where cost[i][j] is the weight of edge i->j
|
||||
/// \param logicalSize the number of elements in both I and J
|
||||
/// \returns the total cost of the best matching
|
||||
inline double operator()(const double cost[N][N], size_t logicalSize)
|
||||
{
|
||||
|
||||
n = logicalSize;
|
||||
assert(n <= N);
|
||||
double ret = 0; //weight of the optimal matching
|
||||
max_match = 0; //number of vertices in current matching
|
||||
memset(xy, -1, sizeof(xy));
|
||||
memset(yx, -1, sizeof(yx));
|
||||
init_labels(cost); //step 0
|
||||
augment(cost); //steps 1-3
|
||||
for (unsigned int x = 0; x < n; x++) //forming answer there
|
||||
ret += cost[x][xy[x]];
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Gets the matching element in 2nd set of the ith element in the first set
|
||||
/// \param i the index of the ith element in the first set (passed in operator())
|
||||
/// \returns an index j, denoting the matched jth element of the 2nd set
|
||||
inline int matching(int i) const {
|
||||
return xy[i];
|
||||
}
|
||||
|
||||
|
||||
/// Gets the matching element in 1st set of the jth element in the 2nd set
|
||||
/// \param j the index of the jth element in the 2nd set (passed in operator())
|
||||
/// \returns an index i, denoting the matched ith element of the 1st set
|
||||
/// \note inverseMatching(matching(i)) == i
|
||||
inline int inverseMatching(int j) const {
|
||||
return yx[j];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@ -88,6 +88,8 @@ void MilkdropPreset::RenderFrame(const libprojectM::Audio::FrameAudioData& audio
|
||||
// First evaluate per-frame code
|
||||
PerFrameUpdate();
|
||||
|
||||
glViewport(0, 0, renderContext.viewportSizeX, renderContext.viewportSizeY);
|
||||
|
||||
m_framebuffer.Bind(m_previousFrameBuffer);
|
||||
// Motion vector field. Drawn to the previous frame texture before warping it.
|
||||
// Only do it after drawing one frame after init or resize.
|
||||
|
||||
@ -11,10 +11,9 @@
|
||||
//
|
||||
#include "PresetFactoryManager.hpp"
|
||||
|
||||
#include "Common.hpp"
|
||||
|
||||
#include <MilkdropPreset/MilkdropPresetFactory.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -135,4 +134,17 @@ std::vector<std::string> PresetFactoryManager::extensionsHandled() const
|
||||
retval.push_back(element.first);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
//CPP17: std::filesystem::path::extension
|
||||
auto PresetFactoryManager::ParseExtension(const std::string& filename) -> std::string
|
||||
{
|
||||
const auto start = filename.find_last_of('.');
|
||||
|
||||
if (start == std::string::npos || start >= (filename.length() - 1)) {
|
||||
return "";
|
||||
}
|
||||
std::string ext = filename.substr(start + 1, filename.length());
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
||||
return ext;
|
||||
}
|
||||
|
||||
@ -80,6 +80,8 @@ public:
|
||||
private:
|
||||
void registerFactory(const std::string& extension, PresetFactory* factory);
|
||||
|
||||
auto ParseExtension(const std::string& filename) -> std::string;
|
||||
|
||||
mutable std::map<std::string, PresetFactory*> m_factoryMap;
|
||||
mutable std::vector<PresetFactory*> m_factoryList;
|
||||
void ClearFactories();
|
||||
|
||||
@ -112,7 +112,6 @@ void ProjectM::ResetTextures()
|
||||
|
||||
void ProjectM::DumpDebugImageOnNextFrame(const std::string& outputFile)
|
||||
{
|
||||
m_renderer->frameDumpOutputFile = outputFile;
|
||||
}
|
||||
|
||||
#if PROJECTM_USE_THREADS
|
||||
@ -200,15 +199,6 @@ void ProjectM::RenderFrame()
|
||||
m_frameCount++;
|
||||
}
|
||||
|
||||
void ProjectM::Reset()
|
||||
{
|
||||
this->m_frameCount = 0;
|
||||
|
||||
m_presetFactoryManager->initialize();
|
||||
|
||||
ResetEngine();
|
||||
}
|
||||
|
||||
void ProjectM::Initialize()
|
||||
{
|
||||
/** Initialise start time */
|
||||
@ -225,11 +215,7 @@ void ProjectM::Initialize()
|
||||
|
||||
m_beatDetect = std::make_unique<libprojectM::Audio::BeatDetect>(m_pcm);
|
||||
|
||||
m_renderer = std::make_unique<Renderer>(m_windowWidth,
|
||||
m_windowHeight,
|
||||
m_meshX,
|
||||
m_meshY,
|
||||
*m_beatDetect);
|
||||
m_renderer = std::make_unique<Renderer>(m_windowWidth, m_windowHeight);
|
||||
|
||||
m_textureManager = std::make_unique<TextureManager>(m_textureSearchPaths);
|
||||
|
||||
@ -272,6 +258,7 @@ void ProjectM::ResetOpenGL(size_t width, size_t height)
|
||||
/** Stash the new dimensions */
|
||||
m_windowWidth = width;
|
||||
m_windowHeight = height;
|
||||
|
||||
try
|
||||
{
|
||||
m_renderer->reset(width, height);
|
||||
@ -408,7 +395,6 @@ auto ProjectM::TargetFramesPerSecond() const -> int32_t
|
||||
void ProjectM::SetTargetFramesPerSecond(int32_t fps)
|
||||
{
|
||||
m_targetFps = fps;
|
||||
m_renderer->setFPS(fps); // ToDo: Renderer should ideally calculate this.
|
||||
}
|
||||
|
||||
auto ProjectM::AspectCorrection() const -> bool
|
||||
@ -490,13 +476,6 @@ void ProjectM::TouchDestroyAll()
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectM::RecreateRenderer()
|
||||
{
|
||||
m_renderer = std::make_unique<Renderer>(m_windowWidth, m_windowHeight,
|
||||
m_meshX, m_meshY,
|
||||
*m_beatDetect.get());
|
||||
}
|
||||
|
||||
auto ProjectM::GetRenderContext() -> RenderContext
|
||||
{
|
||||
RenderContext ctx{};
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include "projectM-4/projectM_export.h"
|
||||
|
||||
#include "libprojectM/Audio/PCM.hpp"
|
||||
#include "libprojectM/Common.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@ -56,10 +55,6 @@ class BeatDetect;
|
||||
}
|
||||
} // namespace libprojectM
|
||||
|
||||
class Pcm;
|
||||
|
||||
class Func;
|
||||
|
||||
class Renderer;
|
||||
|
||||
class TextureManager;
|
||||
@ -209,22 +204,12 @@ public:
|
||||
void DumpDebugImageOnNextFrame(const std::string& outputFile);
|
||||
|
||||
private:
|
||||
void EvaluateSecondPreset();
|
||||
|
||||
auto PipelineContext() -> class PipelineContext&;
|
||||
|
||||
auto PipelineContext2() -> class PipelineContext&;
|
||||
|
||||
void Initialize();
|
||||
|
||||
void Reset();
|
||||
|
||||
void ResetEngine();
|
||||
|
||||
void StartPresetTransition(std::unique_ptr<Preset>&& preset, bool hardCut);
|
||||
|
||||
void RecreateRenderer();
|
||||
|
||||
void LoadIdlePreset();
|
||||
|
||||
auto GetRenderContext() -> RenderContext;
|
||||
@ -240,8 +225,8 @@ private:
|
||||
size_t m_meshX{32}; //!< Per-point mesh horizontal resolution.
|
||||
size_t m_meshY{24}; //!< Per-point mesh vertical resolution.
|
||||
size_t m_targetFps{35}; //!< Target frames per second.
|
||||
size_t m_windowWidth{0}; //!< EvaluateFrameData window width. If 0, nothing is rendered.
|
||||
size_t m_windowHeight{0}; //!< EvaluateFrameData window height. If 0, nothing is rendered.
|
||||
int m_windowWidth{0}; //!< EvaluateFrameData window width. If 0, nothing is rendered.
|
||||
int m_windowHeight{0}; //!< EvaluateFrameData window height. If 0, nothing is rendered.
|
||||
double m_presetDuration{30.0}; //!< Preset duration in seconds.
|
||||
double m_softCutDuration{3.0}; //!< Soft cut transition time.
|
||||
double m_hardCutDuration{20.0}; //!< Time after which a hard cut can happen at the earliest.
|
||||
|
||||
@ -3,6 +3,7 @@ add_library(Renderer OBJECT
|
||||
FileScanner.hpp
|
||||
Framebuffer.cpp
|
||||
Framebuffer.hpp
|
||||
IdleTextures.hpp
|
||||
RenderContext.hpp
|
||||
RenderItem.cpp
|
||||
RenderItem.hpp
|
||||
|
||||
@ -5,13 +5,18 @@
|
||||
//
|
||||
|
||||
#include "FileScanner.hpp"
|
||||
#include "Common.hpp"
|
||||
|
||||
#ifndef _WIN32
|
||||
/** Per-platform path separators and includes */
|
||||
#ifdef _WIN32
|
||||
char constexpr pathSeparator{'\\'};
|
||||
#else
|
||||
char constexpr pathSeparator{'/'};
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
FileScanner::FileScanner()
|
||||
{
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ public:
|
||||
int frame{0}; //!< Frames rendered so far.
|
||||
float fps{0.0f}; //!< Frames per second.
|
||||
float progress{0.0f}; //!< Preset progress.
|
||||
int texsize{512}; //!< Size of the internal render texture.
|
||||
int viewportSizeX{0}; //!< Horizontal viewport size in pixels
|
||||
int viewportSizeY{0}; //!< Vertical viewport size in pixels
|
||||
float aspectX{1.0}; //!< X aspect ratio.
|
||||
|
||||
@ -1,436 +1,45 @@
|
||||
#include "Renderer.hpp"
|
||||
#include "TextureManager.hpp"
|
||||
#include "math.h"
|
||||
#include "omptl/omptl_algorithm"
|
||||
|
||||
#include "MilkdropPreset/Waveform.hpp"
|
||||
#include "stb_image_write.h"
|
||||
#include "wipemalloc.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
class Preset;
|
||||
|
||||
Renderer::Renderer(int viewportWidth, int viewportHeight, int meshX, int meshY,
|
||||
libprojectM::Audio::BeatDetect& beatDetect)
|
||||
: m_beatDetect(beatDetect)
|
||||
, m_viewportWidth(viewportWidth)
|
||||
, m_viewportHeight(viewportHeight)
|
||||
Renderer::Renderer(int viewportWidth, int viewportHeight)
|
||||
{
|
||||
// Interpolation VAO/VBO's
|
||||
glGenBuffers(1, &m_vboInterpolation);
|
||||
glGenVertexArrays(1, &m_vaoInterpolation);
|
||||
|
||||
glBindVertexArray(m_vaoInterpolation);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vboInterpolation);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, static_cast<void*>(nullptr)); // Positions
|
||||
|
||||
glDisableVertexAttribArray(1);
|
||||
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(sizeof(float) * 2)); // Textures
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// CompositeOutput VAO/VBO's
|
||||
glGenBuffers(1, &m_vboCompositeOutput);
|
||||
glGenVertexArrays(1, &m_vaoCompositeOutput);
|
||||
|
||||
float composite_buffer_data[8][2] =
|
||||
{
|
||||
{-0.5, -0.5},
|
||||
{0, 1},
|
||||
{-0.5, 0.5},
|
||||
{0, 0},
|
||||
{0.5, 0.5},
|
||||
{1, 0},
|
||||
{0.5, -0.5},
|
||||
{1, 1}
|
||||
};
|
||||
|
||||
|
||||
glBindVertexArray(m_vaoCompositeOutput);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vboCompositeOutput);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 8 * 2, composite_buffer_data, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, static_cast<void*>(nullptr)); // Positions
|
||||
|
||||
glDisableVertexAttribArray(1);
|
||||
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(sizeof(float) * 2)); // Textures
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
|
||||
// CompositeShaderOutput VAO/VBO's
|
||||
glGenBuffers(1, &m_vboCompositeShaderOutput);
|
||||
glGenVertexArrays(1, &m_vaoCompositeShaderOutput);
|
||||
|
||||
glBindVertexArray(m_vaoCompositeShaderOutput);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vboCompositeShaderOutput);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(composite_shader_vertex), static_cast<void*>(nullptr));
|
||||
// Positions
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(composite_shader_vertex), (void*)(sizeof(float) * 2));
|
||||
// Colors
|
||||
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(composite_shader_vertex), (void*)(sizeof(float) * 6)); // UV
|
||||
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(composite_shader_vertex), (void*)(sizeof(float) * 8));
|
||||
// RAD ANG
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
reset(viewportWidth, viewportHeight);
|
||||
}
|
||||
|
||||
/*
|
||||
void Renderer::RenderTouch(const Pipeline& pipeline, const PipelineContext& pipelineContext)
|
||||
{
|
||||
Pipeline pipelineTouch;
|
||||
Waveform wave;
|
||||
for(std::size_t x = 0; x < m_waveformList.size(); x++){
|
||||
pipelineTouch.drawables.push_back(&wave);
|
||||
wave = m_waveformList[x];
|
||||
|
||||
// Render waveform
|
||||
for (std::vector<RenderItem*>::const_iterator pos = pipelineTouch.drawables.begin(); pos != pipelineTouch.drawables.end(); ++pos)
|
||||
{
|
||||
if (*pos != nullptr)
|
||||
(*pos)->Draw(m_renderContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Renderer::~Renderer()
|
||||
{
|
||||
free(m_perPointMeshBuffer);
|
||||
|
||||
glDeleteBuffers(1, &m_vboInterpolation);
|
||||
glDeleteVertexArrays(1, &m_vaoInterpolation);
|
||||
|
||||
glDeleteBuffers(1, &m_vboCompositeOutput);
|
||||
glDeleteVertexArrays(1, &m_vaoCompositeOutput);
|
||||
}
|
||||
|
||||
void Renderer::reset(int viewportWidth, int viewportHeight)
|
||||
{
|
||||
m_viewportWidth = viewportWidth;
|
||||
m_viewportHeight = viewportHeight;
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
#ifndef GL_TRANSITION
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
#endif
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
|
||||
glViewport(0, 0, viewportWidth, viewportHeight);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
m_mainTextureSizeX = viewportWidth;
|
||||
m_mainTextureSizeY = viewportHeight;
|
||||
|
||||
// snap to 16x16 blocks
|
||||
m_mainTextureSizeX = ((m_mainTextureSizeX - 15) / 16) * 16;
|
||||
m_mainTextureSizeY = ((m_mainTextureSizeY - 15) / 16) * 16;
|
||||
|
||||
m_fAspectX = (m_mainTextureSizeY > m_mainTextureSizeX) ? static_cast<float>(m_mainTextureSizeX) / static_cast<float>(m_mainTextureSizeY) : 1.0f;
|
||||
m_fAspectY = (m_mainTextureSizeX > m_mainTextureSizeY) ? static_cast<float>(m_mainTextureSizeY) / static_cast<float>(m_mainTextureSizeX) : 1.0f;
|
||||
|
||||
m_fInvAspectX = 1.0f / m_fAspectX;
|
||||
m_fInvAspectY = 1.0f / m_fAspectY;
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
bool Renderer::timeCheck(const milliseconds currentTime, const milliseconds lastTime, const double difference) {
|
||||
milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - lastTime);
|
||||
double diff = ms.count();
|
||||
if (diff >= difference)
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If we touched on the renderer where there is an existing waveform.
|
||||
bool Renderer::touchedWaveform(float x, float y, std::size_t i)
|
||||
{
|
||||
/*
|
||||
if (m_waveformList[i].x > (x-0.05f) && m_waveformList[i].x < (x+0.05f) // if x +- 0.5f
|
||||
&& ((m_waveformList[i].y > (y-0.05f) && m_waveformList[i].y < (y+0.05f)) // and y +- 0.5f
|
||||
|| m_waveformList[i].m_mode == Line || m_waveformList[i].m_mode == DoubleLine || m_waveformList[i].m_mode == DerivativeLine ) // OR it's a line (and y doesn't matter)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
// Render a waveform when a touch event is triggered.
|
||||
void Renderer::touch(float x, float y, int pressure, int type = 0)
|
||||
{
|
||||
/*
|
||||
for (std::size_t i = 0; i < m_waveformList.size(); i++) {
|
||||
if (touchedWaveform(x, y, i))
|
||||
{
|
||||
// if we touched an existing waveform with left click, drag it and don't continue with adding another.
|
||||
touchDrag(x, y, pressure);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_touchX = x;
|
||||
m_touchY = y;
|
||||
|
||||
// Randomly select colours on touch
|
||||
m_touchR = ((double)rand() / (RAND_MAX));
|
||||
m_touchB = ((double)rand() / (RAND_MAX));
|
||||
m_touchG = ((double)rand() / (RAND_MAX));
|
||||
m_touchA = ((double)rand() / (RAND_MAX));
|
||||
|
||||
Waveform wave;
|
||||
if (type == 0) {
|
||||
// If we touched randomly, then assign type to a random number between 0 and 8
|
||||
wave.m_mode = static_cast<MilkdropWaveformMode>((rand() % last));
|
||||
}
|
||||
else {
|
||||
wave.m_mode = static_cast<MilkdropWaveformMode>(type);
|
||||
}
|
||||
|
||||
wave.additive = true;
|
||||
wave.modOpacityEnd = 1.1;
|
||||
wave.modOpacityStart = 0.0;
|
||||
wave.maximizeColors = true;
|
||||
wave.modulateAlphaByVolume = false;
|
||||
|
||||
wave.r = m_touchR;
|
||||
wave.g = m_touchG;
|
||||
wave.b = m_touchB;
|
||||
wave.a = m_touchA;
|
||||
wave.x = m_touchX;
|
||||
wave.y = m_touchY;
|
||||
|
||||
// add new waveform to waveformTouchList
|
||||
m_waveformList.push_back(wave);
|
||||
*/
|
||||
}
|
||||
|
||||
// Move a waveform when dragging X, Y, and Pressure can change. We also extend the counters so it will stay on screen for as long as you click and drag.
|
||||
void Renderer::touchDrag(float x, float y, int pressure)
|
||||
{
|
||||
/*
|
||||
// if we left clicked & held in the approximate position of a waveform, snap to it and adjust x / y to simulate dragging.
|
||||
// For lines we don't worry about the x axis.
|
||||
for (std::size_t i = 0; i < m_waveformList.size(); i++) {
|
||||
if (touchedWaveform(x, y, i))
|
||||
{
|
||||
m_waveformList[i].x = x;
|
||||
m_waveformList[i].y = y;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Remove waveform at X Y
|
||||
void Renderer::touchDestroy(float x, float y)
|
||||
{
|
||||
/*
|
||||
// if we right clicked approximately on the position of the waveform, then remove it from the waveform list.
|
||||
// For lines we don't worry about the x axis.
|
||||
for (std::size_t i = 0; i < m_waveformList.size(); i++) {
|
||||
if (touchedWaveform(x, y, i))
|
||||
{
|
||||
m_waveformList.erase(m_waveformList.begin() + i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Remove all waveforms
|
||||
void Renderer::touchDestroyAll()
|
||||
{
|
||||
//m_waveformList.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
void Renderer::CompositeOutput(const Pipeline& pipeline, const PipelineContext& pipelineContext)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_textureManager->getMainTexture()->texID);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
m_renderContext.mat_ortho = glm::ortho(-0.5f, 0.5f, -0.5f, 0.5f, -40.0f, 40.0f);
|
||||
|
||||
m_shaderEngine.enableCompositeShader(m_currentPipeline->compositeShader, pipeline, pipelineContext);
|
||||
|
||||
glUniformMatrix4fv(m_shaderEngine.uniform_v2f_c4f_t2f_vertex_transformation, 1, GL_FALSE,
|
||||
value_ptr(m_renderContext.mat_ortho));
|
||||
glUniform1i(m_shaderEngine.uniform_v2f_c4f_t2f_frag_texture_sampler, 0);
|
||||
|
||||
//Overwrite anything on the screen
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glVertexAttrib4f(1, 1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
glBindVertexArray(m_vaoCompositeOutput);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
for (auto drawable : pipeline.compositeDrawables)
|
||||
drawable->Draw(m_renderContext);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calculates the nearest power of two to the given number using the
|
||||
* appropriate rule
|
||||
*/
|
||||
int Renderer::nearestPower2(int value)
|
||||
{
|
||||
int x = value;
|
||||
int power = 0;
|
||||
|
||||
if (x == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((x & 0x01) != 1)
|
||||
{
|
||||
x >>= 1;
|
||||
}
|
||||
|
||||
if (x == 1)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
x = value;
|
||||
while (x != 0)
|
||||
{
|
||||
x >>= 1;
|
||||
power++;
|
||||
}
|
||||
if (((1 << power) - value) <= (value - (1 << (power - 1))))
|
||||
{
|
||||
return 1 << power;
|
||||
}
|
||||
return 1 << (power - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void Renderer::CompositeShaderOutput(const Pipeline& pipeline, const PipelineContext& pipelineContext)
|
||||
{
|
||||
// hue shader
|
||||
float shade[4][3] = {
|
||||
{1.0f, 1.0f, 1.0f},
|
||||
{1.0f, 1.0f, 1.0f},
|
||||
{1.0f, 1.0f, 1.0f},
|
||||
{1.0f, 1.0f, 1.0f}
|
||||
}; // for each vertex, then each comp.
|
||||
|
||||
// pick 4 colors for the 4 corners
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
shade[i][0] = 0.6f + 0.3f * sinf(pipelineContext.time * 30.0f * 0.0143f + 3 + i * 21);
|
||||
shade[i][1] = 0.6f + 0.3f * sinf(pipelineContext.time * 30.0f * 0.0107f + 1 + i * 13);
|
||||
shade[i][2] = 0.6f + 0.3f * sinf(pipelineContext.time * 30.0f * 0.0129f + 6 + i * 9);
|
||||
float max = ((shade[i][0] > shade[i][1]) ? shade[i][0] : shade[i][1]);
|
||||
if (shade[i][2] > max) max = shade[i][2];
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
shade[i][k] /= max;
|
||||
shade[i][k] = 0.5f + 0.5f * shade[i][k];
|
||||
}
|
||||
}
|
||||
|
||||
// interpolate the 4 colors & apply to all the verts
|
||||
for (int j = 0; j < FCGSY; j++)
|
||||
{
|
||||
for (int i = 0; i < FCGSX; i++)
|
||||
{
|
||||
composite_shader_vertex* pComp = &m_compositeVertices[i + j * FCGSX];
|
||||
float x = pComp->x * 0.5f + 0.5f;
|
||||
float y = pComp->y * 0.5f + 0.5f;
|
||||
|
||||
float col[3] = {1, 1, 1};
|
||||
for (int c = 0; c < 3; c++)
|
||||
col[c] = shade[0][c] * (x) * (y) +
|
||||
shade[1][c] * (1 - x) * (y) +
|
||||
shade[2][c] * (x) * (1 - y) +
|
||||
shade[3][c] * (1 - x) * (1 - y);
|
||||
|
||||
pComp->Diffuse[0] = col[0];
|
||||
pComp->Diffuse[1] = col[1];
|
||||
pComp->Diffuse[2] = col[2];
|
||||
pComp->Diffuse[3] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const int primCount = (FCGSX - 2) * (FCGSY - 2) * 6;
|
||||
composite_shader_vertex tempv[primCount];
|
||||
memset(tempv, 0, sizeof(composite_shader_vertex) * primCount);
|
||||
int src_idx = 0;
|
||||
for (int i = 0; i < primCount; i++)
|
||||
{
|
||||
tempv[i] = m_compositeVertices[m_compositeIndices[src_idx++]];
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vboCompositeShaderOutput);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(composite_shader_vertex) * primCount, nullptr, GL_DYNAMIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(composite_shader_vertex) * primCount, tempv, GL_DYNAMIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
|
||||
glBindVertexArray(m_vaoCompositeShaderOutput);
|
||||
|
||||
// Now do the final composite blit, fullscreen;
|
||||
glDrawArrays(GL_TRIANGLES, 0, primCount);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
*/
|
||||
@ -63,83 +63,18 @@ class Renderer
|
||||
public:
|
||||
Renderer() = delete;
|
||||
|
||||
Renderer(int viewportWidth, int viewportHeight,
|
||||
int meshX, int meshY,
|
||||
libprojectM::Audio::BeatDetect& beatDetect);
|
||||
Renderer(int viewportWidth, int viewportHeight);
|
||||
|
||||
~Renderer();
|
||||
|
||||
void reset(int viewportWidth, int viewportHeight);
|
||||
|
||||
bool timeCheck(const milliseconds currentTime, const milliseconds lastTime, const double difference);
|
||||
|
||||
void setFPS(const int& theValue)
|
||||
{
|
||||
m_fps = std::to_string(theValue);
|
||||
}
|
||||
|
||||
std::string fps() const
|
||||
{
|
||||
return m_fps;
|
||||
}
|
||||
|
||||
milliseconds nowMilliseconds()
|
||||
{
|
||||
return duration_cast<milliseconds>(system_clock::now().time_since_epoch());
|
||||
}
|
||||
|
||||
void touch(float x, float y, int pressure, int type);
|
||||
void touchDrag(float x, float y, int pressure);
|
||||
void touchDestroy(float x, float y);
|
||||
void touchDestroyAll();
|
||||
bool touchedWaveform(float x, float y, std::size_t i);
|
||||
|
||||
std::string frameDumpOutputFile;
|
||||
|
||||
milliseconds lastTimeFPS{nowMilliseconds()};
|
||||
milliseconds currentTimeFPS{nowMilliseconds()};
|
||||
|
||||
int totalframes{1};
|
||||
float realfps{0.0};
|
||||
|
||||
std::string title;
|
||||
|
||||
private:
|
||||
int nearestPower2(int value);
|
||||
|
||||
libprojectM::Audio::BeatDetect& m_beatDetect;
|
||||
|
||||
std::string m_fps;
|
||||
|
||||
float* m_perPointMeshBuffer{nullptr};
|
||||
|
||||
int m_viewportWidth{0};
|
||||
int m_viewportHeight{0};
|
||||
|
||||
GLuint m_vboInterpolation{0};
|
||||
GLuint m_vaoInterpolation{0};
|
||||
|
||||
GLuint m_vboCompositeOutput{0};
|
||||
GLuint m_vaoCompositeOutput{0};
|
||||
|
||||
GLuint m_vboCompositeShaderOutput{0};
|
||||
GLuint m_vaoCompositeShaderOutput{0};
|
||||
|
||||
composite_shader_vertex m_compositeVertices[FCGSX * FCGSY];
|
||||
int m_compositeIndices[(FCGSX - 2) * (FCGSY - 2) * 6];
|
||||
|
||||
float m_touchX{0.0}; ///!< X position for touch waveform to start displaying(scale of 0 - 1 and not the exact coordinates)
|
||||
float m_touchY{0.0}; ///!< y position for touch waveform to start displaying(scale of 0 - 1 and not the exact coordinates)
|
||||
double m_touchR{0.0}; ///!< Red
|
||||
double m_touchG{0.0}; ///!< Green
|
||||
double m_touchB{0.0}; ///!< Blue
|
||||
double m_touchA{0.0}; ///!< Alpha
|
||||
|
||||
int m_mainTextureSizeX{0};
|
||||
int m_mainTextureSizeY{0};
|
||||
|
||||
float m_fAspectX{1.0};
|
||||
float m_fAspectY{1.0};
|
||||
float m_fInvAspectX{1.0};
|
||||
float m_fInvAspectY{1.0};
|
||||
};
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
#include "TextureManager.hpp"
|
||||
|
||||
#include "IdleTextures.hpp"
|
||||
|
||||
#include "MilkdropPreset/MilkdropNoise.hpp"
|
||||
|
||||
#include "SOIL2/SOIL2.h"
|
||||
|
||||
#include "Texture.hpp"
|
||||
#include "projectM-opengl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "MilkdropPreset/MilkdropNoise.hpp"
|
||||
|
||||
// Missing in macOS SDK. Query will most certainly fail, but then use the default format.
|
||||
#ifndef GL_TEXTURE_IMAGE_FORMAT
|
||||
#define GL_TEXTURE_IMAGE_FORMAT 0x828F
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
r/**
|
||||
* projectM -- Milkdrop-esque visualisation SDK
|
||||
* Copyright (C)2003-2007 projectM Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* $Id: carbontoprojectM.hpp,v 1.2 2004/11/12 15:12:58 cvs Exp $
|
||||
*
|
||||
* Translates CARBON -> projectM variables
|
||||
*
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
#ifndef _CARBONTOPROJECTM_H
|
||||
#define _CARBONTOPROJECTM_H
|
||||
|
||||
projectMKeycode carbon2pmKeycode( NSEvent *event ) {
|
||||
projectMKeycode char_code = (projectMKeycode)(event->message & charCodeMask);
|
||||
switch ( char_code ) {
|
||||
case kFunctionKeyCharCode: {
|
||||
switch ( ( event->message << 16 ) >> 24 ) {
|
||||
case 111: {
|
||||
return PROJECTM_K_F12;
|
||||
}
|
||||
case 103: {
|
||||
return PROJECTM_K_F11;
|
||||
}
|
||||
case 109: {
|
||||
return PROJECTM_K_F10;
|
||||
}
|
||||
case 101: {
|
||||
return PROJECTM_K_F9;
|
||||
}
|
||||
case 100: {
|
||||
return PROJECTM_K_F8;
|
||||
}
|
||||
case 98: {
|
||||
return PROJECTM_K_F7;
|
||||
}
|
||||
case 97: {
|
||||
return PROJECTM_K_F6;
|
||||
}
|
||||
case 96: {
|
||||
return PROJECTM_K_F5;
|
||||
}
|
||||
case 118: {
|
||||
return PROJECTM_K_F4;
|
||||
}
|
||||
case 99: {
|
||||
return PROJECTM_K_F3;
|
||||
}
|
||||
case 120: {
|
||||
return PROJECTM_K_F2;
|
||||
}
|
||||
case 122: {
|
||||
return PROJECTM_K_F1;
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
return char_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
projectMModifier carbon2pmModifier( NSEvent *event ) {
|
||||
return (projectMModifier)PROJECTM_K_LSHIFT;
|
||||
}
|
||||
|
||||
#endif /** _CARBONTOPROJECTM_H */
|
||||
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* projectM -- Milkdrop-esque visualisation SDK
|
||||
* Copyright (C)2003-2007 projectM Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Translates cocoa -> projectM variables
|
||||
*
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
#ifndef _CARBONTOPROJECTM_H
|
||||
#define _CARBONTOPROJECTM_H
|
||||
|
||||
projectMKeycode cocoa2pmKeycode( NSEvent *event ) {
|
||||
projectMKeycode char_code = (projectMKeycode)[event keyCode];
|
||||
switch ( char_code ) {
|
||||
case kVK_F1:
|
||||
case kVK_ANSI_H:
|
||||
return PROJECTM_K_F1;
|
||||
case kVK_F2:
|
||||
return PROJECTM_K_F2;
|
||||
case kVK_F3:
|
||||
return PROJECTM_K_F3;
|
||||
case kVK_F4:
|
||||
return PROJECTM_K_F4;
|
||||
default:
|
||||
// try and get ascii code
|
||||
NSString *chars = [event charactersIgnoringModifiers];
|
||||
if ([chars length]) {
|
||||
return (projectMKeycode)[chars characterAtIndex:0];
|
||||
}
|
||||
return char_code;
|
||||
}
|
||||
}
|
||||
|
||||
projectMModifier cocoa2pmModifier( NSEvent *event ) {
|
||||
NSUInteger mod = [event modifierFlags];
|
||||
if (mod & NSShiftKeyMask)
|
||||
return (projectMModifier)PROJECTM_K_LSHIFT;
|
||||
if (mod & NSControlKeyMask)
|
||||
return (projectMModifier)PROJECTM_K_LCTRL;
|
||||
|
||||
return (projectMModifier)0;
|
||||
}
|
||||
|
||||
#endif /** _CARBONTOPROJECTM_H */
|
||||
@ -1,43 +0,0 @@
|
||||
/**
|
||||
* projectM -- Milkdrop-esque visualisation SDK
|
||||
* Copyright (C)2003-2007 projectM Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* See 'LICENSE.txt' included within this release
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* $Id: fatal.h,v 1.1.1.1 2005/12/23 18:05:05 psperl Exp $
|
||||
*
|
||||
* Error codes
|
||||
*
|
||||
* $Log$
|
||||
*/
|
||||
|
||||
#ifndef _FATAL_H
|
||||
#define _FATAL_H
|
||||
|
||||
/* Fatal Error Definitions */
|
||||
|
||||
#define PROJECTM_OUTOFMEM_ERROR -7; /* out of memory */
|
||||
#define PROJECTM_ERROR -1 /* non specific error */
|
||||
#define PROJECTM_SUCCESS 1
|
||||
#define PROJECTM_FAILURE -1
|
||||
#define PROJECTM_PARSE_ERROR -11
|
||||
#define PROJECTM_DIV_BY_ZERO -3
|
||||
#define PROJECTM_OK 2
|
||||
|
||||
#endif /** !_FATAL_H */
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
//
|
||||
// File: glError.h
|
||||
// Author: fatray
|
||||
//
|
||||
// Created on 02 December 2007, 16:08
|
||||
//
|
||||
|
||||
#ifndef _GLERROR_H
|
||||
#define _GLERROR_H
|
||||
|
||||
// no need to include GL in here,
|
||||
// if someone wants GL errors they probably already included it.
|
||||
|
||||
|
||||
/*
|
||||
* if we are debugging, print all glErrors to stderr.
|
||||
* Remeber that glErrors are buffered, this just prints any in the buffer.
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define glError()
|
||||
#else
|
||||
#define glError() { \
|
||||
GLenum err; \
|
||||
while ((err = glGetError()) != GL_NO_ERROR) \
|
||||
fprintf(stderr, "glError: %s at %s:%u\n", \
|
||||
(char *)gluErrorString(err), __FILE__, __LINE__); \
|
||||
}
|
||||
#endif /* glError */
|
||||
|
||||
#endif /* _GLERROR_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by libprojectM.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user