GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by MrDutchy
class texture
{
    public:
        
        // kon/de-structoren
        
        texture (int initsize);
        texture (int initsize,bool alpha);

        texture (int initsize, float r, float g, float b);
        texture (int initsize, float r, float g, float b, float a);

        texture (char * filename); // noch nicht implementiert

        ~texture ();
        
        // methoden
        void gblur    (int iterations);
        
        void genpnoise    (double alpha, double beta, int n); // alpha scales z, beta scales x/y, n number of octaves
        void pnoisetotexture (float red, float green, float blue, float alpha);
        
        void texture::playwithcells(int numpoints, float * parr);
        void cellular (int numpoints, float * parr, float red, float green, float blue, float alpha);
        
        int  alphablendtex(texture * tex1, texture * tex2, float alpha); // alpha - 0  <-> 1
                                                                                       // color - tex1 color <-> tex2 color
        int  additiveblendtex(texture * tex1, texture * tex2);
        int  multiply(texture * tex1, texture * tex2);

        void multiplybyalpha(float alpha);
        void multiplybyrgb(float r, float g, float b);
        int  texcopy(texture * tex1,int x1,int y1,int x2,int y2);

        int  emboss(texture * source);

        int  setalpha(float r, float g, float b, float alpha);
        void composetertex(texture * hmapt);

        void flattenhmap(int exponent);
        void blurhmap(int iterations);
        
        void distort (texture * output); // noch nicht implementiert
        void displace (); // noch nicht implementiert
        void invert ();
        void delarrays();
        void savetexture(char *filename);
        
        // texture object control methoden
        void bind (int * numbound);
        void update();
        void setactive ();

        int id;
        float * colarr;        // zeiger auf texmap
        float * noisearr;    // zeiger auf noisearray
        bool alphachan;        // rgb/rgba mode, immer nur per klassenmethoden setzen

    private:
        
        // methoden
        float WrapDist(int xpix, int ypix, float xpnt, float ypnt);
        float DistToNearestPoint(int x,int y);

        int   wrap(int zx, int zy);
        int   adress(const int x, const int y);
        int   wraphm(int zx, int zy);
        int   adresshm(const int x, const int y);

        void  initcolarr();
        
        float clampval(float var);
        
        // variablen
        float * distbuffer; // zeiger auf distance buffer
        
        float mindist;
        float maxdist;
        
        float * xcoords;
        float * ycoords;

        int size;
        int points;
};