#include "video_GL_mogul.h"
#include <iostream>
		
bool OpenGL_Particles::_set_particle(int particle_num, float x, float y, int r, int g, int b, float a)
{
	if(particle_num>=_count_)return false;
//	_particles_[particle_num*2]=x-_base_x_;
//	_particles_[particle_num*2+1]=y-_base_y_;

	_particles_[particle_num*2]=_base_x_+x;
	_particles_[particle_num*2+1]=_base_y_+y;
	
	_colors_[particle_num*4]=(float)r/255.;
	_colors_[particle_num*4+1]=(float)g/255.;
	_colors_[particle_num*4+2]=(float)b/255.;
	_colors_[particle_num*4+3]=a;
	return true;
}

bool OpenGL_Particles::_get_particle(int particle_num, float * x, float * y, int * r, int * g, int * b, float * a)
{
	if(particle_num>=_count_)return false;
	*x=_particles_[particle_num*2];
	*y=_particles_[particle_num*2+1];
	*r=(int)(_colors_[particle_num*4]*255.);
	*g=(int)(_colors_[particle_num*4+1]*255.);
	*b=(int)(_colors_[particle_num*4+2]*255.);
	*a=_colors_[particle_num*4+3];
	return true;	
}

OpenGL_Particles::~OpenGL_Particles()
{
	if(_particles_)
	{
		delete[] _particles_;
	}
	if(_colors_)
	{
		delete[] _colors_;
	}
}

