Skip to content

Instantly share code, notes, and snippets.

@RblSb

RblSb/Main.hx Secret

Created December 2, 2017 14:48
Show Gist options
  • Save RblSb/72b009f819575212a503ee9c976ba7f4 to your computer and use it in GitHub Desktop.
Save RblSb/72b009f819575212a503ee9c976ba7f4 to your computer and use it in GitHub Desktop.
createRenderTarget android bug
package;
import kha.Framebuffer;
import kha.graphics2.Graphics;
import kha.Assets;
import kha.System;
import kha.Image;
class Main {
var actionBtn:Image;
var minusBtn:Image;
var size = 100;
public static function main():Void {
System.init({title: "Empty", width: 800, height: 600}, function() {
Assets.loadEverything(function() new Main());
});
}
public function new():Void {
initImages();
System.notifyOnRender(onRender);
}
inline function initImages():Void {
actionBtn = Image.createRenderTarget(size, size);
var g = actionBtn.g2;
g.begin(true, 0x0);
g.color = 0xFF000000;
g.fillRect(10, 10, 50, 10);
g.end();
minusBtn = Image.createRenderTarget(size, size);
var g = minusBtn.g2;
g.begin(true, 0x0);
g.color = 0xFF000000;
g.fillRect(10, 10, 10, 50);
g.end();
//uncomment to fix black rect instead of minusBtn
//var fix = Image.createRenderTarget(1, 1);
}
function onRender(frame:Framebuffer):Void {
var g = frame.g2;
g.begin(true, 0xFFFFFFFF);
g.color = 0xFFFFFFFF;
g.drawImage(actionBtn, 0, 0);
g.drawImage(minusBtn, size, 0);
g.end();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment