Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

SDL - Drawing outside an image?

This topic is 4269 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
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!