1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-24 08:42:51 +01:00
Clementine-audio-player-Mac.../3rdparty/libprojectm/Renderer/PerPixelMesh.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

2010-06-06 23:43:45 +02:00
#include <math.h>
#include <algorithm>
#include "PerPixelMesh.hpp"
#include "omptl/omptl"
#include "omptl/omptl_algorithm"
PerPixelMesh::PerPixelMesh(int width, int height) : width(width), height(height), size (width * height),
2010-06-07 12:18:35 +02:00
p(width * height, PixelPoint(0,0)),
p_original(width * height, PixelPoint(0,0)),
2010-06-06 23:43:45 +02:00
identity(width * height, PerPixelContext(0,0,0,0,0,0))
{
for (int j=0;j<height;j++)
for(int i=0;i<width;i++)
{
int index = j * width + i;
float xval=i/(float)(width-1);
float yval=-((j/(float)(height-1))-1);
p[index].x = xval;
p[index].y = yval;
p_original[index].x = xval;
p_original[index].y = yval;
identity[index].x= xval;
identity[index].y= yval;
//identity[index].x= (xval-.5)*2;
//identity[index].y= (yval-.5)*2;
identity[index].i= i;
identity[index].j= j;
identity[index].rad=hypot ( ( xval-.5 ) *2, ( yval-.5 ) *2 ) * .7071067;
identity[index].theta=atan2 ( ( yval-.5 ) *2 , ( xval-.5 ) *2 );
}
}
void PerPixelMesh::Reset()
{
omptl::copy(p_original.begin(), p_original.end(), p.begin());
}
2010-06-07 12:18:35 +02:00
PixelPoint::PixelPoint(float x, float y)
2010-06-06 23:43:45 +02:00
: x(x), y(y) {}
PerPixelContext::PerPixelContext(float x, float y, float rad, float theta, int i, int j)
: x(x), y(y), rad(rad), theta(theta), i(i), j(j) {}