PDA

View Full Version : [SOLVED]APP error on event handling



arthurprs
06-10-2007, 10:43 PM
var
screen: PSDL_Surface;
dot: PSDL_Surface;
event: PSDL_Event;
Running: Boolean;
nextstep: Cardinal;

begin
Running := True;
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE or SDL_HWACCEL);
dot := imagingsdl.LoadSDLSurfaceFromFile('dot.png');

repeat
// event manager
while SDL_PollEvent(@event) > 0 do
begin
case event.type_ of
SDL_QUITEV: Running := False;
end;
end;

if SDL_GetTicks >= nextstep then
begin
drawbg;
SDL_UpdateRect(screen, 0, 0, 640, 480);
SDL_FillRect(screen, nil, 0);
Inc(frames);
Inc(nextstep, interval);
end;

SDL_Delay(1);

until not Running;

SDL_FreeSurface(dot);
SDL_Quit;

end.


The app is crashing with this message on "case event.type_ of" line

http://img530.imageshack.us/img530/5598/capture06102007193944uh3.png

For me looks everything right :?
What is the problem?

Setharian
07-10-2007, 05:36 AM
The SDL_PollEvent(@event) call looks fishy to me. You're passing a pointer to a PSDL_Event (PPSDL_Event) and the function expects a PSDL_Event. Replace event variable declaration from PSDL_event to SDL_event and it should work.

arthurprs
07-10-2007, 05:53 AM
The SDL_PollEvent(@event) call looks fishy to me. You're passing a pointer to a PSDL_Event (PPSDL_Event) and the function expects a PSDL_Event. Replace event variable declaration from PSDL_event to SDL_event and it should work.

opz, a T instead of P :? nice observation

thx for the reply

[SOLVED]