using c++ library in

Is it possible to write processing library in c++ and access it in regular sketch . If it is done like that would it speed up the sketch? and are there any processing libraries that does that?



  • yes i do know about open frame works but what i am asking is writing part of the code in c++ (like libraries etc..) not all of it in processing.

  • edited June 2015

    You can try to use Java's JNI. It's a lot of complicated stuff, and I wouldn't know how well it would work with Processing (since I've never tried this), but if you're up for digging around, here's a link that could get you started:

  • edited June 2015
    • As @MenteCode shown us, native calls is the standard way for Java to access code compiled in other programming languages.
    • However, unless it's some code w/ lotsa arrays and very complicated maths, any speed gains would be minimal.
    • Actually, JNI is mostly used for hardware access only, since Java lacks full pointers.
    • Although Java has a "secret" library called Unsafe, which grants us full pointer access. ;)
  • JNI or JNA.
    But for pure algorithm, Java's JIT compiler might perform better than compiled C++, in some cases...
    That said, in general, the bottleneck is in the display itself, which can be solved by using OpenGL, shaders, etc.

Sign In or Register to comment.