OpenFL - TileMap advices?


#1

Hello everybody !
I’m currently asking the limit of TileMap system of OpenFl.
And whatever I read I remain a little confused between 3D, graphical card enhancement or not.
So maybe, your experience on that subject may help me to orient well my graphic stepwork on a project of mine.

Assuming I have proper files prepared to, with TileMap, I may be able to duplicate Bitmap data on a “projector”, (or several projectors) of the scene size, behind all other general display like UI, sprites and so forth…

Am I right ?

With such a presomption, I tried to visualize what role could fullfill each projector layer, for example :
• one for the grounded carot of earth.
• one for the ground vegetals,
• one for the vertical vegetals (that I may obfuscate on user mouseover by example)
• one for the UI,

…example of intended result…

For that,
• I may load external files, like textures one
• Assemblate them in TileMap
• Duplicate them on their respective projector
• May I alter one elements brightness for example, without touching another one, and tried some random effects for the corners of the scene, like blur, scale, colorize, and so forth ?!

Thanks for your time !


#2

Tilemap runs in one of two modes:

Software

On the Flash target, or when running a Cairo renderer (native platforms) or HTML5 canvas (on HTML5) it works in software. This is not the default on native or HTML5, which default to using OpenGL rendering.

The width and height of your Tilemap will be the size of a BitmapData-like surface. Rendering tiles works using software blitting. Square operations that do not include rotation, alpha or other special effects will perform faster.

Hardware

When OpenGL is being used (default on all targets except Flash) no surface is allocated, and it is rendered directly to the screen buffer. Rotation, scale and alpha are practically no cost. The cost primarily comes from the number of draw calls made. When possible, all objects will be drawn in in the same call. There are some things that can cause additional calls:

  • Changing the source Tileset object to render from
  • Changing between different custom shader types

Adding a post-process filter (tilemap.filters) will result in rendering first to a texture, then rendering again with the filter. Some filters (like blur) require multiple passes.

Using two Tilemaps will require at least two draw calls, but that’s not unreasonable


#3

Flash is no more a viable target.
Sic.
If I could embed all that for windows/iOS with file systems/network and maybe one day android, it would be marvelous !
One step after one step.

But I’m really happy of your personal interest SingMajesty.
If I understand well :
• my primary targets are currently openGL, interfaced by OpenFL and his Tilemap system.
• all I have to do is to project where/when/which part of a TileSheet appears in his projector, with more or less compatible effect.
• but I have no need at that level, to speculate with true 3D projection, but I may whatever benefit of the hardware stimulation by loading, on the fly, files converted in bitmap and decomposated in Tilemap.

Am I still right ?


#4

That sounds about right.

So your targets are hardware accelerated (using OpenGL) by default, but you can use Tilemap + Tileset to optimize 2D rendering without having to write 3D rendering code.

The fewer Tilesets, the fewer calls, but things should still run well even if you do need a few


#5

Thanks a lot !
I will try that.
Regroup ground carrot and grounded vegetals.
Another one for vertical vegetals, and see what happens.
Thanks again.


#8

A bit complex to determine which component of Visual Studio Community are needed !

Within console, I get :

openfl build windows
Creating C:/HaxeToolkit/haxe/Role/BunnyMark/Export/windows/obj/obj/msvc19-ncxp/__pch/haxe/hxcpp.pch…
hxcpp.cpp

Compiling group: haxe
cl.exe -Iinclude -nologo /WX- /fp:precise -DHX_WINDOWS -GR -O2(optim-std) -Zi(debug) -FdC:\HaxeToolkit\haxe\Role\BunnyMark\Export\windows\obj\obj/msvc19-ncxp/vc.pdb(debug) -Od(debug) -O2(release) -Os(optim-size) -FS -Oy- -c -EHs -GS- -arch:SSE2 -IC:/HaxeToolkit/haxe/lib/hxcpp/3,4,188/include -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=331(haxe) -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -DHX_WIN_MAIN(main) -wd4996 … tags=[haxe,static]

  • src/lime/utils/ObjectPool.cpp [haxe,release]
  • src/lime/utils/Log.cpp [haxe,release]
  • src/lime/utils/ObjectPool_openfl_geom_Point.cpp
  • src/lime/utils/ObjectPool_openfl__internal_renderer_ShaderBuffer.cpp
  • src/lime/utils/ObjectPool_openfl__internal_TouchData.cpp
  • src/lime/utils/ObjectPool_openfl_geom_Rectangle.cpp
  • src/lime/utils/ObjectPool_openfl_geom_Matrix.cpp
  • src/lime/utils/AssetCache.cpp [haxe,release]
  • src/Main.cpp
  • src/lime/utils/ObjectPool_openfl_Vector_openfl_display_DisplayObject.cpp
  • src/ApplicationMain.cpp
    Link: ApplicationMain.exe
    LINK : l’éditeur de liens 32 bits (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\link.exe) n’a pas pu effectuer d’E/S de fichier mappé en mémoire sur ‘obj\msvc19-ncxp\d2e3f31c_NativeCFFI.obj’ et va redémarrer l’édition des liens avec un éditeur de liens 64 bits pour un meilleur débit
    LINK : échec de la localisation d’un éditeur de liens 64 bits sur %PATH% ; poursuite de l’édition des liens ; passez à un éditeur de liens 64 bits
    obj\msvc19-ncxp\d2e3f31c_NativeCFFI.obj : fatal error LNK1136: fichier non valide ou endommagé

But with Haxedevelop and only debug > windows mode, I can get a personalized BunnyMark work.

And really, I have to admit.
IT REALLY ROCKS !!!
Amazing !!! I can really see my GraphicalCard works and keep an amazing FPS !

Congratulations for the work “behind the scene”.


#9

If you’re getting errors like this, can you try doing a -clean build? It might help?

openfl test windows -clean

#10

It didn’t work yesterday, but today it does.!
No more windows compilation problem.
Thanks.