In a graphics program I need to dynamicly allocate memory because I don't know 
the size of the window or the number of points and edges in a system.  I know 
this is a lot of code but I am getting lost in all the pointers...again.

I'm having trouble with the GET below.

        double **buffer;
                // the z-buffer
        vector<GET_entry *>* GET;       
                // global edge table
        vector<GET_entry *>* AET;
                // Active edge table
        void create_tables();
                // dynamicly allocates the z-buffer, GET, and AET.
        void destroy_tables();
                // Frees the dynamicly allocated structures

1.  I wanst to dynamicly allocate the GET.   
2.  I want the GET to have one entry per line in the window (i.e. height).
3.  Each entry in the GET is a reference to a list (a vector).

What is the correct way to declare these?  Particularly the GET?


Here is the implementation that is giving many errors all related to the 5th 
and 6th lines from the bottom where I use "GET[ui]".

void tesselation::create_tables() {
                // Dynamicly allocates the z-buffer, GET, and AET.
        int i, j;
                // z-buffer
        buffer = new double* [height];
        for (i = 0; i < height; i++) {
                buffer [i] = new double [width];
        };
                // Set z-buffer to background
        for (i = 0; i < height; i++) {
                for (j = 0; j < width; j++) {
                        buffer[i][j] = largest();
                };
        };
        GET = new vector <GET_entry*> [height];
};

void tesselation::destroy_tables() {
                // Frees the dynamicly allocated structures
        int i;
        unsigned int ui;
                // deallocate the z-buffer array
        for (i = 0; i < height; i++) {
                delete[] buffer[i];
        };
        delete[] buffer;
                // deallocate GET
        for (ui = 0; ui < GET->size(); ui++) {
                if (! (GET[ui] == NULL) ) {
                        delete GET[ui];
                };
        };
        delete[] GET;
};


thanks,

Jimmy J. Johnson

Reply via email to