Direct x lost hardware surface

Hello Sam, I was wondering if you could resolve for me a problem I’m having
using SDL under Windows.
I try using the code (more or less) straight from the example on the
docsproject page, but I find that I never am able to get out of the
SDL_LockSurface loop.
I used exactly the code given in the sample:

    while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
            while ( SDL_LockSurface(image)) < 0 )
                    SDL_Delay(10);
            -- Write image pixels to image->pixels --
            SDL_UnlockSurface(image);
    }

Is there any reason for this happening, or am I just stupid?

— Rob Clayton
skrev: > Hello Sam, I was wondering if you could
resolve for

me a problem I’m having
using SDL under Windows.
I try using the code (more or less) straight from
the example on the
docsproject page, but I find that I never am able to
get out of the
SDL_LockSurface loop.
I used exactly the code given in the sample:

    while ( SDL_BlitSurface(image, imgrect,

screen, dstrect) == -2 ) {
while ( SDL_LockSurface(image)) < 0
)
SDL_Delay(10);
– Write image pixels to
image->pixels –
SDL_UnlockSurface(image);
}

Is there any reason for this happening, or am I just
stupid?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Check your pointers before using them and see if they
are valid…

ie:
assert(image);
while ( SDL_LockSurface(image)) < 0 )
SDL_Delay(10);

maybe something went wrong before the
actualLock/Blit/Unlock-code …like the bitmap
reloading or something

/Anders_____________________________________________________
Do You Yahoo!?
se.yahoo.com

Sigh.
Once you flip to windows, it enters the while loop that attempts to lock the
surface, and never leaves it. It never manages to lock the surface. I
don’t know why :(.
I added an assert around my image surface, and no difference.> ----- Original Message -----

From: andersdarliah@yahoo.com (Anders Lowgren)
To:
Sent: Tuesday, November 27, 2001 12:23 PM
Subject: Re: [SDL] direct x lost hardware surface

— Rob Clayton <@Robert_Sadedin>
skrev: > Hello Sam, I was wondering if you could
resolve for

me a problem I’m having
using SDL under Windows.
I try using the code (more or less) straight from
the example on the
docsproject page, but I find that I never am able to
get out of the
SDL_LockSurface loop.
I used exactly the code given in the sample:

    while ( SDL_BlitSurface(image, imgrect,

screen, dstrect) == -2 ) {
while ( SDL_LockSurface(image)) < 0
)
SDL_Delay(10);
– Write image pixels to
image->pixels –
SDL_UnlockSurface(image);
}

Is there any reason for this happening, or am I just
stupid?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Check your pointers before using them and see if they
are valid…

ie:
assert(image);
while ( SDL_LockSurface(image)) < 0 )
SDL_Delay(10);

maybe something went wrong before the
actualLock/Blit/Unlock-code …like the bitmap
reloading or something

/Anders


Do You Yahoo!?
se.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Sigh.
Once you flip to windows, it enters the while loop that attempts to lock the
surface, and never leaves it. It never manages to lock the surface. I
don’t know why :(.
I added an assert around my image surface, and no difference.

Can you post a complete minimal example that I can use to reproduce the
problem?

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

“Robert Sadedin” wrote in message
news:mailman.1006842126.24166.sdl at libsdl.org

Sigh.
Once you flip to windows, it enters the while loop that attempts to lock
the
surface, and never leaves it. It never manages to lock the surface. I
don’t know why :(.
I added an assert around my image surface, and no difference.

Handling lost surfaces in SDL running over DirectX is incredibly difficult
to get right. I think I got it working once with the following:

  • When ‘SDL_BlitSurface’ returns -2, set a ‘surfaces_lost’ flag and abort
    rendering the current frame.

  • At the start of each frame, if ‘surfaces_lost’ is set and
    ’SDL_GetAppState() & SDL_APPACTIVE’, call the ‘load_bitmaps’ function. This
    functions dumps all old surfaces and loads the bitmaps from the disk. If
    ’load_bitmaps’ fails, the ‘surfaces_lost’ flag remains set and the current
    frame is aborted.

Some of these steps may be unnecessary. The important thing is that there
is no chance for an infinite loop.–
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Thanks a heap Rainer, I’ll give that a shot tonight (Australian time).> ----- Original Message -----

From: root@rainerdeyke.com (Rainer Deyke)
Newsgroups: loki.open-source.sdl
To:
Sent: Wednesday, November 28, 2001 2:42 AM
Subject: Re: [SDL] direct x lost hardware surface

“Robert Sadedin” <@Robert_Sadedin> wrote in message
news:mailman.1006842126.24166.sdl at libsdl.org

Sigh.
Once you flip to windows, it enters the while loop that attempts to lock
the
surface, and never leaves it. It never manages to lock the surface. I
don’t know why :(.
I added an assert around my image surface, and no difference.

Handling lost surfaces in SDL running over DirectX is incredibly difficult
to get right. I think I got it working once with the following:

  • When ‘SDL_BlitSurface’ returns -2, set a ‘surfaces_lost’ flag and
    abort
    rendering the current frame.

  • At the start of each frame, if ‘surfaces_lost’ is set and
    ’SDL_GetAppState() & SDL_APPACTIVE’, call the ‘load_bitmaps’ function.
    This
    functions dumps all old surfaces and loads the bitmaps from the disk. If
    ’load_bitmaps’ fails, the ‘surfaces_lost’ flag remains set and the current
    frame is aborted.

Some of these steps may be unnecessary. The important thing is that there
is no chance for an infinite loop.


Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl