| Spirrwell (9) | |||
Again, sorry for the bad title, but hopefully it'll be understandable. Basically, I'm creating a class for animation and instead of limiting myself to just using OpenGL for more power I would also implement software rendering with the SDL library. First off lets start with the class I have:
I haven't actually created the constructor yet, but basically instead of creating two arrays of the images I'll be loading in the constructor which for OpenGL would be an array of GLuints and in SDL it would be an array of SDL_Surfaces, I want to know how to create one or the other depending on which is currently being used. The problem is if I were to create one of these arrays it would have to be in the constructor once I determine if OpenGL is being used or not, but then the rest of the class wouldn't be able to use the variable because it'd be limited to the scope of the constructor. I also can't create the array without knowing how many frames (images) I'm actually loading which is determined by what is entered into the constructor. So bottom line, is it possible to create variables in the constructor of a class that aren't limited to the scope of that constructor? | |||
|
Last edited on
|
|||
| EssGeEich (1007) | |||||
|
777th Post! You can make the base class a virtual class, and make two derived classes: One SDLAnimationStrip and one OGLAnimationStrip like follows:
When you are going to use them, you should use them like:
Also you need to change from 'private' to 'protected' in your code snip, or you will not be able to access variables from derived classes. | |||||
|
Last edited on
|
|||||
| Spirrwell (9) | |
| I love this place! It's hard not to get answers. Thank you, I'll try this out now.... | |
|
|
|
| EssGeEich (1007) | |
| Last thing: Into "Screen" struct/class you must hold BOTH the SDL's Screen Informations and OGL's Screen Informations. | |
|
|
|