[SDL] Small Blit program won't run unless breakpoint set(Mac/XCode)
Michael Ryan Bannon
ryan.bannon at humagade.com
Mon Jul 3 11:52:27 PDT 2006
Hey,
Thanks for the response.
First, I'm trying to recreate some code from the engine I'm porting to Mac,
so that's why I read the file into memory (that's what they were doing
originally, so I just kept with it). Also, I don't know SDL or SDL_Image
that well, so I missed that part.
Regarding portability, I'm not really worrying about that right now. I've
got bigger problems :)
As for explaining how I expect it to work, I guess I can't considering that
it's not working. Again, I don't know SDL that well. What I thought would
happen is to blit the picture surface onto the display surface every
iteration. And at every iteration the alpha would increase until it's reset
to 0. What actually is happening is that it goes up to 255 but doesn't
reset itself.
I assumed that the blit cleared the display when I called it, but I guess
not. What should I be doing differently? It should start as black, fade
into full alpha, then start again. So, how exactly should I be clearing the
blit?
Thanks,
Ryan
"Christian Walther" <cwalther at gmx.ch> wrote in message
news:e8bnrg$f6b$1 at sea.gmane.org...
> Michael Ryan Bannon wrote:
>>> But, naturally, I can't get the code sample to work.
>
> I didn't try your code, but a few comments anyway:
>
> - Why are you reading the file into memory before decoding it with
> SDL_image, when you could just have SDL_image read the file itself? (And
> using this complicated Carbon code at that, when simple stdio would do
> the job?)
>
>>> #include <SDL/SDL.h>
>>> #include <SDL_image/SDL_image.h>
>
> Although I guess it doesn't matter for this sample code, I'd like to
> point out that this isn't portable. SDL.h happens to be in an "SDL"
> directory on Linux (and I guess other Unixes), so that would work, but
> SDL_image.h probably isn't in an "SDL_image" directory (or framework)
> anywhere but on Mac OS X. The portable way is to #include "SDL.h" and
> tell the compiler where it is in the platform-specific build system
> (e.g. on Mac OS X add "/Library/Frameworks/SDL.framework/Headers" to the
> "Header Search Paths" setting in Xcode, or specify
> "-I/Library/Frameworks/SDL.framework/Headers" on the command line). The
> same for SDL_image.h.
>
>> the alpha calls that I'm doing still don't seem to be working.
> ...
>>> // Display
>>> int alpha = 0;
>>> while(true)
>>> {
>>> alpha += 10;
>>> if(alpha > 255)
>>> {
>>> alpha = 0;
>>> }
>>> pSurfaceOne->format->Amask = 0;
>>> SDL_SetAlpha(pSurfaceOne, SDL_SRCALPHA, alpha);
>>> SDL_BlitSurface(pSurfaceOne, NULL, pDisplaySurface, NULL);
>>> }
>
> Care to explain how you expect it to work (after you add the missing
> SDL_UpdateRect)? I expect this code to blit the same image onto itself
> repeatedly in very fast succession (with varying alpha values), so
> except for the first split second you won't see anything but this image.
> Perhaps you meant to clear the display surface between blits, but even
> then you'll probably only get flicker unless you add some SDL_Delay to
> the loop.
>
> Hope this helps
>
> -Christian
More information about the SDL
mailing list