Results 1 to 9 of 9

Thread: SDL on Delphi XE2

  1. #1

    SDL on Delphi XE2

    Hi.

    I'm installed DelphiXE2 and SDL-JEDI but when I compile my games have a SDL.pas error :

    Code:
    [DCC Error] sdl.pas(358): E2029 Identifier expected but 'CONST' found
    I solved my problem by adding the following to the jedi-sdl.inc file:

    Code:
    {$IFDEF ver230}
      {$DEFINE Delphi}   {Delphi XE2}
      {$DEFINE Delphi32}
      {$DEFINE Delphi4UP}
      {$DEFINE Delphi5UP}
      {$DEFINE Delphi6UP}
      {$DEFINE Delphi7UP}
      {$DEFINE Delphi8UP}
      {$DEFINE Delphi9UP}
      {$DEFINE Delphi10UP}
      {$DEFINE Delphi11UP}
      {$DEFINE Delphi12UP}
      {$DEFINE Delphi14UP}
      {$DEFINE Delphi15UP}
      {$DEFINE Delphi16UP}
      {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7}
      {$DEFINE Has_Int64}
      {$DEFINE HAS_TYPES}
    {$ENDIF ver210}
    Now game compile but no load BMP, PNG or WAV files:

    Code:
    Graphic := SDL_LoadBMP( PChar( sFile ) );
    Code:
    Graphic:= IMG_Load( PChar( sFile ) );
    Code:
    Sound := Mix_LoadWAV( PChar( sFile ) );
    Allways return NIL. No error, but no load. Same code in Delphi2006 work OK.

    What's going on here?

    Thanks
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  2. #2
    Looking at my sdl.pas, I guess that the compiler got uses, but then went trough all the {$IFDEF}s and didn't specify anything to use, going straight to const, hence the "identifier expected". Maybe try {$DEFINE WINDOWS} (since it's Delphi)?

  3. #3
    The problem might be unicode-releated. You pass strings as PChars, but since XE2 is unicode, a char now has a size of 2 Bytes (codepage + char) instead of 1 Byte that it had in earlier versions. So try to pass the filenames different, e.g. cast as ansistring or some type where char size is 1, which SDL obviously expects.

    Some more explanation : Since a Char in Uncide now has two bytes, for SDL your filename will look like this : "M Y F I" instead of "MyFile" due to codepages being stored with each char.

    So you'll e.g. have to do something like this : Graphic := SDL_LoadBMP(PAnsiChar(sFile)), depending how sFile is declared.

  4. #4
    I solve it

    I change all PChar(xxx) for PChar(AnsiString(xxx)) and now work Ok.

    Thanks.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  5. #5
    Hi again.

    Now I can compile my projects in Win32 and Win64, but I like port to iOS and MacOSx.

    Mac OSx
    When I active Platform OSx I have this error in SDL.pas:
    Code:
    [DCC Fatal Error] sdl.pas(318): F1026 File not found: 'Windows.dcu'
    
    317 {$IFDEF WINDOWS}
    318   Windows;
    319 {$ENDIF}
    I'm compile for platform OSx but compiler think I'm compile to Windows.
    How I can tell compiler that I am compiling for Mac OSx and not for Windows ?


    iOS

    When you select iOS and export to Xcode, game is compiled for Xcode in Mac by FPC 2.6.0 and I need SDL.pas in Mac.
    When install in Mac "fpc-2.6.0.intel-macosx.pkg" from "FireMonkey-iOS.dmg" image, JEDI-SDL has installed in:
    Code:
    /Developer/Embarcadero/fpc/packages/sdl
    but I do not know how add library path to use it when compile with Xcode.
    Is there something like "Library" of Delphi where you can indicate paths for search *. pas ?

    For test, I copy SDL.pas from "/Developer/Embarcadero/fpc/packages/sdl/src/SDL.pas" to my project folder but I have next error:
    Code:
    Target OS: Darwin/iPhoneSim fro i386
    Compiling /Users/...../Naves.pas
    Compiling /Users/...../sdl.pas
    Fatal: Can't find unit x used by sdl
    Fatal: Compilation aborted
    I think problem is at line 311 of sdl.pas:
    Code:
    300{$IFDEF UNIX}
    301  {$IFDEF FPC}
    302  pthreads,
    303  unixtype,
    304  baseunix,
    305  {$IFNDEF GP2X}    
    306  unix,
    307  {$ELSE}
    308  unix;
    309  {$ENDIF}
    310  {$IFNDEF GP2X}
    311  x,
    312  xlib;
    313  {$ENDIF}
    314  {$ELSE}
    315  Libc,
    316  Xlib;
    317  {$ENDIF}
    318{$ENDIF}

    Compiler think I'm compile for GP2x ?
    How I can tell compiler that I am compiling for iOS and not for GP2X ?

    Thanks.
    Last edited by kotai; 11-06-2012 at 12:03 PM.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  6. #6
    The SDL headers are not really optimized for Delphi XE2 and I think for it to work on Mac OS X, you will to tweak a few compiler conditions in JEDI-SDL.inc. If I remember correctly, if compiled with Delphi on desktop machines, it assumes Windows is used as its platform.

    With SDL 1.2 on iOS you have two problems:
    - SDL 1.2 does not work on iOS, you need SDL 1.3/2.0 (try these headers: https://github.com/Stoney-FD/sdl13-pascal <-- They worked for me in the past (Disclaimer: I wrote them), but are pretty much alpha, if not pre-alpha)
    - You can't link against dynamic libraries
    Freeze Development | Elysion Game Framework | Twitter: @Stoney_FD
    Check out my new book: Irrlicht 1.7.1 Realtime 3D Engine Beginner's Guide (It's C++ flavored though)

    Programmer: A device for converting coffein into software.

  7. #7
    Thanks for reply.

    ¿ SDL in iOS can't link against dynamic libraries ?
    I download by mercurial SDL2.0 from
    http://hg.libsdl.org/SDL and I build in xcode file library "libSDL2.a"
    ¿ I can't work like windows and put in project folder the library "libSDL2.a" ?

    If I can't complile for MacOS, no problem, but I like port my games to iOS.

    Have you a small example in free pascal for test SDL in iOS ?

    Thanks.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  8. #8
    Member
    Join Date
    Apr 2012
    Location
    Düsseldorf im Rheinland
    Posts
    36

    SDL 1.2.14 Windows 64 bit DLL

    SDL x86_x64 with Header for Delphi Version > 4 und Lazarus 9.30.4 !
    Attached Files Attached Files

  9. #9
    Thanks for SDL64bits.
    I test it this week.

    Kotai.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

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
  •  
Comodo SSL