Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: sdl2 windows and android

  1. #1

    sdl2 windows and android

    hello friends,
    in recent months I have worked with in sdl2 with freepascal on android compiled from (http://www.pilotlogic.com/sitejoom/index.php/codetyphon) this way came to the conclusion that Native give me better results than java.
    I compiled sdl2 sdl2_image sdl2_mixer and sdl2_ttf all in one dll for Windows and separate (.so) for android.
    the next step is to compile for Ubuntu .
    on this pack i have one demo using sdl2 sd2_image and sdl2_ttf on my experia x8 have 55 fps
    and 20 on BlueStacks.

    (DOWLOAD)
    (windows dll with demo) https://app.box.com/s/wcvfaw1huwpa011t9re8
    (andoid bin demo) https://app.box.com/s/906nasyoewfk6x96dpq4

    my game (sdl + glEs) (200 particles and tile map) on my device i have 45 fps



    Last edited by djoker; 19-11-2013 at 01:54 PM.
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  2. #2
    Wow that's nice. I would like to know more about how to work with SDL2 and Android with Free Pascal. Maybe there is the chance for a how-to?
    Best regards,
    Cybermonkey

  3. #3

  4. #4
    hi folks , tank you for the feedback .
    on my zip is 1 simple demo to show how to start
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  5. #5
    Fantastic !!
    I'm going crazy to try compile SDL2 with DelphiXE5 for android but I can not
    When I add cdecl; external 'libSDL2.so' to any function app not run, say "application has stopped".
    I test too many "libSDL2.so" and with all app not run

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

  6. #6
    kotai I prefer open source programs i have no money to buy delphiXE
    and if you look to sdl you have to make some trick to work with delphi you have 2 ways
    declare android hidden functions from sdl on delphi or expose the native code on delphi jni functions look to my demo.



    procedure Java_org_libsdl_app_SDLActivity_nativeInit(env:JNI Env; cls:jclass; obj:jobject);stdcall;

    begin
    SDL_Android_Init(env,cls);
    SDL_SetMainReady();
    sdlMain();
    logmsg('all ok Luis Santos AKA Djoker');
    halt(0);
    end;




    exports
    JNI_OnLoad,
    JNI_OnUnload,
    Java_org_libsdl_app_SDLActivity_nativeInit;

    begin
    end.

    on the c++ you have the code android_main with this 2 calls look the source code.
    and you have to see one point delphixe5 create native libs with 14,9 MB (15.713.020 bytes) on release mode? man wtf . no way
    goto freepascal


    ps: check this site http://www.crossfpc.com/

    sory mi English
    Last edited by djoker; 20-11-2013 at 09:45 AM.
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  7. #7
    hi kotai i (download xe5) and try with the sdl2 but i think its not possible because with xe5 you don't have way to use java and sdl2 use java for video , audio and input.
    but i think with xe5 you don't need sdl because with xe5 you have all the stuff like glES input ...
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  8. #8
    Thanks for try it.

    In delphi xe5 you have unit androidapi.jni with functions:
    TJNI_OnLoad = function(PVM: PJavaVM; Reserved: Pointer): JNIInt; cdecl;
    TJNI_OnUnload = procedure(PVM: PJavaVM; Reserved: Pointer); cdecl;

    but I not how to use them.

    I like more make android hidden functions from sdl on delphi like other platforms (win32, win64 and macos) and use same code for all platforms.
    Later I prepare a simple example with only SDL_Init for test with android to see if you know the problem

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

  9. #9
    kontai i use my jni functions from freepscal is the same the problem and i don't see my exported functions from delphixe5 i use idaq to decompile .so libs and look the import/export functions
    and the big problem from sdl is that you don't have access to Java i think.
    jni is global system form compilers like delphi/c++ create native code to java jni is just the headers to communicate java/native on android or windows .


    ""
    procedure Java_org_libsdl_app_SDLActivity_onNativeAccel(
    env:JNIEnv; cls:jclass;
    x:jfloat;y:jfloat; z:jfloat);stdcall;""

    Java_org_libsdl_app_SDLActivity
    org.libsdl.app is the package name
    onNativeAccel the name of the function imported from java exported from delphi
    SDLActivity is the name of the activity

    now on java
    "
    public static native void nativeInit();/declare function

    class SDLMain implements Runnable {
    @Override
    public void run() {
    // Runs SDL_main()
    SDLActivity.nativeInit();

    Log.v("SDL", "SDL thread terminated");
    }
    }


    "
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  10. #10
    Hi again.

    I make this ultra simple example for test SDL2 on Delphi XE5. It work perfect on Win32, Win64 and MacOSX but not in android (compile ok and deploy to phone, but when open say "application has stopped" and close it.)
    For Android I add file "libSDL2.so" in menu deployment to folder "/lib"

    SDL2Test.dpr :
    Code:
    program SDL2Test;
    
    
    uses
      System.SysUtils;
    
    
    const
      {$IFDEF MSWINDOWS}
        SDL_LibName = 'SDL2.dll';
      {$ENDIF}
    
    
      {$IFDEF ANDROID}
        SDL_LibName = 'libSDL2.so';
      {$ENDIF}
    
    
      {$IFDEF MACOS}
        {$IFDEF IOS}
          {$IFDEF CPUARM}
            SDL_LibName = 'libSDL2.a';
          {$ELSE}
            SDL_LibName = 'libSDL2Simulator.a';
          {$ENDIF}
        {$ELSE}
          SDL_LibName = 'SDL2';
        {$ENDIF}
      {$ENDIF}
    
    
      function SDL_Init(flags: UInt32): LongInt cdecl; external SDL_LibName name 'SDL_Init';
    
    
    
    
    begin
         try
            if SDL_Init(0) < 0 then
               Writeln('Can not Init SDL')
            else
               Writeln('SDL Init OK');
         except
            on E: Exception do
               Writeln(E.ClassName, ': ', E.Message);
         end;
         repeat
         until False;
    end.
    What is the problem ?

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

Page 1 of 2 12 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
  •