Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Creating a pointer to a vector of Images

$
0
0

Thanks for your replies. Wasn't able to get the suggestions working. Probably related to other errors in my program.

In the end I changed my constructor for my viewer class for a pointer ofImage objects and a pointer ofImage

in the viewer cpp

Viewer::Viewer(vector<ofImage*>* viewerGrid)

in ofApp:

for(auto &viewGrid: grid){

        area.push_back(Viewer(viewGrid.getImages()));
    }

Looping over elements in the grid class and pushing them back in to the vector ofImage pointers. getImages being my vector of image function. That changed a bit.

vector<ofImage*> *GridElement::getImages(){

    return &images;
}

Then drawing in the vector cpp

 vector<ofImage*> &imageRef = *viewImages;
    imageRef[currentFrame]->draw(552, 0);

Had to save the pointer viewImages to a reference ofImage pointers so then I could access the draw function to display them.

That's what worked for me. Bit new to pointers and references, confused on some bits please correct my explanation if necessary.


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>