Skip to content
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

Open
boozook opened this issue Nov 5, 2014 · 4 comments
Open

Update demo for new Lime #5

boozook opened this issue Nov 5, 2014 · 4 comments

Comments

@boozook
Copy link

boozook commented Nov 5, 2014

I got the following error on the demo:

src/Demo.hx:6: characters 7-16 : Class not found : lime.Lime

I use actual dev-version hxcpp (from git) and nightly Haxe (2014-10-09T22:31:58)

@boozook
Copy link
Author

boozook commented Nov 5, 2014

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:

./src/Main.cpp:72:69: error: no matching function for call to 'fromPointer'
                ::cpp::Pointer< ::cpp::Char > _g6 = ::cpp::Pointer< ::cpp::Char >(::cpp::Pointer_obj::fromPointer(_g5));                HX_STACK_VAR(_g6,"_g6");
                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Haxelib/hxcpp/git/include/cpp/Pointer.h:165:27: note: candidate template ignored: could not match 'T *' against 'Dynamic'
        inline static Pointer<T> fromPointer(T *value)  { return Pointer<T>(value); }
                                 ^
/Haxelib/hxcpp/git/include/cpp/Pointer.h:167:27: note: candidate template ignored: could not match 'const T *' against 'Dynamic'
        inline static Pointer<T> fromPointer(const T *value)  { return Pointer<T>(value); }
                                 ^
2 errors generated.

@dazKind
Copy link
Owner

dazKind commented Nov 5, 2014

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.

@dazKind
Copy link
Owner

dazKind commented Nov 5, 2014

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

@boozook
Copy link
Author

boozook commented Nov 5, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants