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

Thread: Tilengine 2D Pascal Wrapper!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by megamarc79 View Post
    Hello folks!

    (...) you must provide an external surface for rendering in a compatible pixel format. (..)
    I see. That's the hard thing.

    This works also in the other direction? I mean, loading/creating bitmaps with an external library (SDL, for example) and use them as tiles and sprites.
    No signature provided yet.

  2. #2
    Both in SDL1 and SDL2, when you create surfaces, you can specify the pixel format - when you create an RGB texture, you need to specify the R,G,B,A-masks. You can have RGBA, ABGR or whatever you really want (although with some pixel formats, SDL's "draw line" / "fill rect" functions seem buggy and may draw a blue rectangle instead of a red one). So I guess you could try creating a Tilengine-compatible surface that way.

  3. #3
    Quote Originally Posted by Super Vegeta View Post
    Both in SDL1 and SDL2, when you create surfaces, you can specify the pixel format - when you create an RGB texture, you need to specify the R,G,B,A-masks. You can have RGBA, ABGR or whatever you really want (although with some pixel formats, SDL's "draw line" / "fill rect" functions seem buggy and may draw a blue rectangle instead of a red one). So I guess you could try creating a Tilengine-compatible surface that way.
    Tilengine uses an ARGB pixel format for 32 bpp, and packed 565 RGB for 16 bpp. Both formats are broadly supported almost anywhere.

  4. #4
    Quote Originally Posted by Ñuño Martínez View Post
    This works also in the other direction? I mean, loading/creating bitmaps with an external library (SDL, for example) and use them as tiles and sprites.
    Yes! I wrote the loaders to support Tiled file formats (based on xml and png), but you can implement your own. The API has several functions to build the assets at runtime in memory, actually my standard loaders use those functions internally. Please check the GitHub project, the modules LoadTileset.c and LoadTilemap.c for example. Using them as a reference, you can build yours. Source is C language, but the pascal wrapper is a very thin direct translation of the API, you'll get the point easily.

    The website and GitHub project are a bit outdated, but I'm working to push the current updates and download links. Tilengine has now builds for Raspberry Pi and Android, and the new 16 bpp format for mobile GPUs that don't handle well 32 bpp textures. Managing so much target platforms, language wrappers and examples is becoming increasingly difficult!

  5. #5
    Hi megamarc79,

    on website there are some examples but i don't found Pseudo 3D road (scaling). Can you share some example about it?

    Thanks
    Sesilla

  6. #6
    Quote Originally Posted by SesillaAndromeda View Post
    Hi megamarc79,

    on website there are some examples but i don't found Pseudo 3D road (scaling). Can you share some example about it?

    Thanks
    Sesilla
    The scaling pseudo 3d road is an unfinished sample I was working on. The still image appears ok, but the effect in motion is wrong so I didn't publish the source code. It's not a limitation of the engine, but a misunderstanding on how to implement the effect corrctly. Some real games that used this technique properly were Namco's Final Lap and Suzuka 8 hours series.

  7. #7
    I see some recent activity here I didn't know :-)

    How do I use this without the built-in windowing?
    SetRenderTarget sounds like it might do the trick, but how do I get pointer to a framebuffer in VCL?
    The two parameters required are returned by the typical "lock" function in many systems to get direct pixel acces to a video surface. Check the source code of the built-in windowing based in SDL2. This is what it does at line 785 on a SDL-based surface backbuffer:
    https://github.com/megamarc/Tilengin...c_lib/Window.c

    Pascal wrapper
    This wrapper was originally submitted by turrican, but as Tilengine evolves this wrapper is getting out of sync because it's not being updated anymore. It also lacks any example and build procedure for this language. To keep this language supported, someone should update the binding and provide a pascal version of any of the examples.

    Support
    Tilengine has its own dedicated forum, with threads in english and spanish. You can reach them here:
    http://www.tilengine.org/forum/index.php
    Last edited by megamarc79; 08-09-2017 at 03:02 PM. Reason: typos

  8. #8
    I'd like someone to update it to the most current version of the Tilengine. And maybe provide a graphical Lazarus component, perhaps descendant of TImage (so we wouldn't need to worry about repainting it and it'll be easy to write screenshots) with set of events so we could utilize Tilengine in an OOP manner. Obviously it's not THAT important, but it would be good to have it, not to mention it would make development easier since the built-in windowing is weak and not many have enough skills to setup their own aside of putting components on a form.

  9. #9
    Last edited by Thyandyr; 29-05-2017 at 02:43 PM.

  10. #10
    For Delphi on Windows

    1) Change project output directory to ..\..\..\bin\
    2) In Benchmark method CreateWindow('A', CWF_NONE); instead of CreateWindow(nil, CWF_NONE);
    3) Copy everything from Tilengine-master\lib\win32 to Tilengine-master\bin
    4) Compile
    5) Open command promt to Tilengine-master\bin
    6) Run TileEngine_Benchmark.exe

    Now... that makes the benchmark work. I still have no idea what it does, some odd stuff appears on a window and the exe exits gracefully.

    C:\Users\Admin\Downloads\Tilengine-master\bin>TileEngine_Benchmark.exe
    Tilengine benchmark tool ObjectPascal
    http://www.tilengine.org
    Normal layer..........
    217194570 pixels/s.
    Scaling layer..........
    331034483 pixels/s.
    Affine layer..........
    64602961 pixels/s.
    Blend layer..........
    132780083 pixels/s.
    Scaling blend layer...
    204255319 pixels/s.
    Affine blend layer....
    54825814 pixels/s.
    Affine blend layer....
    423841060 pixels/s.
    Colliding sprites......
    228571429 pixels/s.

    C:\Users\Admin\Downloads\Tilengine-master\bin>
    CPU 12.5%

    The same project in C outputs:

    Tilengine benchmark tool
    Written by Megamarc - Jun 1 2017 19:20:44
    Library version: 1.13.0
    http://www.tilengine.org

    Syntax: benchmark format
    format : pixel format (16 or 32)
    C:\Users\Admin\Downloads\Tilengine-master\bin>

    PS. Got to love the authentic look of old CRT pixels
    Last edited by Thyandyr; 01-06-2017 at 05:32 PM.

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
  •