-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update demo for new Lime #5
Comments
I try to update... import hxnanovg.Nvg;
import lime.app.Application;
import lime.graphics.opengl.GL;
import lime.graphics.RenderContext;
import lime.graphics.GLRenderContext;
using cpp.NativeString;
@:buildXml("&<include name='${haxelib:hx-nanovg}/Build.xml'/>")
class Main extends Application
{
private var ctx:GLRenderContext;
var vg:cpp.Pointer<NvgContext>;
var linearGradient:NvgPaint;
var font:Int;
public function new()
{
super();
}
public override function init(context:RenderContext):Void
{
updateSavedContext(context);
vg = Nvg.createGL(NvgMode.ANTIALIAS);
font = Nvg.createFont(vg, "arial".c_str(), "assets/arial.ttf".c_str());
linearGradient = Nvg.linearGradient(vg, 0, 0, 500, 500, Nvg.rgba(255, 192, 0, 255), Nvg.rgba(0, 0, 0, 255));
}
public override function render(context:RenderContext):Void
{
updateSavedContext(context);
GL.viewport(0, 0, config.width, config.height);
GL.clearColor(0.3, 0.3, 0.3, 1.0);
GL.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT | GL.STENCIL_BUFFER_BIT);
Nvg.beginFrame(vg, 800, 600, 1.0);
Nvg.rect(vg, 100, 100, 500, 300);
Nvg.circle(vg, 120, 120, 250);
Nvg.pathWinding(vg, NvgSolidity.HOLE); // Mark circle as a hole.
Nvg.fillPaint(vg, linearGradient);
Nvg.fill(vg);
Nvg.fontFaceId(vg, font);
Nvg.fillColor(vg, Nvg.rgba(255, 0, 0, 255));
Nvg.text(vg, 50, 50, "This is some text".c_str(), untyped __cpp__("NULL"));
Nvg.fontSize(vg, 100.0);
Nvg.fontFaceId(vg, font);
Nvg.fillColor(vg, Nvg.rgba(255, 255, 255, 64));
Nvg.textAlign(vg, NvgAlign.ALIGN_LEFT | NvgAlign.ALIGN_MIDDLE);
Nvg.text(vg, 100, 100, "Some other text!".c_str(), untyped __cpp__("NULL"));
Nvg.endFrame(vg);
}
function updateSavedContext(context:RenderContext):Void
{
switch(context)
{
case RenderContext.OPENGL(gl): ctx = gl;
default: null;
}
}
} And got the new errors:
|
Hi there, concerning the second error: Given that the Haxe 3.2 release has still not happened yet, you are likely to see bugs come up as hxcpp and the haxe-compiler are still being worked on when grabbing nightlies from git. Personally Im using nightlies from sept. 10th, I think. What line in your hx-file does the cpp-error correspond to? Oh, looks like the latest lime doesnt work with the demo anymore. Thats the reason for the first error. |
From the looks of it, the second error might come from the Nvg.text-calls. you might want to remove them and see if it compiles and shows the geometry when you render |
Wow! Looks good! Thank you. What I did: as you say I comment all about text: /* in init method*/
//font = Nvg.createFont(vg, "arial".c_str(), "assets/arial.ttf".c_str());
/* in render method */
//Nvg.fontFaceId(vg, font);
//Nvg.fillColor(vg, Nvg.rgba(255, 0, 0, 255));
//Nvg.text(vg, 50, 50, "This is some text".c_str(), untyped __cpp__("NULL"));
//Nvg.fontSize(vg, 100.0);
//Nvg.fontFaceId(vg, font);
//Nvg.fillColor(vg, Nvg.rgba(255, 255, 255, 64));
//Nvg.textAlign(vg, NvgAlign.ALIGN_LEFT | NvgAlign.ALIGN_MIDDLE);
//Nvg.text(vg, 100, 100, "Some other text!".c_str(), untyped __cpp__("NULL")); And it work fine on OS X now. But we need to create new issue about text-render. |
I got the following error on the demo:
I use actual dev-version hxcpp (from git) and nightly Haxe (2014-10-09T22:31:58)
The text was updated successfully, but these errors were encountered: