Qchmqs
Qchmqs

Reputation: 1805

I want to wrap SDL functions in C++ Classes

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.)

Upvotes: 1

Views: 681

Answers (1)

Stuart Golodetz
Stuart Golodetz

Reputation: 20656

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).

Upvotes: 4

Related Questions