Sign in to follow this  

SDL - Drawing outside an image?

This topic is 4089 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
That will be fine. I think it just deletes the overhanging pixels (well it does for the screen).

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
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
Sign in to follow this