Reloading hardware surfaces

Greets all, I’m just trying to clear up a few issues regarding the reloading
of hardware surfaces under win32 when application context is lost and then
regained.

Direct x loses all hardware surfaces under these conditions, and I’m
attempting to detect this condition, and to reload my surfaces when
necessary.

To this end, I have an event check in my main loop as follows:

while(SDL_PollEvent(&event)){
switch (event.type){
case SDL_ACTIVEEVENT:
if ( event.active.state & SDL_APPACTIVE ){
if ( event.active.gain )
loadImages();
}
break;
}

My load images function reloads all the surfaces without freeing the memory
allocated by the surfaces originally.

I assume that if I attempt to free the old pointes that have had their
memory ‘trashed’ then my application could crash. Is this a correct
assumption, or am I leaking memory?

Thanks for any help, and any pointers as to whether what I’m doing is
appropriate or not,

Rob

Robert Sadedin wrote:

My load images function reloads all the surfaces without freeing the
memory allocated by the surfaces originally.

I assume that if I attempt to free the old pointes that have had
their
memory ‘trashed’ then my application could crash. Is this a correct
assumption, or am I leaking memory?

It is a false assumption. You are leaking memory.–
Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com