SDL - Drawing outside an image?

Started by
3 comments, last by Servant of the Lord 17 years, 5 months ago
I'm wondering whether I am going out of bounds, when drawing outside of a surface? Basicly, I'm not bothering to cut my images as I draw them, to fit the screen, and am letting my blitting to overflow outside of the Surface I'm blitting to.
The screen
 _______________
|_______________|   
|            ___|__
|           |...|..|
|           |...|..| The surfaced being blitted
|            ---|--
|               |
|_______________|
Will SDL take care of my blitting going beyond the surface I'm blitting to? Not just the 'screen' surface, but any surface I'm blitting to? Also, I'm assuming in my code I'm working on that class destructors automaticly get called at system exit, or must I delete them with delete or something?
Advertisement
That will be fine. I think it just deletes the overhanging pixels (well it does for the screen).
slymrHopefully game is in progress.
Okay thanks. I thought I'd have to rewrite the code to stop outside drawing. [smile] Glad I can avoid it, although it wouldn't be to annoying.

But the class deconstructers, do I need to delete it specifically, or does it 'deconstuct' at the program quit?

Example: Can I go like this, and let the program automaticly call my decunstruct function?
int main(){   MyClass MyInstance(...Constuctor parameters...);      while(Not Quited)   {      ...      Main Loop      ...   }      return 0;}
Or must I delete MyInstance manually?
int main(){   MyClass MyInstance(...Constuctor parameters...);      while(Not Quited)   {      ...      Main Loop      ...   }      delete MyInstance;   return 0;}

Or, is there some way I call the deconstuctor? I tried '~MyInstance()' but it gave me compile-time errors.
Constructors and destructors are purely a C++ issue and have no relation to SDL. A destructor for an object is called as soon as it goes out of scope. You only call 'delete' on a pointer that points to an object that you previously allocated with 'new'.
Okay thanks. I know that its not SDL related, but I'm creating a SDL_Surface in the class, which ought to then have a SDL_FreeSurface in the destructer. (That's how I think it needs to be done, anyway)

This topic is closed to new replies.

Advertisement