#ifndef PROJECT_VOLUMES_H
#define PROJECT_VOLUMES_H

#include <SDL/SDL_OpenGL.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include "math_vector3D.h"

enum {VGEN_EMPTY, VGEN_PLASMA, VGEN_SPHERE};
enum {VRND_SLICES, VRND_SHADERS, VRND_OPENCL};

#define default_width 128
#define default_height 128
#define default_depth 128

#define default_iso_depth 0.5

typedef struct vpal
{
	unsigned char r,g,b,a;
}vpal;


void ClearBorders(int width, int height, int depth, unsigned int *voldata);

class Cvolume
{
public:
	Cvolume(int width = default_width, int height = default_height, int depth = default_depth);
	~Cvolume();

	void UploadVolumeTexture();
	GLuint InitVolumeTexture();
	GLuint GetVolumeID();

	int GetWidth();
	int GetHeight();
	int GetDepth();

	unsigned int* GetDataPointer();

	float GetIsoDepth();
	void SetIsoDepth(float iso_depth);

	void GenVolume(int way);
	void LoadVolume(char *filename);
	void RenderVolume(int way, bool alpha, Cvector pos, Cvector dir, Cvector up, Cvector right);

protected:
	int width;
	int height;
	int depth;

	float iso_depth;

	unsigned int *data;
	GLuint vol_id;

	void GenVolumeEmpty();
	void GenVolumePlasma();
	void GenVolumeSphere();

	void RenderVolumeSlices(bool alpha, Cvector pos, Cvector dir, Cvector up, Cvector right);
	void RenderVolumeShaders(bool alpha, Cvector pos, Cvector dir, Cvector up, Cvector right);
	void RenderVolumeOpenCL(bool alpha, Cvector pos, Cvector dir, Cvector up, Cvector right);

	void FadeByDistanceFromCenter(float radius);

	void DrawSlice(int num, Cvector pos, Cvector spc);
};

#endif
