LPDIRECTDRAWSURFACE :: Release() ends everything - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

LPDIRECTDRAWSURFACE :: Release() ends everything

I'm trying to deallocate images dynamically (during runtime). For example, when the title screen clears, images and buttons should be deleted. The same should occur between stages. My game contains many (50+ MB) images, and it would be inefficient otherwise. However, LPDIRECTDRAWSURFACE :: Release() ends the program immediately. In the game loop, should released (0/NULL) images not be drawn? Remember, I'm releasing surfaces used as images not the main or back buffers. No one yet has been able to answer this question, though it sounds very simple. Help will be returned.


Comments

  • Need more info!



    But it seems that you are drawing to draw released surfaces, your program crashes right away.



    When I used to DirectDraw, I used this:

    #define CLEANRELEASE(x) if(x){(x)->Rlease();(x)=NULL;}



    That gurantees to set any object I release to NULL, and when I draw

    if( x )

    x->BltFast .. whatever



    : I'm trying to deallocate images dynamically (during runtime). For example, when the title screen clears, images and buttons should be deleted. The same should occur between stages. My game contains many (50+ MB) images, and it would be inefficient otherwise. However, LPDIRECTDRAWSURFACE :: Release() ends the program immediately. In the game loop, should released (0/NULL) images not be drawn? Remember, I'm releasing surfaces used as images not the main or back buffers. No one yet has been able to answer this question, though it sounds very simple. Help will be returned.

    :






  • : Need more info!

    :

    : But it seems that you are drawing to draw released surfaces, your program crashes right away.

    :

    : When I used to DirectDraw, I used this:

    : #define CLEANRELEASE(x) if(x){(x)->Rlease();(x)=NULL;}

    :

    : That gurantees to set any object I release to NULL, and when I draw

    : if( x )

    : x->BltFast .. whatever

    :

    : : I'm trying to deallocate images dynamically (during runtime). For example, when the title screen clears, images and buttons should be deleted. The same should occur between stages. My game contains many (50+ MB) images, and it would be inefficient otherwise. However, LPDIRECTDRAWSURFACE :: Release() ends the program immediately. In the game loop, should released (0/NULL) images not be drawn? Remember, I'm releasing surfaces used as images not the main or back buffers. No one yet has been able to answer this question, though it sounds very simple. Help will be returned.



    You probably right. I noticed my old game code didn't perform any checking or do anything but call :: Release(). Here's the updated version:



    void Sprite :: Free()

    {

    if (Image)

    {

    Image->Release();

    Image = NULL;

    }

    }



    It should work. Thanks.


Sign In or Register to comment.