Hi Mark,
embind is a C++11 API. It cannot be used from C, though you could write a
program that is written in C and links with a C++ module that talks to
JavaScript as C.
However, if you're just talking to JavaScript through C, embind wouldn't
get you much. It would be easier in your C to simply write:
extern int FillRect(HDC hDC, CONST RECT* lprc, HBRUSH hbr);
And implement _FillRect in your JavaScript.
The embind alternative would work too. For your edification, here is how
it might look:
// In your C
extern int FillRect(HDC hDC, CONST RECT* lprc, HBRUSH hbr);
// In a C++ module
using namespace emscripten;
int FillRect(HDC hDC, CONST RECT* lprc, HBRUSH hbr) {
val canvas = getCanvasFromDC(hDC);
setCanvasFillStyle(canvas, hbr);
canvas.call<void>("fillRect", lprc->left, lprc->top, lprc->right -
lprc->left, lprc->bottom - lprc->top);
}
embind is plenty fast for real-time chatter between JavaScript and C: we go
through embind for every OpenGL call in our codebase. :)
On Mon, Feb 17, 2014 at 2:25 PM, Mark Hahn <[email protected]> wrote:
> I'm a newbie planning on implementing a subset of GDI in javascript that
> is called from emscripten-converted C (not C++) to draw text on a canvas.
> I'm looking into using embind because I don't think I can avoid
> double-quotes in my javascript (I always code in coffeescript).
>
> Some embind questions ...
>
> 1) Will I have trouble interfacing with embind from C? I see most of the
> embind docs in the wiki relate to C++ classes.
>
> 2) The wiki page mentions that embind is "not as lightweight as JS
> libraries". How large is embind (bytes added to page load)?
>
> 3) I'm going to be calling several javascript functions from C for every
> keystroke in an editor. There can't be more than 50 ms or so delay in the
> browser including the canvas drawing time. Is embind to slow for this?
> Anyone have an idea what the call overhead is in milliseconds?
>
> Can anyone suggest a better way to have C calls draw on a canvas than
> coding the calls myself in javascript? I've looked at SDL and OpenGL and
> both seem like overkill. I was disappointed to find there wasn't already a
> GDI emulation in emscripten.
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.