[fpc-pascal]Weird problem

Anton Tichawa anton.tichawa at chello.at
Sun Nov 24 05:19:44 CET 2002


On Sunday 24 November 2002 04:41, James Mills wrote:

hi, James,

I didn't find anything wrong in your code, but I remember having had troubles 
with ansistring initialization some time ago. Maybe you can check if 
'dataDir' contains the correct value when you use it, or simply set the 
filename: 

filename := './data/images/splash.bmp';

Another possible cause might be, if those strings are shortsstrings, that the 
terminating #0 is missing. You could try

filename := './data/images/splash.bmp'#0;

hth,

Anton.

> Hi,
>
> Sorry to bother you folks, with something that's probably very simple.
>
> But, the code attached does not work, it will not load the splash.bmp
> for some strange reason.
> However, if I copy the code in the procedure displaySplash in gfx.pas
> over to main.pas about displaySplash, like so...
>
> procedure mainLoop;
> var
>    done:    Boolean;
>    filename:   String;
> begin
>    filename := dataDir + '/images/splash.bmp';
>    image := SDL_loadBMP(@filename[1]);
>    if (image = nil) then
>       begin
>          writeLn('Couldn''t load ' + filename);
>          halt(1);
>       end;
>    if (SDL_BlitSurface(image, nil, screen, nil) < 0) then
>       begin
>          writeLn('BlitSurface error:' {+ SDL_GetError()});
>       end;
>    SDL_updateRect(screen, 0, 0, image^.w, image^.h);
>    SDL_freeSurface(image);
>
>    //displaySplash;
>    done := FALSE;
>    while (done = FALSE) do
>       begin
>          if (SDL_PollEvent(event) > 0) then
>             begin
>                if (event^.eventtype = SDL_EventQuit) then
>                   begin
>                      done := TRUE;
>                   end;
>             end;
>       end;
>    cleanUp;
> end;
>
>
> It will work. It won't work if it's called from the gfx library I'm
> trying to build up for a game I'm developing, in SDL.
>
> Could someone explain/help me please.
> thanks in advance.
>
> James




More information about the fpc-pascal mailing list