Results 1 to 10 of 15

Thread: Csfml.pas

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hi Paul,

    Thx. Update with some examples coming soon. So I can test and make sure I got everything just right.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Wow - I've seen sfml used to great effect in Ludum dare compos. Have you been in touch with the SFML devs to have it listed on their site? It'd be an asset to them to have an extra language be supported after all, and I'll be looking forward to those examples to see if SFML is something I will be picking up in future
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  3. #3
    Hi, yea SFML is cool. Its was certainly easier to compile the C/C++ sources vs the others I've tried. It coded/structured in a style similar to my own which makes it also easier for me to work with and way easier to import and use in my project. I am working on the examples, but having a bit of a problem with the event structure:

    Code:
    typedef union
    {
        ////////////////////////////////////////////////////////////
        // Member data
        ////////////////////////////////////////////////////////////
        sfEventType            type; ///< Type of the event
        sfSizeEvent            size;
        sfKeyEvent             key;
        sfTextEvent            text;
        sfMouseMoveEvent       mouseMove;
        sfMouseButtonEvent     mouseButton;
        sfMouseWheelEvent      mouseWheel;
        sfJoystickMoveEvent    joystickMove;
        sfJoystickButtonEvent  joystickButton;
        sfJoystickConnectEvent joystickConnect;
    } sfEvent;
    Here is the delphi version of this that I have:

    Code:
      { TsfEvent }
      TsfEvent = record
        case Integer of
          0: (cType          : TsfEventType);
          1: (size           : TsfSizeEvent);
          2: (key            : TsfKeyEvent);
          3: (text           : TsfTextEvent);
          4: (mouseMove      : TsfMouseMoveEvent);
          5: (mouseButton    : TsfMouseButtonEvent);
          6: (mouseWheel     : TsfMouseWheelEvent);
          7: (joystickMove   : TsfJoystickMoveEvent);
          8: (joystickButton : TsfJoystickButtonEvent);
          9: (joystickConnect: TsfJoystickConnectEvent);
      end;
    ctype, and size are returning values, but for some reason key is not. I've checked and rechecked the structure, alignment, etc. Not sure what the problems is at the moment. key.code is always zero but the sfEvtKeyPressed event is returned, just not the key code value. Is there anything wrong with this structure?

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Hmm, I'm on linux and debugging under wine doesnt really appeal to me. Would it be possible to get the source for a test app of some description? I should have time to play with it tomorrow if you're still having trouble with it.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    Hi, sure here ya go: cfml2_testbed. Thanks. At the moment I am at a lost as to why keyboard event codes are not returning properly. If I set it to some value before the poll event call, afterwards its always set to ZERO (which is sfKeyA in the enum structure). Also included is an updated cfml2.pas file.

    UPDATE: Alright, I think I found the problem. Turns out the enum size was causing the problem. It needs to be: {$MINENUMSIZE 4}. So I will get the header fixed up now, make some examples and push up a new version soon.
    Last edited by drezgames; 04-07-2014 at 11:29 PM.

  6. #6
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Hey there piradyne - took the liberty of modifying your header so it plays nice on linux and with the default library layout. I stuck in a tar.gz up here: https://www.dropbox.com/s/yiv2r0m13j...csfml_2.tar.gz

    I put the testbed program in it too along with the assets it needs. I should point out the .so files in there are for csfml2 for 64 bit gcc. If you're on a 32 bit box - you're going to want to replace 'em for the appropriate versions.

    And a quick screenie of everything working more or less as it should: Screenshot-1.jpg

    Edit: Almost forgot to look at this keyboard problem... Be right back with an update once I have that nailed

    Edit2: Solved it!

    Code:
    type     
      TsfKeyCode = longword;
    And in the testbed:
    Code:
    writeln('KeyCode: ',SwapEndian(event.key.code));
    It has an offset of 1 but I guess you can't get everything XD
    Last edited by code_glitch; 05-07-2014 at 02:27 PM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  7. #7
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    So, quick update with everything working... Albeit with a bit of a kludge - if anyone has a way to do this properly please do chime in. What I've done is this:

    Header:
    Code:
    function  bad_sfRenderWindow_pollEvent(renderWindow: PsfRenderWindow; event: PsfEvent): Boolean; cdecl; external CSFML2_LIB_GRAPHICS; external name 'sfRenderWindow_pollEvent'; 
    function sfRenderWindow_pollEvent(renderWindow: PsfRenderWindow; event: PsfEvent): Boolean; Overload;
    And in the implementation section:
    Code:
    function  sfRenderWindow_pollEvent(renderWindow: PsfRenderWindow; event: PsfEvent): Boolean; 
       
    begin 
        sfRenderWindow_pollEvent := bad_sfRenderWindow_pollEvent(renderWindow, event); 
        event^.key.code := SwapEndian(event^.key.code) + 1; 
    end;
    And now the testbed works flawlessly on my system I've bundled it all up so if you're on a 64 bit linux system - see here: https://www.dropbox.com/s/a0x4krmxbd...rdfixed.tar.gz

    Having seen the testbed code - I'm quite tempted to pick this up as an API for some really quick n dirty development (ala ludum dare ) nice work piradyne

    Edit/Disclaimer: for my 'kludge' to work, 32 bit users may have to change from longword to a 32 bit equivalent. And systems with a different endian-ness may need to remove the swapendian call... But hey - I don't have my username for no reason at all
    Last edited by code_glitch; 05-07-2014 at 03:02 PM.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Tags for this Thread

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
  •