android - Trying to set a texture from Java plugin in Unity 4.6 -


what i'm trying do:

  • pull image sd-card on phone using java plugin.
  • unity passes texture id plugin.
  • plugin uses opengl assign image texture in unity through id.
  • will (eventually) used play video clip phone in unity, now, it's trying change texture outside of unity.

my issue:

when call method in plugin, passing texture.getnativetextureid() it, texture not change. i'm using simple black 50x50 texture testing, , original texture flat white.

i'm worried i've missed significant, first time working gl calls in java. of answers similar problems involve using native c++ instead of java, can't find concrete answer saying c++ must used. i'd best avoid writing set of plugins , plugin handlers c++, if it's efficient/only way working, i'll i'm not unfamiliar opengl , c++

code:

the plugin method called onprerender() in script attached main camera:

if (grabtex) {     int texptr = m_videotex.getnativetextureid();     debug.log( "texptr = " + texptr );     m_jvinterface.settex( texptr ); } 

m_videotex basic texture2d( 50, 50 ) pixels set white, attached diffuse shader on quad in scene.

the java plugin code follows:

public void settexture(context cont, int _texpointer) {     if (_texpointer != 0) {         final bitmapfactory.options options = new bitmapfactory.options();         options.inscaled = false;         options.injustdecodebounds = false;         final bitmap bitmap = bitmapfactory.decodefile("/storage/emulated/0/pictures/black.jpg", options);          gles20.glbindtexture(gles20.gl_texture_2d, _texpointer);          glutils.teximage2d(gles20.gl_texture_2d, 0, bitmap, 0);          log.i("videohandler", "recieved id: " + _texpointer);          bitmap.recycle();     } } 

this problem opengl context. easiest way send texture raw bytes unity , upload texture inside unity.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -