Oops!Sorry my bad.Your solution works.Yeah,that was it.I was passing params as array.Thanks a lot for your patience.
On Sat, Mar 8, 2014 at 12:16 AM, Michael IV <explomas...@gmail.com> wrote: > Btw,I also tried just this : > > vec2 glm_add(){ > return vec2(1,2); > } > > At the JavaScript end still nothing appears. > > I suggest you to try it yourself.GLM include is a matter of seconds :) > > > On Sat, Mar 8, 2014 at 12:11 AM, Chad Austin <c...@imvu.com> wrote: > >> Ah, got it. The issue here is that you're using a mix of arrays and >> objects. >> >> value_array is for mapping your type into JavaScript arrays. That is, >> [x, y]. >> value_object is for mapping your type into JavaScript objects. That is, >> {x: x, y: y} >> >> What happens if you write: >> >> var vec = Module.glm_add({x:1,y:2},{x:2,y:3}); >> document.write(vec.x + "/" + vec.y); >> >> >> On Fri, Mar 7, 2014 at 2:09 PM, Michael IV <explomas...@gmail.com> wrote: >> >>> Ok,that is very simple.You just need to include glm lib .Then I am >>> trying to do this: >>> >>> vec2 glm_add(const vec2& a ,const vec2& b){ >>> >>> return a + b; >>> } >>> >>> EMSCRIPTEN_BINDINGS(my_module) { >>> >>> value_object<vec2>("vec2") >>> .field("x", &vec2::x) >>> .field("y", &vec2::y) >>> ; >>> function("glm_add", &glm_add); >>> } >>> >>> >>> On the JavaScript side I would expect to operate on that method like >>> that: >>> >>> var vec = Module.glm_add([1,2],[2,3]); >>> >>> document.write(vec.x + "/" + vec.y); >>> >>> >>> >>> >>> On Fri, Mar 7, 2014 at 11:47 PM, Chad Austin <c...@imvu.com> wrote: >>> >>>> Can you reduce the problem code into a minimal example with >>>> reproduction steps? I can't really help without seeing what's actually >>>> going wrong. >>>> >>>> >>>> >>>> On Fri, Mar 7, 2014 at 1:18 PM, Michael IV <explomas...@gmail.com>wrote: >>>> >>>>> Well,it is heavily templated so there is not a single structure >>>>> definitiion there for vec2 type, but I know it is resolved to a simple >>>>> array by compiler. >>>>> >>>>> >>>>> On Fri, Mar 7, 2014 at 8:57 PM, Chad Austin <c...@imvu.com> wrote: >>>>> >>>>>> Can you show the definition of vec2 in the C++? It's hard to tell >>>>>> what the problem might be there. >>>>>> >>>>>> Sent from my iPhone >>>>>> >>>>>> On Mar 7, 2014, at 5:09 AM, Michael IV <explomas...@gmail.com> wrote: >>>>>> >>>>>> Anyone? >>>>>> >>>>>> >>>>>> On Fri, Mar 7, 2014 at 1:19 PM, Michael IV <explomas...@gmail.com>wrote: >>>>>> >>>>>>> my guess : it is because vec2 template preprocessed to C array. >>>>>>> >>>>>>> >>>>>>> On Friday, March 7, 2014 1:15:44 PM UTC+2, Michael IV wrote: >>>>>>>> >>>>>>>> I have a template class vec2 (GLM math lib) .To expose it to >>>>>>>> JavaScript I first tried value_array.Works great. >>>>>>>> But then I wanted to have more object oriented interface so that at >>>>>>>> JavaScript side we can do: >>>>>>>> >>>>>>>> var vector = Module.glm_add(vec1,vec2); >>>>>>>> >>>>>>>> vector.x; >>>>>>>> vector.y; >>>>>>>> .... >>>>>>>> So I tried value_object which compiles ok but in JS I am getting >>>>>>>> blank screen. >>>>>>>> >>>>>>>> EMSCRIPTEN_BINDINGS(my_module) { >>>>>>>> /* >>>>>>>> //this works >>>>>>>> value_array<vec2>("vec2") >>>>>>>> .element(&vec2::x) >>>>>>>> .element(&vec2::y) >>>>>>>> ; >>>>>>>> */ >>>>>>>> //this doesn't >>>>>>>> value_object<vec2>("vec2") >>>>>>>> .field("x", &vec2::x) >>>>>>>> .field("y", &vec2::y) >>>>>>>> ; >>>>>>>> function("glm_add", &glm_add); >>>>>>>> } >>>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to a topic in >>>>>>> the Google Groups "emscripten-discuss" group. >>>>>>> To unsubscribe from this topic, visit >>>>>>> https://groups.google.com/d/topic/emscripten-discuss/B4lujXZEZWU/unsubscribe >>>>>>> . >>>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>>> emscripten-discuss+unsubscr...@googlegroups.com. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Michael Ivanov >>>>>> Independent Pixel Commander >>>>>> onlygraphix.com >>>>>> Tel:+972 54 4962254 >>>>>> >>>>>> -- >>>>>> 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 emscripten-discuss+unsubscr...@googlegroups.com. >>>>>> >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to a topic in >>>>>> the Google Groups "emscripten-discuss" group. >>>>>> To unsubscribe from this topic, visit >>>>>> https://groups.google.com/d/topic/emscripten-discuss/B4lujXZEZWU/unsubscribe >>>>>> . >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> emscripten-discuss+unsubscr...@googlegroups.com. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Michael Ivanov >>>>> Independent Pixel Commander >>>>> onlygraphix.com >>>>> Tel:+972 54 4962254 >>>>> >>>>> -- >>>>> 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 emscripten-discuss+unsubscr...@googlegroups.com. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> 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 a topic in the >>>> Google Groups "emscripten-discuss" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/emscripten-discuss/B4lujXZEZWU/unsubscribe >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> emscripten-discuss+unsubscr...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Michael Ivanov >>> Independent Pixel Commander >>> onlygraphix.com >>> Tel:+972 54 4962254 >>> >>> -- >>> 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 emscripten-discuss+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> 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 a topic in the >> Google Groups "emscripten-discuss" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/emscripten-discuss/B4lujXZEZWU/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> emscripten-discuss+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Michael Ivanov > Independent Pixel Commander > onlygraphix.com > Tel:+972 54 4962254 > > -- Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254 -- 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 emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.