Example #1
0
void Pipeline::setStaticPerPixel(int gx, int gy)
{
	 staticPerPixel = true;
	 this->gx = gx;
	 this->gy = gy;

		this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
		for ( int x = 0; x < gx; x++ )
		{
			this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
		}
		this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
		for ( int x = 0; x < gx; x++ )
		{
			this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
		}

}
Example #2
0
Renderer::Renderer(const pm_config &settings, BeatDetect *beatDetect) : 
settings(settings), mesh(settings.meshX, settings.meshY), beatDetect(beatDetect)
{
	//int x;
	//int y;

	this->totalframes = 1;
	this->noSwitch = false;
	this->realfps = 0;

	/** Other stuff... */
	this->aspect = (float) settings.windowHeight / (float) settings.windowWidth;

    gxInit();
    
	/// @bug put these on member init list
    this->renderTarget = new RenderTarget(settings.textureSize, settings.windowWidth, settings.windowHeight);
    this->textureManager = new TextureManager(settings.presetDirectory);
	this->beatDetect = beatDetect;


	int size = (mesh.height - 1) *mesh.width * 5 * 2;
	p = ( float * ) wipemalloc ( size * sizeof ( float ) );


	for (int j = 0; j < mesh.height - 1; j++)
	{
		int base = j * mesh.width * 2 * 5;


		for (int i = 0; i < mesh.width; i++)
		{
			int index = j * mesh.width + i;
			int index2 = (j + 1) * mesh.width + i;

			int strip = base + i * 10;
			p[strip + 2] = mesh.identity[index].x;
			p[strip + 3] = mesh.identity[index].y;
			p[strip + 4] = 0;

			p[strip + 7] = mesh.identity[index2].x;
			p[strip + 8] = mesh.identity[index2].y;
			p[strip + 9] = 0;
		}
	}


#ifdef USE_CG
	shaderEngine.setParams(renderTarget->texsize, renderTarget->textureID[1], aspect, beatDetect, textureManager);
#endif

}
Example #3
0
void PCM::initPCM(int samples) {
  int i;

    waveSmoothing = 0;

  //Allocate memory for PCM data buffer
    assert(samples == 2048);
  PCMd = (float **)wipemalloc(2 * sizeof(float *));
  PCMd[0] = (float *)wipemalloc(samples * sizeof(float));
  PCMd[1] = (float *)wipemalloc(samples * sizeof(float));

  //maxsamples=samples;
  newsamples=0;
    numsamples = maxsamples;

  //Initialize buffers to 0
  for (i=0;i<samples;i++)
    {
      PCMd[0][i]=0;
      PCMd[1][i]=0;
    }

  start=0;

  //Allocate FFT workspace
  w=  (double *)wipemalloc(maxsamples*sizeof(double));
  ip= (int *)wipemalloc(maxsamples*sizeof(int));
  ip[0]=0;


    /** PCM data */
//    this->maxsamples = 2048;
//    this->numsamples = 0;
//    this->pcmdataL = NULL;
//    this->pcmdataR = NULL;

    /** Allocate PCM data structures */
    pcmdataL=(float *)wipemalloc(this->maxsamples*sizeof(float));
    pcmdataR=(float *)wipemalloc(this->maxsamples*sizeof(float));

}
Example #4
0
Renderer::Renderer(int width, int height, int gx, int gy, int texsize, BeatDetect *beatDetect, std::string _presetURL,
		std::string _titlefontURL, std::string _menufontURL, bool enableFBO, bool enableFBOFast) :
	texsize(texsize), mesh(gx, gy), m_presetName("None"), vw(width), vh(height), title_fontURL(_titlefontURL), menu_fontURL(_menufontURL), presetURL(_presetURL)
{
	this->totalframes = 1;
	this->noSwitch = false;
	this->showfps = false;
	this->showtitle = false;
	this->showpreset = false;
	this->showhelp = false;
	this->showstats = false;
	this->studio = false;
	this->realfps = 0;

	this->drawtitle = 0;

	//this->title = "Unknown";

	/** Other stuff... */
	this->correction = true;
	this->aspect = (float) height / (float) width;;

	/// @bug put these on member init list
	this->renderTarget = new RenderTarget(texsize, width, height, enableFBO, enableFBOFast);
	this->textureManager = new TextureManager(presetURL);
	this->beatDetect = beatDetect;

#ifdef USE_FTGL
	/**f Load the standard fonts */

	title_font = new FTGLPixmapFont(title_fontURL.c_str());
	other_font = new FTGLPixmapFont(menu_fontURL.c_str());
	other_font->UseDisplayList(true);
	title_font->UseDisplayList(true);

	poly_font = new FTGLExtrdFont(title_fontURL.c_str());

	poly_font->UseDisplayList(true);
	poly_font->Depth(20);
	poly_font->FaceSize(72);

	poly_font->UseDisplayList(true);

#endif /** USE_FTGL */


	int size = (mesh.height - 1) *mesh.width * 5 * 2;
	p = ( float * ) wipemalloc ( size * sizeof ( float ) );


	for (int j = 0; j < mesh.height - 1; j++)
	{
		int base = j * mesh.width * 2 * 5;


		for (int i = 0; i < mesh.width; i++)
		{
			int index = j * mesh.width + i;
			int index2 = (j + 1) * mesh.width + i;

			int strip = base + i * 10;
			p[strip + 2] = mesh.identity[index].x;
			p[strip + 3] = mesh.identity[index].y;
			p[strip + 4] = 0;

			p[strip + 7] = mesh.identity[index2].x;
			p[strip + 8] = mesh.identity[index2].y;
			p[strip + 9] = 0;
		}
	}


#ifdef USE_CG
	shaderEngine.setParams(renderTarget->texsize, renderTarget->textureID[1], aspect, beatDetect, textureManager);
#endif

}
Example #5
0
void PresetInputs::Initialize ( int gx, int gy )
{
	int x, y;

	this->gx =gx;
	this->gy= gy;

	this->x_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->x_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->y_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->y_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->rad_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->rad_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->theta_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x <gx; x++ )
	{
		this->theta_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}

	this->origtheta= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origtheta[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->origrad= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origrad[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->origx= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origx[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->origy= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origy[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}

	for ( x=0;x<gx;x++ )
	{
		for ( y=0;y<gy;y++ )
		{
			this->origx[x][y]=mathval(x/ ( float ) ( gx-1 ));
			this->origy[x][y]=mathval(- ( ( y/ ( float ) ( gy-1 ) )-1 ));
			this->origrad[x][y]=mathval( hypotf ( ( mathtofloat(this->origx[x][y])-.5f ) *2, ( mathtofloat(this->origy[x][y])-.5f ) *2 ) * .7071067f);
			this->origtheta[x][y]=mathval(atan2 ( ( ( mathtofloat(this->origy[x][y])-.5f ) *2 ), ( ( mathtofloat(this->origx[x][y])-.5f ) *2 ) ));
		}
	}



}
Example #6
0
void PresetOutputs::Initialize ( int gx, int gy )
{

	assert(gx > 0);
	this->gx = gx;
	this->gy= gy;
	assert(this->gx > 0);
	int x;
	this->x_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->x_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->y_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->y_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->sx_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->sx_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->sy_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->sy_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->dx_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->dx_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->dy_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->dy_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->cx_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->cx_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->cy_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->cy_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->zoom_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->zoom_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->zoomexp_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->zoomexp_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}
	this->rot_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->rot_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}

	this->warp_mesh= ( mathtype ** ) wipemalloc ( gx * sizeof ( mathtype * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->warp_mesh[x] = ( mathtype * ) wipemalloc ( gy * sizeof ( mathtype ) );
	}


}
Renderer::Renderer(int width, int height, int gx, int gy, int texsize, BeatDetect *beatDetect, std::string _presetURL,
		std::string _titlefontURL, std::string _menufontURL, PrismaticInputAdapter* prismaticInput) :
	title_fontURL(_titlefontURL), menu_fontURL(_menufontURL), presetURL(_presetURL), m_presetName("None"), vw(width),
			vh(height), texsize(texsize), mesh(gx, gy)
{
	int x;
	int y;

	this->totalframes = 1;
	this->noSwitch = false;
	this->showfps = false;
	this->showtitle = false;
	this->showpreset = false;
	this->showhelp = false;
	this->showstats = false;
	this->studio = false;
	this->realfps = 0;

	this->drawtitle = 0;

	//this->title = "Unknown";

	/** Other stuff... */
	this->correction = true;
	this->aspect = (float) height / (float) width;;

	/// @bug put these on member init list
	this->renderTarget = new RenderTarget(texsize, width, height);
	this->textureManager = new TextureManager(presetURL);
	this->beatDetect = beatDetect;
  this->prismaticInput = prismaticInput;

#ifdef USE_FTGL
	/** Load the standard fonts if they do exist */
	struct stat buffer;

	if (stat( title_fontURL.c_str(), &buffer )) {
	  std::cout << "Could not open font file: " << title_fontURL << std::endl;
	  exit(1);
	}
	if (stat( menu_fontURL.c_str(), &buffer )) {
	  std::cout << "Could not open font file: " << menu_fontURL << std::endl;
	  exit(1);
	}

	title_font = new FTGLPixmapFont(title_fontURL.c_str());
	other_font = new FTGLPixmapFont(menu_fontURL.c_str());
	poly_font = new FTGLExtrdFont(title_fontURL.c_str());

	if(title_font->Error()) {
		fprintf(stderr, "Failed to open font %s\n", title_fontURL.c_str());
	} else {
		title_font->UseDisplayList(true);
	}

	other_font->UseDisplayList(true);

	if(poly_font->Error()) {
		fprintf(stderr, "Failed to open font %s\n", title_fontURL.c_str());
	} else {
		poly_font->UseDisplayList(true);
		poly_font->Depth(20);
		poly_font->FaceSize(72);
	}

#endif /** USE_FTGL */


	int size = (mesh.height - 1) *mesh.width * 5 * 2;
	p = ( float * ) wipemalloc ( size * sizeof ( float ) );


	for (int j = 0; j < mesh.height - 1; j++)
	{
		int base = j * mesh.width * 2 * 5;


		for (int i = 0; i < mesh.width; i++)
		{
			int index = j * mesh.width + i;
			int index2 = (j + 1) * mesh.width + i;

			int strip = base + i * 10;
			p[strip + 2] = mesh.identity[index].x;
			p[strip + 3] = mesh.identity[index].y;
			p[strip + 4] = 0;

			p[strip + 7] = mesh.identity[index2].x;
			p[strip + 8] = mesh.identity[index2].y;
			p[strip + 9] = 0;
		}
	}


#ifdef USE_CG
	shaderEngine.setParams(renderTarget->texsize, renderTarget->textureID[1], aspect, beatDetect, textureManager);
#endif

}
Example #8
0
void PresetInputs::Initialize ( int gx, int gy )
{
	int x, y;

	this->gx =gx;
	this->gy= gy;


	/// @bug no clue if this block belongs here
	// ***
	progress = 0;
	frame = 1;

	x_per_pixel = 0;
	y_per_pixel = 0;
	rad_per_pixel = 0;
	ang_per_pixel = 0;
	// ***

	this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x <gx; x++ )
	{
		this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->theta_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x <gx; x++ )
	{
		this->theta_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}

	this->origtheta= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origtheta[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->origrad= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origrad[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->origx= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origx[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->origy= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->origy[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}

	for ( x=0;x<gx;x++ )
	{
		for ( y=0;y<gy;y++ )
		{
			this->origx[x][y]=x/ ( float ) ( gx-1 );
			this->origy[x][y]=- ( ( y/ ( float ) ( gy-1 ) )-1 );
			this->origrad[x][y]=hypot ( ( this->origx[x][y]-.5 ) *2, ( this->origy[x][y]-.5 ) *2 ) * .7071067;
			this->origtheta[x][y]=atan2 ( ( ( this->origy[x][y]-.5 ) *2 ), ( ( this->origx[x][y]-.5 ) *2 ) );
		}
	}



}
Example #9
0
void PresetOutputs::Initialize ( int gx, int gy )
{

	assert(gx > 0);
	this->gx = gx;
	this->gy= gy;

	staticPerPixel = true;
	setStaticPerPixel(gx,gy);

	assert(this->gx > 0);
	int x;
	this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->sx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->sx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->sy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->sy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->dx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->dx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->dy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->dy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->cx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->cx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->cy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->cy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->zoom_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->zoom_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->zoomexp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->zoomexp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->rot_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->rot_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}

	this->warp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->warp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
	for ( x = 0; x < gx; x++ )
	{
		this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
	}
	this->orig_x = (float **) wipemalloc(gx * sizeof(float *));
	for (x = 0; x < gx; x++)
	{
		this->orig_x[x] = (float *) wipemalloc(gy * sizeof(float));
	}
	this->orig_y = (float **) wipemalloc(gx * sizeof(float *));
	for (x = 0; x < gx; x++)
	{
		this->orig_y[x] = (float *) wipemalloc(gy * sizeof(float));
	}

		//initialize reference grid values
		for (x = 0; x < gx; x++)
		{
			for (int y = 0; y < gy; y++)
			{
				float origx = x / (float) (gx - 1);
				float origy = -((y / (float) (gy - 1)) - 1);

				rad_mesh[x][y]=hypot ( ( origx-.5 ) *2, ( origy-.5 ) *2 ) * .7071067;
				orig_x[x][y] = (origx - .5) * 2;
				orig_y[x][y] = (origy - .5) * 2;
			}
		}
}