Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pteberf

Pages: [1]
1
Window / Re: Way to NOT pass reference to RenderWindow to a class?
« on: May 07, 2016, 05:37:04 pm »
If you want to draw to something then you have to pass this something to the function that does the drawing, I find this very natural and not annoying at all. And this is how everyone else does it too.

@Laurent thanks for feedback. I'll stick with passing the window then. I just thought that not doing it might have been better and I am apparently wrong.  :D

2
Window / Way to NOT pass reference to RenderWindow to a class?
« on: May 07, 2016, 04:06:51 pm »
Greetings, people!

I am developing a video game using SFML and nearly every drawable entity has its own class. There is also a somewhat engine class, containing my RenderWindow.

The problem is that in order to call window's draw() method in any drawable entity's entity_draw() method, I have to either pass a window reference to the entity_draw() method, or have a reference as a member of entity's class and initialise it in a constructor, obvioulsy passing RenderWindow reference to the constructor.

Both variants are very annoying and I am wondering whether there is a good way to "globalize" the RenderWindow somehow.

The best solution I found was creating another class, containing only the window and a videomode(MainWindow class) so they could be accessible from any project file. These two were private static members and constructor and destructor were also private, so I got somewhat of a static class. This however produced an unresolved external symbol error and trying to initialise RenderWindow and VideoMode in different ways didn't produce any result.

Help?  :D :D
Thank you.

Pages: [1]
anything