1

I wrapped the SDL functions in C++ classes in order to make it simple for me to use them without complicating the code, but I wonder if it is good practice to do so, as, as far as I know, SDL is written for C, no?

Also:

The Core class I made is the one which initializes the screen, so is there any way I can make the screen I made in this class (the main screen) accessible in other classes? (I know I can just pass the pointer, I just don't like this way because it causes a lot of problems when the logic gets complicated.)

Stuart Golodetz
  • 20,238
  • 4
  • 51
  • 80
Qchmqs
  • 1,803
  • 2
  • 20
  • 29

1 Answers1

4

SDL is written in C, not just for C. It's perfectly fine to write a C++ wrapper round it if you want to.

As far as the screen goes, you make it available to other classes in exactly the same sort of way you'd make anything else available - you either pass the pointer around (sensible) or use some sort of global access point for it (usually discouraged).

Stuart Golodetz
  • 20,238
  • 4
  • 51
  • 80
  • so there is no problem ? fine lol,but about the screen: should i keep passing the pointer away ? – Qchmqs Dec 05 '11 at 20:09
  • i did so but other classes will ned the same pointer and i dont like `className->screen;` way – Qchmqs Dec 05 '11 at 20:11
  • 1
    any way it seems like my main question got answered so ... wait 3 minutes SO won't let me accept the answer until 3 mintues – Qchmqs Dec 05 '11 at 20:18