trying to decouple things properly

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/represet@1179 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2008-09-20 19:05:57 +00:00
parent c7b0a57e2b
commit ab5e0ae5eb
13 changed files with 156 additions and 169 deletions

View File

@ -17,7 +17,7 @@ OPTION (USE_CG "Use Cg for Pixel Shader support" OFF)
#OPTION (FTGL_STATIC "Build the projectM target library in the platform's native static (NOT shared) format." OFF)
OPTION (BUILD_PROJECTM_STATIC "Build the projectM target library in the platform's native static (NOT shared) format." OFF)
SET(SOIL_SOURCES image_DXT.c image_helper.c SOIL.c stb_image_aug.c)
ADD_DEFINITIONS(-DCMAKE_INSTALL_PREFIX="\\\"${CMAKE_INSTALL_PREFIX}\\\"")
if (USE_NATIVE_GLEW)
ADD_DEFINITIONS(-DUSE_NATIVE_GLEW)
@ -28,18 +28,19 @@ SET(GLEW_SOURCES )
SET (GLEW_LINK_TARGETS GLEW)
endif(USE_NATIVE_GLEW)
SET(projectM_SOURCES projectM.cpp FBO.cpp PCM.cpp Preset.cpp BeatDetect.cpp fftsg.cpp KeyHandler.cpp
timer.cpp wipemalloc.cpp BuiltinFuncs.cpp BuiltinParams.cpp Renderer.cpp PresetLoader.cpp PresetChooser.cpp PresetMerge.cpp PipelineContext.cpp ConfigFile.cpp IdlePreset.cpp TimeKeeper.cpp PresetFactory.cpp PresetFactoryManager.cpp ${GLEW_SOURCES})
SET(projectM_SOURCES projectM.cpp PCM.cpp Preset.cpp BeatDetect.cpp fftsg.cpp KeyHandler.cpp
timer.cpp wipemalloc.cpp PresetLoader.cpp PresetChooser.cpp PresetMerge.cpp ConfigFile.cpp TimeKeeper.cpp PresetFactory.cpp PresetFactoryManager.cpp ${GLEW_SOURCES})
if (USE_DEVIL)
SET (projectM_SOURCES ${projectM_SOURCES})
ADD_DEFINITIONS(-DUSE_DEVIL)
SET (IMAGE_LINK_TARGETS IL ILU ILUT)
else (USE_DEVIL)
SET (projectM_SOURCES ${projectM_SOURCES} ${SOIL_SOURCES})
SET (projectM_SOURCES ${projectM_SOURCES})
SET (IMAGE_LINK_TARGETS )
endif (USE_DEVIL)
if (USE_CG)
ADD_DEFINITIONS(-DUSE_CG)
SET (CG_LINK_TARGETS Cg CgGL)
@ -77,7 +78,10 @@ ADD_DEFINITIONS(-DLINUX -DSTBI_NO_DDS -DUSE_THREADS)
endif(WIN32)
endif(APPLE)
ADD_DEFINITIONS(-DCMAKE_INSTALL_PREFIX="\\\"${CMAKE_INSTALL_PREFIX}\\\"")
add_subdirectory(Renderer)
#ADD_DEFINITIONS(-DCMAKE_INSTALL_PREFIX="\\\"${CMAKE_INSTALL_PREFIX}\\\"")
FIND_PACKAGE(OpenGL)
@ -127,7 +131,7 @@ IF(USE_OPENMP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
ENDIF(USE_OPENMP)
INCLUDE_DIRECTORIES(${FTGL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${FTGL_INCLUDE_DIRS} "Renderer")
LINK_DIRECTORIES(${FTGL_LINK_DIRS} "./")
if(BUILD_PROJECTM_STATIC)
@ -135,10 +139,9 @@ if(BUILD_PROJECTM_STATIC)
${CG_LINK_TARGETS})
else(BUILD_PROJECTM_STATIC)
TARGET_LINK_LIBRARIES(projectM ${GLEW_LINK_TARGETS} m ${FTGL_LINK_TARGETS} ${OPENGL_LIBRARIES} ${IMAGE_LINK_TARGETS}
TARGET_LINK_LIBRARIES(projectM Renderer/libRenderer.a MilkdropPresetFactory/libMilkdropPresetFactory.a ${GLEW_LINK_TARGETS} m ${FTGL_LINK_TARGETS} ${OPENGL_LIBRARIES} ${IMAGE_LINK_TARGETS}
${CG_LINK_TARGETS})
endif(BUILD_PROJECTM_STATIC)

View File

@ -443,3 +443,140 @@ void PresetInputs::resetMesh()
}
}
#ifdef USE_MERGE_PRESET_CODE
void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy)
{
double invratio = 1.0 - ratio;
//Merge Simple Waveforms
//
// All the mess is because of Waveform 7, which is two lines.
//
//Merge Custom Shapes and Custom Waves
for (PresetOutputs::cshape_container::iterator pos = A.customShapes.begin();
pos != A.customShapes.end(); ++pos)
{
(*pos)->a *= invratio;
(*pos)->a2 *= invratio;
(*pos)->border_a *= invratio;
}
for (PresetOutputs::cshape_container::iterator pos = B.customShapes.begin();
pos != B.customShapes.end(); ++pos)
{
(*pos)->a *= ratio;
(*pos)->a2 *= ratio;
(*pos)->border_a *= ratio;
A.customShapes.push_back(*pos);
}
for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin();
pos != A.customWaves.end(); ++pos)
{
(*pos)->a *= invratio;
for (int x=0; x < (*pos)->samples; x++)
{
(*pos)->a_mesh[x]= (*pos)->a_mesh[x]*invratio;
}
}
for (PresetOutputs::cwave_container::iterator pos = B.customWaves.begin();
pos != B.customWaves.end(); ++pos)
{
(*pos)->a *= ratio;
for (int x=0; x < (*pos)->samples; x++)
{
(*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio;
}
A.customWaves.push_back(*pos);
}
//Interpolate Per-Pixel mesh
for (int x=0;x<gx;x++)
{
for(int y=0;y<gy;y++)
{
A.x_mesh[x][y] = A.x_mesh[x][y]* invratio + B.x_mesh[x][y]*ratio;
}
}
for (int x=0;x<gx;x++)
{
for(int y=0;y<gy;y++)
{
A.y_mesh[x][y] = A.y_mesh[x][y]* invratio + B.y_mesh[x][y]*ratio;
}
}
//Interpolate PerFrame floats
A.screenDecay = A.screenDecay * invratio + B.screenDecay * ratio;
A.wave.r = A.wave.r* invratio + B.wave.r*ratio;
A.wave.g = A.wave.g* invratio + B.wave.g*ratio;
A.wave.b = A.wave.b* invratio + B.wave.b*ratio;
A.wave.a = A.wave.a* invratio + B.wave.a*ratio;
A.wave.x = A.wave.x* invratio + B.wave.x*ratio;
A.wave.y = A.wave.y* invratio + B.wave.y*ratio;
A.wave.mystery = A.wave.mystery* invratio + B.wave.mystery*ratio;
A.border.outer_size = A.border.outer_size* invratio + B.border.outer_size*ratio;
A.border.outer_r = A.border.outer_r* invratio + B.border.outer_r*ratio;
A.border.outer_g = A.border.outer_g* invratio + B.border.outer_g*ratio;
A.border.outer_b = A.border.outer_b* invratio + B.border.outer_b*ratio;
A.border.outer_a = A.border.outer_a* invratio + B.border.outer_a*ratio;
A.border.inner_size = A.border.inner_size* invratio + B.border.inner_size*ratio;
A.border.inner_r = A.border.inner_r* invratio + B.border.inner_r*ratio;
A.border.inner_g = A.border.inner_g* invratio + B.border.inner_g*ratio;
A.border.inner_b = A.border.inner_b* invratio + B.border.inner_b*ratio;
A.border.inner_a = A.border.inner_a* invratio + B.border.inner_a*ratio;
A.mv.a = A.mv.a* invratio + B.mv.a*ratio;
A.mv.r = A.mv.r* invratio + B.mv.r*ratio;
A.mv.g = A.mv.g* invratio + B.mv.g*ratio;
A.mv.b = A.mv.b* invratio + B.mv.b*ratio;
A.mv.length = A.mv.length* invratio + B.mv.length*ratio;
A.mv.x_num = A.mv.x_num* invratio + B.mv.x_num*ratio;
A.mv.y_num = A.mv.y_num* invratio + B.mv.y_num*ratio;
A.mv.y_offset = A.mv.y_offset* invratio + B.mv.y_offset*ratio;
A.mv.x_offset = A.mv.x_offset* invratio + B.mv.x_offset*ratio;
A.fRating = A.fRating* invratio + B.fRating*ratio;
A.fGammaAdj = A.fGammaAdj* invratio + B.fGammaAdj*ratio;
A.videoEcho.zoom = A.videoEcho.zoom* invratio + B.videoEcho.zoom*ratio;
A.videoEcho.a = A.videoEcho.a* invratio + B.videoEcho.a*ratio;
A.fWarpAnimSpeed = A.fWarpAnimSpeed* invratio + B.fWarpAnimSpeed*ratio;
A.fWarpScale = A.fWarpScale* invratio + B.fWarpScale*ratio;
A.fShader = A.fShader* invratio + B.fShader*ratio;
//Switch bools and discrete values halfway. Maybe we should do some interesting stuff here.
if (ratio > 0.5)
{
A.videoEcho.orientation = B.videoEcho.orientation;
A.textureWrap = B.textureWrap;
A.bDarkenCenter = B.bDarkenCenter;
A.bRedBlueStereo = B.bRedBlueStereo;
A.bBrighten = B.bBrighten;
A.bDarken = B.bDarken;
A.bSolarize = B.bSolarize;
A.bInvert = B.bInvert;
A.bMotionVectorsOn = B.bMotionVectorsOn;
}
return;
}
#endif

View File

@ -48,138 +48,3 @@ void PipelineMerger::MergePipelines(const Pipeline & a, const Pipeline & b, Pipe
out.compositeShader = a.compositeShader;
out.warpShader = a.warpShader;
}
void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy)
{
double invratio = 1.0 - ratio;
//Merge Simple Waveforms
//
// All the mess is because of Waveform 7, which is two lines.
//
//Merge Custom Shapes and Custom Waves
for (PresetOutputs::cshape_container::iterator pos = A.customShapes.begin();
pos != A.customShapes.end(); ++pos)
{
(*pos)->a *= invratio;
(*pos)->a2 *= invratio;
(*pos)->border_a *= invratio;
}
for (PresetOutputs::cshape_container::iterator pos = B.customShapes.begin();
pos != B.customShapes.end(); ++pos)
{
(*pos)->a *= ratio;
(*pos)->a2 *= ratio;
(*pos)->border_a *= ratio;
A.customShapes.push_back(*pos);
}
for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin();
pos != A.customWaves.end(); ++pos)
{
(*pos)->a *= invratio;
for (int x=0; x < (*pos)->samples; x++)
{
(*pos)->a_mesh[x]= (*pos)->a_mesh[x]*invratio;
}
}
for (PresetOutputs::cwave_container::iterator pos = B.customWaves.begin();
pos != B.customWaves.end(); ++pos)
{
(*pos)->a *= ratio;
for (int x=0; x < (*pos)->samples; x++)
{
(*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio;
}
A.customWaves.push_back(*pos);
}
//Interpolate Per-Pixel mesh
for (int x=0;x<gx;x++)
{
for(int y=0;y<gy;y++)
{
A.x_mesh[x][y] = A.x_mesh[x][y]* invratio + B.x_mesh[x][y]*ratio;
}
}
for (int x=0;x<gx;x++)
{
for(int y=0;y<gy;y++)
{
A.y_mesh[x][y] = A.y_mesh[x][y]* invratio + B.y_mesh[x][y]*ratio;
}
}
//Interpolate PerFrame floats
A.screenDecay = A.screenDecay * invratio + B.screenDecay * ratio;
A.wave.r = A.wave.r* invratio + B.wave.r*ratio;
A.wave.g = A.wave.g* invratio + B.wave.g*ratio;
A.wave.b = A.wave.b* invratio + B.wave.b*ratio;
A.wave.a = A.wave.a* invratio + B.wave.a*ratio;
A.wave.x = A.wave.x* invratio + B.wave.x*ratio;
A.wave.y = A.wave.y* invratio + B.wave.y*ratio;
A.wave.mystery = A.wave.mystery* invratio + B.wave.mystery*ratio;
A.border.outer_size = A.border.outer_size* invratio + B.border.outer_size*ratio;
A.border.outer_r = A.border.outer_r* invratio + B.border.outer_r*ratio;
A.border.outer_g = A.border.outer_g* invratio + B.border.outer_g*ratio;
A.border.outer_b = A.border.outer_b* invratio + B.border.outer_b*ratio;
A.border.outer_a = A.border.outer_a* invratio + B.border.outer_a*ratio;
A.border.inner_size = A.border.inner_size* invratio + B.border.inner_size*ratio;
A.border.inner_r = A.border.inner_r* invratio + B.border.inner_r*ratio;
A.border.inner_g = A.border.inner_g* invratio + B.border.inner_g*ratio;
A.border.inner_b = A.border.inner_b* invratio + B.border.inner_b*ratio;
A.border.inner_a = A.border.inner_a* invratio + B.border.inner_a*ratio;
A.mv.a = A.mv.a* invratio + B.mv.a*ratio;
A.mv.r = A.mv.r* invratio + B.mv.r*ratio;
A.mv.g = A.mv.g* invratio + B.mv.g*ratio;
A.mv.b = A.mv.b* invratio + B.mv.b*ratio;
A.mv.length = A.mv.length* invratio + B.mv.length*ratio;
A.mv.x_num = A.mv.x_num* invratio + B.mv.x_num*ratio;
A.mv.y_num = A.mv.y_num* invratio + B.mv.y_num*ratio;
A.mv.y_offset = A.mv.y_offset* invratio + B.mv.y_offset*ratio;
A.mv.x_offset = A.mv.x_offset* invratio + B.mv.x_offset*ratio;
A.fRating = A.fRating* invratio + B.fRating*ratio;
A.fGammaAdj = A.fGammaAdj* invratio + B.fGammaAdj*ratio;
A.videoEcho.zoom = A.videoEcho.zoom* invratio + B.videoEcho.zoom*ratio;
A.videoEcho.a = A.videoEcho.a* invratio + B.videoEcho.a*ratio;
A.fWarpAnimSpeed = A.fWarpAnimSpeed* invratio + B.fWarpAnimSpeed*ratio;
A.fWarpScale = A.fWarpScale* invratio + B.fWarpScale*ratio;
A.fShader = A.fShader* invratio + B.fShader*ratio;
//Switch bools and discrete values halfway. Maybe we should do some interesting stuff here.
if (ratio > 0.5)
{
A.videoEcho.orientation = B.videoEcho.orientation;
A.textureWrap = B.textureWrap;
A.bDarkenCenter = B.bDarkenCenter;
A.bRedBlueStereo = B.bRedBlueStereo;
A.bBrighten = B.bBrighten;
A.bDarken = B.bDarken;
A.bSolarize = B.bSolarize;
A.bInvert = B.bInvert;
A.bMotionVectorsOn = B.bMotionVectorsOn;
}
return;
}

View File

@ -2,13 +2,6 @@
#define PRESET_MERGE_HPP
#include "Preset.hpp"
#include "Pipeline.hpp"
#include "PresetFrameIO.hpp"
class PresetMerger
{
public:
static void MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy);
};
class PipelineMerger
{

View File

@ -1,13 +1,11 @@
PROJECT(Renderer)
cmake_minimum_required(VERSION 2.4.0)
ADD_DEFINITIONS(-DLINUX)
ADD_DEFINITIONS(-DCMAKE_INSTALL_PREFIX="\\\"${CMAKE_INSTALL_PREFIX}\\\"")
SET(Renderer_SOURCES FBO.cpp MilkdropWaveform.cpp PerPixelMesh.cpp Pipeline.cpp Renderer.cpp ShaderEngine.cpp UserTexture.cpp Waveform.cpp Filters.cpp PerlinNoise.cpp PipelineContext.cpp Renderable.cpp Shader.cpp TextureManager.cpp VideoEcho.cpp)
SET(SOIL_SOURCES SOIL/image_DXT.c SOIL/image_helper.c SOIL/SOIL.c SOIL/stb_image_aug.c)
SET(Renderer_SOURCES FBO.cpp MilkdropWaveform.cpp PerPixelMesh.cpp Pipeline.cpp Renderer.cpp ShaderEngine.cpp UserTexture.cpp Waveform.cpp Filters.cpp PerlinNoise.cpp PipelineContext.cpp Renderable.cpp Shader.cpp TextureManager.cpp VideoEcho.cpp ${SOIL_SOURCES})
INCLUDE_DIRECTORIES("../")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/.. "/usr/local/include")
ADD_LIBRARY(Renderer STATIC ${Renderer_SOURCES})
SET_TARGET_PROPERTIES(Renderer PROPERTIES VERSION 2.00 SOVERSION 2)
TARGET_LINK_LIBRARIES(Renderer m)

View File

@ -5,10 +5,9 @@
#include "PerPixelMesh.hpp"
#include "Renderable.hpp"
#include "Filters.hpp"
#include "BeatDetect.hpp"
#include "PipelineContext.hpp"
#include "Shader.hpp"
#include "Common.hpp"
#include "../Common.hpp"
//This class is the input to projectM's renderer
//
//Most implemenatations should implement PerPixel in order to get multi-threaded

View File

@ -3,7 +3,7 @@
#include <string.h>
#include "TextureManager.hpp"
#include "BeatDetect.hpp"
class BeatDetect;
class RenderContext
{

View File

@ -2,7 +2,7 @@
#define Renderer_HPP
#include "FBO.hpp"
#include "BeatDetect.hpp"
class BeatDetect;
#include <string>
#include <set>

View File

@ -30,7 +30,7 @@
#include "Pipeline.hpp"
#include "PipelineContext.hpp"
#include "BeatDetect.hpp"
class ShaderEngine;
#include "TextureManager.hpp"
#include <cstdlib>

View File

@ -14,13 +14,6 @@
#include <GL/gl.h>
#endif
#ifdef USE_DEVIL
#include <IL/ilut.h>
#else
#include "SOIL.h"
#endif
#include "TimeKeeper.hpp"
#include "RandomNumberGenerators.hpp"

View File

@ -22,7 +22,7 @@
#include "fatal.h"
#include "Common.hpp"
#include "compare.h"
#ifdef WIN32
#include "win32-dirent.h"
#endif
@ -45,7 +45,6 @@
#include "PresetMerge.hpp"
//#include "menu.h"
#include "PCM.hpp" //Sound data handler (buffering, FFT, etc.)
#include "IdlePreset.hpp"
#include <map>