Sign in to follow this  
Servant of the Lord

SDL - Drawing outside an image?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Kylotan    9860
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'.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this