mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-22 15:35:55 +00:00
Renderer Unification
git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@1069 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
#include <math.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
PresetInputs::PresetInputs()
|
||||
PresetInputs::PresetInputs() : PipelineContext()
|
||||
{
|
||||
}
|
||||
|
||||
@ -114,6 +114,20 @@ PresetOutputs::~PresetOutputs()
|
||||
|
||||
void PresetOutputs::PrepareToRender()
|
||||
{
|
||||
drawables.clear();
|
||||
|
||||
drawables.push_back(&mv);
|
||||
|
||||
for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
|
||||
pos != customShapes.end(); ++pos)
|
||||
{
|
||||
if( (*pos)->enabled==1) drawables.push_back((*pos));
|
||||
}
|
||||
|
||||
drawables.push_back(&wave);
|
||||
if(bDarkenCenter)drawables.push_back(&darkenCenter);
|
||||
drawables.push_back(&border);
|
||||
|
||||
compositeDrawables.clear();
|
||||
|
||||
if (bBrighten==1)
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
#include "MilkdropWaveform.hpp"
|
||||
#include "Pipeline.hpp"
|
||||
#include "Filters.hpp"
|
||||
#include "CustomShape.hpp"
|
||||
|
||||
class CustomWave;
|
||||
class CustomShape;
|
||||
|
||||
|
||||
/// Container class for all preset writeable engine variables. This is the important glue
|
||||
@ -41,6 +41,7 @@ public:
|
||||
MilkdropWaveform wave;
|
||||
Border border;
|
||||
MotionVectors mv;
|
||||
DarkenCenter darkenCenter;
|
||||
|
||||
Brighten brighten;
|
||||
Darken darken;
|
||||
@ -100,7 +101,7 @@ public:
|
||||
|
||||
/// Container for all *read only* engine variables a preset requires to
|
||||
/// evaluate milkdrop equations. Every preset object needs a reference to one of these.
|
||||
class PresetInputs {
|
||||
class PresetInputs : public PipelineContext{
|
||||
|
||||
public:
|
||||
/* PER_PIXEL VARIBLES BEGIN */
|
||||
@ -112,18 +113,13 @@ public:
|
||||
|
||||
/* PER_PIXEL VARIBLES END */
|
||||
|
||||
int fps;
|
||||
|
||||
|
||||
float time;
|
||||
float bass;
|
||||
float mid;
|
||||
float treb;
|
||||
float bass_att;
|
||||
float mid_att;
|
||||
float treb_att;
|
||||
int frame;
|
||||
float progress;
|
||||
|
||||
|
||||
/* variables were added in milkdrop 1.04 */
|
||||
|
||||
@ -106,7 +106,7 @@ void Shape::Draw(RenderContext &context)
|
||||
{
|
||||
if (imageUrl !="")
|
||||
{
|
||||
GLuint tex = context.textureManager->getTexture(imageUrl);
|
||||
GLuint tex= context.textureManager->getTexture(imageUrl);
|
||||
if (tex != 0)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
@ -26,6 +26,7 @@ public:
|
||||
|
||||
class DarkenCenter : public RenderItem
|
||||
{
|
||||
public:
|
||||
DarkenCenter();
|
||||
void Draw(RenderContext &context);
|
||||
};
|
||||
@ -63,6 +64,7 @@ public:
|
||||
float border_b; /* blue color value */
|
||||
float border_a; /* alpha color value */
|
||||
|
||||
|
||||
Shape();
|
||||
virtual void Draw(RenderContext &context);
|
||||
};
|
||||
|
||||
@ -205,9 +205,8 @@ void Renderer::ResetTextures()
|
||||
textureManager->Preload();
|
||||
}
|
||||
|
||||
void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipelineContext)
|
||||
void Renderer::SetupPass1(const Pipeline* pipeline, const PipelineContext &pipelineContext)
|
||||
{
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@ -242,7 +241,27 @@ void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipe
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef USE_CG
|
||||
}
|
||||
|
||||
void Renderer::RenderItems(const Pipeline* pipeline, const PipelineContext &pipelineContext)
|
||||
{
|
||||
renderContext.time = pipelineContext.time;
|
||||
renderContext.texsize = texsize;
|
||||
renderContext.aspectCorrect = correction;
|
||||
renderContext.aspectRatio = aspect;
|
||||
renderContext.textureManager = textureManager;
|
||||
renderContext.beatDetect = beatDetect;
|
||||
|
||||
for (std::vector<RenderItem*>::const_iterator pos = pipeline->drawables.begin(); pos != pipeline->drawables.end(); ++pos)
|
||||
(*pos)->Draw(renderContext);
|
||||
}
|
||||
|
||||
void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipelineContext)
|
||||
{
|
||||
|
||||
SetupPass1(pipeline, pipelineContext);
|
||||
|
||||
#ifdef USE_CG
|
||||
cgGLBindProgram(myCgWarpProgram);
|
||||
checkForCgError("binding warp program");
|
||||
|
||||
@ -257,28 +276,9 @@ void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipe
|
||||
checkForCgError("disabling fragment profile");
|
||||
#endif
|
||||
|
||||
renderContext.time = pipelineContext.time;
|
||||
renderContext.texsize = texsize;
|
||||
renderContext.aspectCorrect = correction;
|
||||
renderContext.aspectRatio = aspect;
|
||||
renderContext.textureManager = textureManager;
|
||||
renderContext.beatDetect = beatDetect;
|
||||
RenderItems(pipeline,pipelineContext);
|
||||
|
||||
for (std::vector<RenderItem*>::const_iterator pos = pipeline->drawables.begin(); pos != pipeline->drawables.end(); ++pos)
|
||||
(*pos)->Draw(renderContext);
|
||||
|
||||
/** Restore original view state */
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
|
||||
renderTarget->unlock();
|
||||
|
||||
//BEGIN PASS 2
|
||||
FinishPass1(); //BEGIN PASS 2
|
||||
//
|
||||
//end of texture rendering
|
||||
//now we copy the texture from the FBO or framebuffer to
|
||||
@ -318,90 +318,34 @@ void Renderer::RenderFrame(const Pipeline* pipeline, const PipelineContext &pipe
|
||||
|
||||
}
|
||||
|
||||
void Renderer::FinishPass1()
|
||||
{
|
||||
draw_title_to_texture();
|
||||
/** Restore original view state */
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
|
||||
renderTarget->unlock();
|
||||
}
|
||||
|
||||
void Renderer::RenderFrame(PresetOutputs *presetOutputs, PresetInputs *presetInputs)
|
||||
{
|
||||
/** Save original view state */
|
||||
// TODO: check there is sufficient room on the stack
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
totalframes++;
|
||||
|
||||
//BEGIN PASS 1
|
||||
//
|
||||
//This pass is used to render our texture
|
||||
//the texture is drawn to a FBO or a subsection of the framebuffer
|
||||
//and then we perform our manipulations on it in pass 2 we
|
||||
//will copy the image into texture memory and render the final image
|
||||
|
||||
|
||||
//Lock FBO
|
||||
renderTarget->lock();
|
||||
|
||||
glViewport( 0, 0, renderTarget->texsize, renderTarget->texsize );
|
||||
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
|
||||
//If using FBO, sitch to FBO texture
|
||||
if(this->renderTarget->useFBO)
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, renderTarget->textureID[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, renderTarget->textureID[0] );
|
||||
}
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
#ifdef USE_GLES1
|
||||
glOrthof(0.0, 1, 0.0, 1, -40, 40);
|
||||
#else
|
||||
glOrtho(0.0, 1, 0.0, 1, -40, 40);
|
||||
#endif
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
||||
renderContext.time = presetInputs->time;
|
||||
renderContext.texsize = texsize;
|
||||
renderContext.aspectCorrect = correction;
|
||||
renderContext.aspectRatio = aspect;
|
||||
renderContext.textureManager = textureManager;
|
||||
renderContext.beatDetect = beatDetect;
|
||||
SetupPass1(presetOutputs, *presetInputs);
|
||||
|
||||
Interpolation(presetOutputs, presetInputs);
|
||||
|
||||
RenderItems(presetOutputs, *presetInputs);
|
||||
|
||||
presetOutputs->mv.Draw(renderContext);
|
||||
|
||||
|
||||
for (PresetOutputs::cshape_container::iterator pos = presetOutputs->customShapes.begin();
|
||||
pos != presetOutputs->customShapes.end(); ++pos)
|
||||
{
|
||||
if( (*pos)->enabled==1) (*pos)->Draw(renderContext);
|
||||
}
|
||||
|
||||
|
||||
draw_custom_waves(presetOutputs);
|
||||
presetOutputs->wave.Draw(renderContext);
|
||||
if(presetOutputs->bDarkenCenter)darken_center();
|
||||
presetOutputs->border.Draw(renderContext);
|
||||
draw_title_to_texture();
|
||||
/** Restore original view state */
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPopMatrix();
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPopMatrix();
|
||||
|
||||
renderTarget->unlock();
|
||||
FinishPass1();
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@ -112,6 +112,10 @@ private:
|
||||
|
||||
float aspect;
|
||||
|
||||
std::string title_fontURL;
|
||||
std::string menu_fontURL;
|
||||
std::string presetURL;
|
||||
|
||||
#ifdef USE_CG
|
||||
|
||||
CGcontext myCgContext;
|
||||
@ -137,14 +141,15 @@ private:
|
||||
FTGLExtrdFont *poly_font;
|
||||
#endif /** USE_FTGL */
|
||||
|
||||
std::string title_fontURL;
|
||||
std::string menu_fontURL;
|
||||
std::string presetURL;
|
||||
|
||||
|
||||
|
||||
void CompositeOutput(const Pipeline* pipeline);
|
||||
void SetupPass1(const Pipeline* pipeline, const PipelineContext &pipelineContext);
|
||||
void Interpolation(const Pipeline* pipeline);
|
||||
void RenderItems(const Pipeline* pipeline, const PipelineContext &pipelineContext);
|
||||
void CompositeOutput(const Pipeline* pipeline);
|
||||
void FinishPass1 ();
|
||||
void SetupPass2 (const Pipeline* pipeline, const PipelineContext &pipelineContext);
|
||||
|
||||
inline static Point PerPixel(Point p, PerPixelContext &context)
|
||||
{
|
||||
return currentPipe->PerPixel(p,context);
|
||||
@ -152,7 +157,6 @@ private:
|
||||
|
||||
void Interpolation(PresetOutputs *presetOutputs, PresetInputs *presetInputs);
|
||||
|
||||
void draw_waveform(PresetOutputs * presetOutputs);
|
||||
void rescale_per_pixel_matrices();
|
||||
|
||||
void draw_fps( float realfps );
|
||||
|
||||
@ -15,7 +15,7 @@ public:
|
||||
//void unloadTextures(const PresetOutputs::cshape_container &shapes);
|
||||
void Clear();
|
||||
void Preload();
|
||||
unsigned int getTexture(std::string imageUrl);
|
||||
unsigned int getTexture(const std::string imageUrl);
|
||||
unsigned int getTextureMemorySize();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user