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

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.