Ah, that explains a lot. I'm happy to see that it is so easy to use from C. With Alon's help I was able to make libraries work and they are easy to use.
Maybe when my project is done I'll contribute a wiki entry that focuses on usage from C and how easy it is. As the docs are now they cover so much that it is a bit scary for the newbie. Emscripten is *too* flexible. :-) I suspect many coders will be converting legacy C code to the browser as I am. My client's code is 23 years old and they don't want to change a single line. Long story. > And implement _FillRect in your JavaScript. Yes, I'm planning on coding a sizable part of the GDI API in JS. My co-workers aren't sure my head is screwed on straight. I wore google out trying to find an existing solution to interface C/C++ GDI calls to canvas in the browser. If anyone knows any existing solution I missed I would be eternally grateful. > // In a C++ module <...snip...> val canvas = getCanvasFromDC(hDC); I want to verify that you also mean I would implement the C++ call getCanvasFromDC in Javascript. You aren't referring to an existing implementation, are you? Thanks for the info. It helps a lot. On Thu, Feb 20, 2014 at 12:28 AM, Chad Austin <[email protected]> wrote: > 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. > -- 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.
