Setting different Lime renderer


so lime.ui.Window has a renderer property Which is most often set to OPENGL.
I look here…:

enum RenderContext {
	OPENGL (gl:#if (!flash || display) GLRenderContext #else Dynamic #end);
	CANVAS (context:CanvasRenderContext);
	DOM (element:#if ((!js && !html5) || display) DOMRenderContext #else Dynamic #end);
	FLASH (stage:#if ((!js && !html5) || display) FlashRenderContext #else Dynamic #end);
	CAIRO (cairo:#if ((!js && !html5) || display) CairoRenderContext #else Dynamic #end);
	CONSOLE (context:#if ((!js && !html5) || display) ConsoleRenderContext #else Dynamic #end);
	CUSTOM (data:Dynamic);

…and I see other renderers so I think that I can use easier ones like CANVAS to draw to the screen, but when I try to create a new canvas renderer with…:

override public function onWindowCreate(win:Window):Void {
        var c:CanvasRenderContext;
        c = new CanvasRenderContext();
        var r:Renderer = new Renderer(win);
        var ctx:RenderContext = RenderContext.CANVAS(c);
        r.context = ctx;
        r.type = RendererType.CANVAS;

r appears to be empty an empty array.

So is it possible to use other renderers? if so which renderers are for each platform… what do each of them mean or do… and how do I make and set new renderers?

If not possible… is there a nifty tutorial for OpenGL with Lime? (because I really don’t understand OpenGL at all :sweat_smile: )

Thanks in advance!


Lime 6.4.0 should allow you to disable OpenGL, and use a software renderer (canvas on HTML5 or Cairo on native platforms) using <window hardware="false" />, or using <define name="canvas" if="html5" /> or <define name="cairo" if="native" />

I’m working on updating the Lime API with the next release, to make this easier. The tentative API looks a little like this:


class Main extends Application {
    public function new () {
        super ();
        createWindow ({
            width: 800,
            width: 600,
            element: js.Browser.document.getElementById ("content"),
            context: {
                type: CANVAS
    public override function render (context:RenderContext):Void {
        var context = context.canvas2D;
        context.fillStyle = "red";
        context.fillRect (0, 0, 100, 100);