Tilengine - The 2D retro graphics engine forum

Full Version: SetRasterCallback on C# / BeefLang
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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#.
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/...mer.cs#L75
Is it the same method for the latest Tilengine version?
It should be, yes. Isn't it working for you?
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.
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.
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);
}

}
}
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...