#ifndef CPU_H
#define CPU_H

#include<texturewidget.h>
#include<raig.h>
#include<QVector>
#include<QRgb>
#include<parametres.h>

using namespace std;

class CPU{

public:
    CPU();

    CPU(textureWidget* );
     void raycastingCPU();

    void ShowRCCPUResults(GLubyte* ptTex,int wi, int he);
    virtual GLubyte* raycastingCPU(Parametres* p) = 0;

    textureWidget* getTextureWidget();
    textureWidget* texturewidget;

protected:
    void setid(int);
    friend int getid();

    float *mask;
    float *voxels;
    Raig* raig;
    Lut *colores;
    Material *materialPrimari;
    Material *materialSecundari;
    float UMBRAL_OPACITAT;
    float UMBRAL_SATURACIO;
    GLuint lista;
    int uns;
    FILE *f1;
    char *imagen;
    char *nombreFichero;
    char *unsCS;
    unsigned char *capas;
    vec4  *points;
    vec3  *normals;
    vec4  *colors;
    int anchura, altura, profundidad;
    int NumVoxelsMon;
    int hit;
    float tnear, tfar;
    vec4 *colormascara;
    float getVoxel( int,int,int);
    float getVoxelMask(int i, int j, int k);
    bool intersecta(Raig *raig, Capsa3D cub, float t0, float t1);
    void CarregaParametres(Parametres *p);

    static const int GS_MODE = 0;
    static const int LUT_MODE = 1;
    static const int PHONG_MODE = 2;
    static const int MIP_MODE = 3;
    static const int MIDA_MODE = 4;

private:
    int id;

    virtual vec4 calculIluminacioFTB(Capsa3D cub, Raig raig, int colorMode, Llum *llum) = 0;
    virtual vec4 getColorActual(int mode, float v, int i, int j, int k, Llum *llum, vec4 colorMax) = 0;

    // potser s'elimina



    float planox,planoy,planoz;
    float maxVal,minVal;

    QList<char*> etiquetas;
    QList<float> listaVoxels;


};

#endif // CPU_H
