GordonShumway
27-09-2009, 07:27 PM
Hello fellow Pascalians, (I couldn't resist the temptation. :))
I have kind of a stupid newbie type question, as I'm sure you've gathered from the post title I'm using Delphi 2k9, and am having some rather perturbing problems. (A lot of which were solved elsewhere after some quick perusing on previous posts.)
So after downloading and installing Jedi-SDL (most recent version from source forge, including most recent DLLs from libsdl) I've been able to compile several basic examples. However whenever I call SDL_OPENBMP (or for that matter TTF_OPENFONT) I always get a nil return value. So when I check the error code I get 'Cannot open ?', the '?' is the first letter of the file name that I try to send to it. I have included my code here in hopes that maybe someone could explain to me what I'm doing wrong. I'm sure it's something simple. However (at least for SDL_TTF) it does compile in Lazarus (the tutorials that I've been following have been for fpc and Lazarus.)
Also note that this is in a separate class from the main program with the actual screen surface being referenced by (of course) self.mainScreen
Any help would be very appreciative!
procedure Ttesting.DisplayPic;
var
picture : PSDL_Surface;
srcRect, dstRect: PSDL_RECT;
I: Integer;
fname: PChar;
begin
picture := SDL_LOADBMP('fpsdl.bmp');
if picture = nil then
begin
ShowMessage('Couldn''t load the bmp. ' + PAnsiChar(SDL_GETERROR));
exit;
end;
new(srcRect);
new(dstRect);
srcRect.x := 0;
srcRect.y := 0;
srcRect.w := 200;
srcRect.h := 200;
dstRect.x := 0;
dstRect.y := 0;
dstRect.w := 200;
dstRect.h := 200;
for I := 0 to 200 do
begin
SDL_BLITSURFACE(picture, srcRect, self.mainScreen, dstRect);
SDL_FLIP(self.mainScreen);
dec(srcRect.w);
dec(srcRect.h);
inc(dstRect.x);
inc(dstRect.y);
SDL_DELAY(30);
if srcRect.w = 1 then
begin
srcRect.x := 0;
srcRect.y := 0;
srcRect.w := 200;
srcRect.h := 200;
dstRect.x := 0;
dstRect.y := 0;
dstRect.w := 200;
dstRect.h := 200;
end;
end;
SDL_FREESURFACE(picture);
end;
I have kind of a stupid newbie type question, as I'm sure you've gathered from the post title I'm using Delphi 2k9, and am having some rather perturbing problems. (A lot of which were solved elsewhere after some quick perusing on previous posts.)
So after downloading and installing Jedi-SDL (most recent version from source forge, including most recent DLLs from libsdl) I've been able to compile several basic examples. However whenever I call SDL_OPENBMP (or for that matter TTF_OPENFONT) I always get a nil return value. So when I check the error code I get 'Cannot open ?', the '?' is the first letter of the file name that I try to send to it. I have included my code here in hopes that maybe someone could explain to me what I'm doing wrong. I'm sure it's something simple. However (at least for SDL_TTF) it does compile in Lazarus (the tutorials that I've been following have been for fpc and Lazarus.)
Also note that this is in a separate class from the main program with the actual screen surface being referenced by (of course) self.mainScreen
Any help would be very appreciative!
procedure Ttesting.DisplayPic;
var
picture : PSDL_Surface;
srcRect, dstRect: PSDL_RECT;
I: Integer;
fname: PChar;
begin
picture := SDL_LOADBMP('fpsdl.bmp');
if picture = nil then
begin
ShowMessage('Couldn''t load the bmp. ' + PAnsiChar(SDL_GETERROR));
exit;
end;
new(srcRect);
new(dstRect);
srcRect.x := 0;
srcRect.y := 0;
srcRect.w := 200;
srcRect.h := 200;
dstRect.x := 0;
dstRect.y := 0;
dstRect.w := 200;
dstRect.h := 200;
for I := 0 to 200 do
begin
SDL_BLITSURFACE(picture, srcRect, self.mainScreen, dstRect);
SDL_FLIP(self.mainScreen);
dec(srcRect.w);
dec(srcRect.h);
inc(dstRect.x);
inc(dstRect.y);
SDL_DELAY(30);
if srcRect.w = 1 then
begin
srcRect.x := 0;
srcRect.y := 0;
srcRect.w := 200;
srcRect.h := 200;
dstRect.x := 0;
dstRect.y := 0;
dstRect.w := 200;
dstRect.h := 200;
end;
end;
SDL_FREESURFACE(picture);
end;