Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Jedi-SDL & FPC

  1. #1

    Jedi-SDL & FPC

    Hi all,

    I am taking my first steps with Jedi-SDL and unfortunatley, a few things didn't work the way they should (or as I think they should). Installing the SDL was quite easy and the included demos worked well using Delphi 6.

    Afterwards I worked my way through the documentation and came to the following code example (Example 2-3. Loading and Displaying a BMP File):

    Code:
    (*     
     * Palettized screen modes will have a default palette (a standard     
     * 8*8*4 colour cube), but if the image is palettized as well we can     
     * use that palette for a nicer colour matching     
     *)    
    if (image.format.palette and screen_.format.palette) then    
    begin      
      SDL_SetColors(screen_, @image.format.palette.colors[0], 0, image.format.palette.ncolors);    
    end;
    This can't be possible as image.format.palette and screen_.format.palette are of PSDL_Palette, so Delphi refuses to compile. Well thats my first problem. The second one has something to do with the free pascal compiler as I want to use the Jedi-SDL with Linux as well.

    For now I have installed fpc under windows and set it up according to this article:
    http://www.freepascal.org/wiki/index.php/FPC_and_SDL
    I am able to compile the SDL demos without errors but and some of them execute without problems but the Oxygene Demo (...\JEDI-SDL\SDLSpriteEngine\Demos\Oxygene) crashes with the error that the entry point for "IMG_string_equals" was not found in "SDL_image.dll". When I compile it with Delphi it works like a charm.

    Perhaps someone could give me a hint what I have done wrong.

    Thanks in advance
    iax

  2. #2

    Re: Jedi-SDL & FPC

    Quote Originally Posted by IaxFenris
    I am able to compile the SDL demos without errors but and some of them execute without problems but the Oxygene Demo (...\JEDI-SDL\SDLSpriteEngine\Demos\Oxygene) crashes with the error that the entry point for "IMG_string_equals" was not found in "SDL_image.dll". When I compile it with Delphi it works like a charm.
    I have come across this myself a few times, firstly make sure you are running the latest SDL_image.dll you can probably get this from libsdl.org. I think the error actually have something to do with the way smartlinking works under FPC (i could be wrong though), the function IMG_string_equals might not exist in SDL_image any more, Delphi probably just ignores the reference if it's not used, I'm not sure how FPC does this. But the easiest way isto commont out the function declaration in sdl_image.pas and see if it works. If it does then let use know so we can update the headers.
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  3. #3

    Jedi-SDL & FPC

    Thanks for your reply.

    First I have tried to comment the dubious function out but this caused an access violation when starting oxygene.

    Then I tried to update the SDL_image which caused a domino effect as it required a new sdl.dll then a libpng13.dll and finally a zlib1.dll. Once I have installed all these libraries I got the message that the entry point for IMG_string_equals was not found. Great.

    I also tried to comment the function out using the new libraries but starting oxygene raised the visual studio jit-debugger so it wasn't successful as well

  4. #4

    Jedi-SDL & FPC

    Hi Ian,
    Can I ask which version of JEDI-SDL you are using? Is it v0.5 or 1.0beta?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  5. #5

    Jedi-SDL & FPC

    I am using v0.5 of the Jedi-SDL and have now updated to 1.0beta. I also tried to reinstall the runtime libraries (which are only included in v0.5) and found a problem I must have overlooked the first time i intalled them.

    The following compressed runtimes from the v0.5 download are damaged and couldn't be extracted:

    sdl-1.2.2-win32.zip
    sdl_image-1.2.0-win32.zip
    sdl_mixer-1.2.0-win32.zip
    sdl_net-1.2.2-win32.zip

    Its very likely that these damaged zip-files caused the whole trouble.

    The broken Jedi-SDL installation is downloaded from sourceforge, so are there any other sources where I can runtimes that work with Jedi-SDL ?

    thanks
    Michael

  6. #6
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #7

    Jedi-SDL & FPC

    Thanks a lot for the links, savage. I have installed the runtimes and now it works perfectly with fpc

    Next step is installing the whole thing under Linux and I am confident that it will cause at least as much trouble as under Windows


    Oh and maybe someone has an idea how the correct code for the above code fragment should look like, or am I missing the forest through the trees?

  8. #8

    Jedi-SDL & FPC

    [quote="IaxFenris"]Thanks a lot for the ]

    Good to know

    Quote Originally Posted by IaxFenris
    Next step is installing the whole thing under Linux and I am confident that it will cause at least as much trouble as under Windows
    Though JEDI-SDL 1.0 is still in beta is has been tested quite extensively on Linux and to a lesser extent on MacOS X with FPC. So I would hope that you won't have the same hassles. It's fairly stable ( actually more so that 0.5 ) and the only reason why it's not an offical release yet is that I have not had the time or motivation to remove it's beta status. I will get round to doing it, but not sure when.

    Quote Originally Posted by IaxFenris
    Oh and maybe someone has an idea how the correct code for the above code fragment should look like, or am I missing the forest through the trees?
    it should look something like this...
    Code:
    var
      screen &#58; PSDL_Surface;
      colours &#58; array&#91;0..255&#93; of TSDL_Color;
    ...
      // Set palette
      SDL_SetColors&#40;screen, @colours&#91;0&#93;, 0, 256&#41;;
    This is pretty much off the top of my head, so you'll need to confirm if this compiles or not.

    To ensure you have the all the latest bug fixs for JEDI-SDL you might want to consider syncing with CVS.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  9. #9

    Jedi-SDL & FPC

    Thanks for your suggestion, I'll try to get the cvs updates up and running. TortoiseCVS is a good tool to do so, isn't it?


    Considering the code example my SDLTest.dpr looks like this:

    Code:
    program SDLTest;
    
    uses
      windows,
      SysUtils,
      SDL;
    
    var
      screen_ &#58; PSDL_Surface;
    
    procedure display_bmp&#40;file_name &#58; PChar&#41;;
    var
      image &#58; PSDL_Surface;
    begin
      // Load the BMP file into a surface
      image &#58;= SDL_LoadBMP&#40;file_name&#41;;
      if &#40;image = nil&#41; then
      begin
        MessageBox&#40;0, PChar&#40;Format&#40;'Couldn''t load %s &#58; %s',
          &#91;file_name, SDL_GetError&#93;&#41;&#41;, 'Error', MB_OK or MB_ICONHAND&#41;;
        exit;
      end;
      if &#40;image.format.palette and screen_.format.palette&#41; then
      begin
        SDL_SetColors&#40;screen_, @image.format.palette.colors&#91;0&#93;, 0, image.format.palette.ncolors&#41;;
      end;
      // Blit onto the screen surface
      if &#40;SDL_BlitSurface&#40;image, nil, screen_, nil&#41; < 0&#41; then
        MessageBox&#40;0, PCHar&#40;Format&#40;'BlitSurface error &#58; %s', &#91;SDL_GetError&#93;&#41;&#41;, 'Error', MB_OK or MB_ICONHAND&#41;;
      SDL_UpdateRect&#40;screen_, 0, 0, image.w, image.h&#41;;
      // Free the allocated BMP surface
      SDL_FreeSurface&#40;image&#41;;
    end;
    
    begin
      // Initialize the SDL library
      if &#40;SDL_Init&#40;SDL_INIT_VIDEO&#41; < 0&#41; then begin
        MessageBox&#40;0, PChar&#40;Format&#40;'Couldn''t initialize SDL &#58; %s',
          &#91;SDL_GetError&#93;&#41;&#41;, 'Error', MB_OK or MB_ICONHAND&#41;;
        // Clean up on exit
        SDL_Quit;
        exit;
      end;
    
      &#40;*
       * Initialize the display in a 640x480 8-bit palettized mode,
       * requesting a software surface
       *&#41;
      screen_ &#58;= SDL_SetVideoMode&#40;640, 480, 8, SDL_SWSURFACE or SDL_ANYFORMAT&#41;;
      display_bmp&#40;'./auweia.bmp'&#41;;
      if &#40;screen_ = nil&#41; then begin
        MessageBox&#40;0, PChar&#40;Format&#40;'Couldn''t set 640x480x8 video mode &#58; %s',
          &#91;SDL_GetError&#93;&#41;&#41;, 'Error', MB_OK or MB_ICONHAND&#41;;
        SDL_Quit;
        exit;
      end;
    end.
    It is taken directly from the "Object Pascal SDL Doc.chm" file and Delphi complains about the following line:

    Code:
    if &#40;image.format.palette and screen_.format.palette&#41; then
    with the message "Operator is not applicable to this operands." (hopefully proper translated from german)

  10. #10

    Jedi-SDL & FPC

    To fix that in Delphi it should look as follows:

    Code:
    if &#40;image.format.palette and screen_.format.palette&#41; = screen_.format.palette then
    You can and something that large, but you still have to compare it to something. The and gives you back a joined version of the two, then adding the = makes it a true/false comparason for the if statement. I'm not sure that screen_.format.palette belongs on the right hand side of the equal, but it at least gets the idea across.

Page 1 of 3 123 LastLast

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
  •