I'm tying to make what I guess would be described as an event system. A dynamic array of functions that get all get called when a single function is called. My problem is that the functions are not getting called and I can't figure out why. I'm not experienced with C++, I'm used to using c# and before that Java.
Here's my code, well the relevant snippets.
Code:
static std::vector<std::function<void()>> * renderFunctions = new std::vector<std::function<void()>>;
//
std::vector<std::function<void()>>::iterator it;
for (it = renderFunctions->begin(); it < renderFunctions->end(); it++) {
(*it)();
}
//
std::function<void(void)> x = testRender;
Display::renderFunctions->push_back(x);
//
void testRender() {
glUseProgram(shader);
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
std::cout << "I'm not getting called, argghh!";
}
The iterator is getting called from a loop.