Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Basic needs for FreePascal with game programming.

  1. #11

    Re: Basic needs for FreePascal with game programming.

    Quote Originally Posted by marcov
    Quote Originally Posted by firehead
    Hello. I wonder if there's any way that I can start the game programming in just using the original FPC compiler(with out Lazarus).
    Well best to start with the (admitted pretty sad) games that come with FPC. There is a tetris and samegame clone, and both work with both graph and in textmode. I still must have an half finished chain-reaction somewhere.
    My Allegro.pas wrapper includes a nice complete platform game. It's very simple and I think very documented. Also I plan to release an almost beta version.
    No signature provided yet.

  2. #12
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: Basic needs for FreePascal with game programming.

    Quote Originally Posted by Brainer
    Quote Originally Posted by AthenaOfDelphi
    You can dynamically load your libraries using loadLibrary (if my memory serves)
    Yep, that's true. To be honest, I have never tried loading a DLL during application's execution, i.e. not at start. But AFAIK existence of external dependencies is checked before an application is actually run. I've never really met any program which thrown an error saying there's a DLL missing in the middle of its execution. But like I said, I may be wrong. If anyone can dispell the doubt, please do so.
    I can dispell the doubt because I've written an application that does it. It's a fractal renderer I wrote many years ago and it stored it's equations in a DLL that is loaded dynamically at run time.

    The way it works is you load a library with loadLibrary and then rather than have the compiler sort the dependencies etc. out at compile time, you use a mechanism similar to event handlers to sort them out yourself. You get the addresses of the calls using getProcAddress (IIRC).

    For example (taken from my Fractal program), here is a prototype definition:-

    [pascal]
    TEQPConfigEQ = procedure( CurrentEQ:Integer;
    var xmin:TFloaty;
    var xmax:TFloaty;
    var ymin:TFloaty;
    var ymax:TFloaty;
    var arg1:TFloaty;
    var arg2:TFloaty;
    var arg3:TFloaty;
    var arg4:TFloaty;
    var arg5:TFloaty;
    var arg6:TFloaty;
    var arg7:TFloaty;
    var arg8:TFloaty ); stdcall;
    [/pascal]

    In your main code you declare a variable like this...

    [pascal]
    EQPConfigEQ : TEQPConfigEQ;
    [/pascal]

    And initialise it using getProcAddress something like this...

    [pascal]
    @EQPConfigEq:=GetProcAddress(EQPLibraryHandle,'EQP lug_ConfigEq');
    [/pascal]

    If this fails, I think (IIRC) EQPConfigEQ ends up equal to NIL. If it succeeds, you call the routines just like a normal procedure called 'EQPConfigEQ'.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #13

    Re: Basic needs for FreePascal with game programming.

    Thank you very much, Athena.

  4. #14
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    Re: Basic needs for FreePascal with game programming.

    I should perhaps also add an example that is closer to home... if anyone uses the DGL OpenGL interface, that uses a similar mechanism to load the OpenGL DLL on the host machine.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #15

    Re: Basic needs for FreePascal with game programming.

    Personally I would not use some DLL extraction technique. It is going to bring you into more problems with antivirusses, and the constantly increasing limitations of doing with binaries that use code.

    If you really want to pursue this, go the way of static linking, but be warned, that takes work and skill.

    Of course I wouldn't even try to do this, and just distribute DLLs. The one .EXE thing is fun from a purist stance, but there are many practical problems. The biggest being that if you finally figured it out, an year later, versions have changed and to upgrade you will have to do it all over again.

    In other words, it is not an one way effort, but something that needs to be repeated as new versions, antivirruses, general security limitations in Windows etc mature.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •