Tilengine - The 2D retro graphics engine forum
SetRasterCallback on C# / BeefLang - Printable Version

+- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum)
+-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7)
+--- Thread: SetRasterCallback on C# / BeefLang (/showthread.php?tid=975)



SetRasterCallback on C# / BeefLang - System64 - 12-17-2020

Hello! I'm trying Tilengine on BeefLang by curiosity and I'm trying to do raster effects.
The thing is when I execute SetRasterCallback, it asks for a videocallback :

private static extern void TLN_SetRasterCallback(VideoCallback callback);

I have no idea how to use it. Do you know how to use it please? It's the same thing for C#.


RE: SetRasterCallback on C# / BeefLang - megamarc - 12-17-2020

Hi!
You can get examples on CsTilengine, the C# binding for Tilengine. This line of the "platformer.cs" sample shows how to setup the raster callback:
https://github.com/megamarc/CsTilengine/blob/master/samples/platformer.cs#L75


RE: SetRasterCallback on C# / BeefLang - System64 - 12-17-2020

Is it the same method for the latest Tilengine version?


RE: SetRasterCallback on C# / BeefLang - megamarc - 12-17-2020

It should be, yes. Isn't it working for you?


RE: SetRasterCallback on C# / BeefLang - System64 - 12-17-2020

because in the Java binding, I don't need to do that. It's justĀ 

tln.SetRasterCallback(object, string methodname);

and after, just create a method public void methodname(int line) and here you go!


It's much simpler.


RE: SetRasterCallback on C# / BeefLang - megamarc - 12-17-2020

Java with JNI behaves different than other languages, you pass the string with the name of the Java method to invoke. The hard work is done inside the JNI bridge.
In other languages -like C#- you have to create the callback method as a type of object. In fact it's simpler that the Java way.


RE: SetRasterCallback on C# / BeefLang - System64 - 12-17-2020

In BeefLang, it doesn't work, that's weird

Code:
using Tilengine;
using System;
using TLN.Data;
using TLN.Enums;
using TLN.Types;

namespace TestTilengine
{
class RasterEffects
{
private String rasterMode ~ delete _;
private int layerID;



public this(String rasterMode, int layerID)
{
this.rasterMode = new String(rasterMode);
this.rasterMode.ToLower();
this.layerID = layerID;
}

// VideoCallback callback = new VideoCallback(MyRasterEffects);
TLN.VideoCallback callback = new TLN.VideoCallback(myRasterEffect);
TLN.SetRasterCallback(callback);


public static void myRasterEffect(int line);
{
Tilengine.TLN.SetBGColor((uint8) line, (uint8) line, (uint8) line);
}

}
}



RE: SetRasterCallback on C# / BeefLang - megamarc - 12-17-2020

I don't know Beef, so I can't give support about it. As I've read, it's originally based on C#, but it has some key differences, so it is NOT C#. Maybe you've hit one of those differences...