Hi,
When I run this program (trying to learn SDL here…), the program will
quit by just pressing any key on the keyboard. And if I don’t mask out
the Mouse events, the program will crash with a GPF fault.
This is on linux btw, using the FreePascal SDL library 1.2
Any help would be appriciated.
James
Source code included…
Program Demo01 ;
Uses SDL, SDL_Video, SDL_Events, crt;
Const
width = 640 ;
height = 480 ;
colordepth = 16 ;
Var
screen: PSDL_Surface ;
image: PSDL_Surface;
event: PSDL_Event;
done: Boolean;
file_name: String;
Begin
SDL_Init (SDL_INIT_VIDEO) ;
screen := SDL_SetVideoMode (width, height, colordepth, SDL_SWSURFACE)
;
if screen = nil then
Begin
Writeln (‘Couldn’'t initialize video mode at ', width, ‘x’,
height, ‘x’, colordepth, ‘bpp’) ;
Halt(1)
End ;
file_name := ‘splash.bmp’;
image := SDL_LoadBMP(@file_name[1]);
if (image = nil) then
begin
writeLn(‘Couldn’'t load ’ + file_name);
halt(1);
end;
if (SDL_BlitSurface(image, nil, screen, nil) < 0) then
begin
writeLn('BlitSurface error:' {+ SDL_GetError()});
writeLn();
end;
SDL_UpdateRect(screen, 0, 0, image^.w, image^.h);
SDL_FreeSurface(image);
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
done := false;
while (NOT done) do
begin
while (SDL_PollEvent(@event) > 1) do
begin
writeLn(event^.eventtype);
if (event^.eventtype = SDL_QUITMASK) then
begin
writeLn(‘QUIT recieved’);
done := true;
end;
end;
end;
SDL_FreeSurface (screen) ;
SDL_Quit ;
WriteLn(‘Now we are not using SDL’)
End.