PDA

View Full Version : JEDI-SDL with FPC (no IDE), Win32



Bijo
03-06-2007, 11:29 PM
Hi there,


I've been following this thread (http://www.pascalgamedevelopment.com/viewtopic.php?t=3906&postdays=0&postorder=asc&start=0) and this one (http://wiki.freepascal.org/FPC_and_SDL) but when I compile the test program Oxygene the SDL unit can't be found.


That FPC page doesn't look like it's for Windows, but I figured whatever. I had to change all the /'s to \'s when I copied the lines into my fpc.cfg file and put the path.


Grrr, it's like an information overload and I'm just wasting too much time figuring things out :clown:

godbeast
03-06-2007, 11:39 PM
You can do something like this:

1) make "sdl" directory in your units dir
2) copy all the pas files you need (sdl.pas, sdl_mixer.pas etc.) to this dir

Run freepascal and add:

c:\my_projects_dir\fpc\units_dir\sdl
c:\my_projects_dir\fpc\units_dir\sdl/*

Remeber to keep dlls in your program dirs

Bijo
04-06-2007, 12:04 AM
:shock:

Well, there's a problem: I don't know what files I need. I'm just getting at this SDL for the first time. Setting it up for use with MinGW a while ago was also a pain in the ass (I'm very noobish at installing libraries for use). Why is there no easy installation of some kind for no-hassle people like me (without using Lazarus)?

What do you mean by...

Run freepascal and add:

c:\my_projects_dir\fpc\units_dir\sdl
c:\my_projects_dir\fpc\units_dir\sdl/*
...? You mean the linking with use of -Fu ? You mean I should add it to be included with an IDE (that I don't use)?

Man, I think I need a break from this programming stuff for a while before my head explodes.

DarknessX
04-06-2007, 12:46 AM
Bijo, open FPC, and go to:
Directories --> Units, and add the following directories: (Assuming that your SDL folder is at C:\Projects\Jedi-SDL\)


C:\Projects\Jedi-SDL\SDL\Pas\
C:\Projects\Jedi-SDL\OpenGL\Pas\
C:\Projects\Jedi-SDL\fmod\Pas\
C:\Projects\Jedi-SDL\ODE\Pas\
C:\Projects\Jedi-SDL\SDL_Image\Pas\
C:\Projects\Jedi-SDL\SDL_Mixer\Pas\
C:\Projects\Jedi-SDL\SDL_Net\Pas\
C:\Projects\Jedi-SDL\SDL_Sound\Pas\
C:\Projects\Jedi-SDL\SDL_ttf\Pas\
C:\Projects\Jedi-SDL\SDLFilter\Pas\
C:\Projects\Jedi-SDL\SDLMonoFonts\Pas\
C:\Projects\Jedi-SDL\SDLSpriteEngine\Pas\
C:\Projects\Jedi-SDL\SFont\Pas\
C:\Projects\Jedi-SDL\smpeg\Pas\


And then click the Includes tab, and add:


C:\Projects\Jedi-SDL\SDL\Pas\


Now it should work fine... That adds all files you will ever need for JEDI-SDL.

savage
04-06-2007, 09:37 AM
General JEDI-SDL docs are now available as part of the latest beta download or online @ http://jedi-sdl.pascalgamedevelopment.com/docs.php#Docs

There is also a "Using JEDI-SDL with FreePascal" document available here -
http://jedi-sdl.pascalgamedevelopment.com/html_docs/Using%20SDL%20under%20Free%20Pascal.htm

I hope one of these is usefull.

Bijo
04-06-2007, 12:54 PM
I followed your second link, Savage, and some of the links are dead. It's the part that says
You can download the 1.9.2 aka 2.0.0-Beta2 release for the following operating systems :

* Linux (Intel X86)
* Linux (PowerPC)
* Win32 (Windows 95, 98, ME, 2000, NT)
* FreeBSD (FreeBSD 4.x and probably 5.x too)


Well, I just forgot about that and used the download at Sourceforge; the JEDI-SDLbeta1.

When I compile the test program there down below using
fpc -Sd <pasfile> I get 6 errors. (There a way to quickly generate a text file with the compiler errors, while compiling?)

savage
04-06-2007, 01:24 PM
That beta1 download is a couple of years old. Please grab the latest one from
http://www.pascalgamedevelopment.com/jedi-sdl/files/JEDI-SDLv1.0.zip which is where the nearly nightly builds will be available from until v1.0 is finally released.

Can you post what compilation errors you are getting?

Bijo
04-06-2007, 02:19 PM
The errors:


&#40;8,13&#41;&#58; identifier not found "PSDLSurface"
&#40;8,24&#41;&#58; error in type definition
&#40;24,16&#41;&#58; operator not overloaded
&#40;30,20&#41;&#58; unknown record field identifier "_TYPE"
&#40;34,23&#41;&#58; incompatible type for arg no. 1&#58; got "<erroneuos>", expected "PSDL_Surface"
&#40;38,28&#41;&#58; incompatible type for arg no. 1&#58; got "<erroneuos>", expected "PSDL_Surface"



Should I put a # before -FiC:/JEDI-SDLv1.0/SDL/Pas in FPC.CFG? It said nothing about it in the second link (about using JEDI-SDL w/ FPC). Seems it doesn't have any noticeable effect, though.

savage
04-06-2007, 02:28 PM
Hold on you are using PSDLSurface that should be PSDL_Surface.

as long as your fpc.cfg contains

-FiC&#58;/JEDI-SDLv1.0/SDL/Pas
and

-FuE&#58;/JEDI-SDLv1.0/SDL/Pas

it should find sdl.pas

Bijo
04-06-2007, 03:23 PM
Okay, corrected it. Now there's one error in (30,20) there's unknown record field identifier "_TYPE".

I don't know, man. For this quick compile test -- well, it was supposed to be quick :D -- I just copied the code from that page (with line 8: PSDLSurface made into PSDL_Surface).

program SDLtest;

uses
sdl,
sdlutils;

var
_screen : PSDLSurface; {made this PSDL_Surface}
event : TSDL_Event;

const
Done : Boolean = False;

begin
// Initialise the SDL video sub-system
if ( SDL_Init( SDL_INIT_VIDEO) < 0 ) then
begin
exit;
end;

// Set the Window Width, Height, Colour Depth and turn on double buffering
_screen := SDL_SetVideoMode( 640, 480, 16, SDL_DOUBLEBUF );

if ( _screen <> nil ) then
begin
repeat
// This is where we check for Screen, Keyboard and Mouse events
while ( SDL_PollEvent( @event ) = 1 ) do
begin
if ( event._type = SDL_QUITEV ) then
Done := True;
end;

SDL_Flip(_screen);
until Done;

// Since we are finished with it we need to free it
SDL_FreeSurface(_screen);
end;

// Shut Down SDL and exit
SDL_Quit;
end.

I have no clue. Is there an easier smaller test code that just initializes SDL and compiles, sum' like that? Just to make sure the installation is okay, 'cause the more trouble the setup gives me, the less attractive it becomes to starting learning to use this library.

savage
04-06-2007, 03:46 PM
Apologies Bijo. It seems the so called "Latest" documentation was out of date. I have just updated it...

Please use this..

program SDLtest;

uses
sdl,
sdlutils;

var
_screen : PSDL_Surface;
event : TSDL_Event;
Done : Boolean = False;

begin
// Initialise the SDL video sub-system
if ( SDL_Init( SDL_INIT_VIDEO) < 0 ) then
begin
exit;
end;

// Set the Window Width, Height, Colour Depth and turn on double buffering
_screen := SDL_SetVideoMode( 640, 480, 16, SDL_DOUBLEBUF );

if ( _screen <> nil ) then
begin
repeat
// This is where we check for Screen, Keyboard and Mouse events
while ( SDL_PollEvent( @event ) = 1 ) do
begin
if ( event.type_ = SDL_QUITEV ) then
Done := True;
end;

SDL_Flip(_screen);
until Done;

// Since we are finished with it we need to free it
SDL_FreeSurface(_screen);
end;

// Shut Down SDL and exit
SDL_Quit;
end.


This should compile and run.

Bijo
04-06-2007, 04:14 PM
No problem, Savage. I appreciate all the help, and I know that you -- like many others -- are doing good work on stuff for the Pascal community 8) (it's you who maintains JEDI-SDL, true?).


It compiles just perfectly. I'll start looking for some stuff to get me started :)

Thanks everybody for the effort.

WILL
04-06-2007, 04:56 PM
(it's you who maintains JEDI-SDL, true?).

He's the guy. ;)


I'll start looking for some stuff to get me started :)

You can check out my tutorial series in the Articles section. It's designed with Lazarus in mind, but it should work for raw FPC. JEDI-SDL is what I use for graphics, input, etc. Should give you an idea of how to put together a game with it.

Bijo
04-06-2007, 06:11 PM
The Artillery articles: that stuff looks good, WILL. I'll surely check it out, but I'm first wanting to make my Pong game, heh heh :) (I think the game you describe in there is a bit too much for an inexperienced programmer like me.)

Most of the resources I find about SDL use C++ to explain things, so I guess I'll have to go translating again. Oh, the good times I'll have :P

WILL
04-06-2007, 07:28 PM
Actaully it's aimed at beginners. I kept it very simple and easy to pickup.

But I'd recommend you do your Pong game first so you get the basic concepts in programming with graphics first. I actually had some fun with Arkanoid/Breakout and pong when I was first learning myself. Made a ton of versions with different features. ;)

If you get really stuck you can take a look at the provided source that I have in my tutorial as it shows you how to use JEDI-SDL properly. Give or take whatever setting I have that are geared towards the game being made.