I'm quite new to C++ and SFML so please excuse my naivete.
Say I have a class WindowManager which, on construction, allocates a RenderWindow object
and keeps a pointer to it.
Now, say in a different file, I have a main function which creates a WindowManager. Then,
it does something like this:
int main(int argc, char * argv) {
WindowManager wm(); // a RenderWindow object is allocated on the heap in the constructor
while (wm.getRenderWindow()->isOpen) {
sf::Event event;
while (wm.getRenderWindow->pollEvent(event)) {
...
}
}
}
Here's my question:
Because I'm dereferencing the pointer to the sf::RenderWindow object stored in my WindowManager class,
will this code be significantly slower than just creating a sf::RenderWindow on the stack (as a local variable
within main())? Is it generally bad practice to dynamically allocate the sf::RenderWindow object in SFML? I fear it might be bad practice because the RenderWindow object could potentially be huge. It probably needs to store at least one byte for each pixel in the rendered window (presumably much more). The dimensions of a window could be in the tens of millions too.
I guess this also just stems from a weak understanding of heap/stack location/speed.
By the way, the reason I'm doing this in the first place is that I'm attempting to write a game engine.