int array to opengl texture in android -
i'm trying add efects camera in android, found things on internet got stuck when creating texture,
i use funcion decodeyuv420sp() returns me int[width*height] rgb array hex values each array position,
now, want create opengl texture of array dont know how, can convert each hex value r_g_b separated , put opengl doesn't work this:
mnewtexture = new int[width*height*4] for(int i=0; i<mrgb.length; i=i+4){ mnewtexture[i] = getr(mrgb[i]) ; //r mnewtexture[i+1] = getg(mrgb[i]) ; //g mnewtexture[i+2] = getb(mrgb[i]) ; //b mnewtexture[i+3] = geta(mrgb[i]); //a }
to convert hex value rgba (from 0 255)
and convert opengl texture:
gl.glbindtexture(gl10.gl_texture_2d, tex); gl.glteximage2d(gl10.gl_texture_2d, 0, gl10.gl_rgba, 1024, 512, 0, gl10.gl_rgba, gl10.gl_float, floatbuffer.wrap(mnewtexture)); gl.gltexparameterf(gl10.gl_texture_2d, gl10.gl_texture_min_filter, gl10.gl_linear);
however worng, cause doesn't work...
any idea?
why try wrap int array floatbuffer? of conversions unnecessary.
just take original texture, wrap in bytebuffer, , pass glteximage type gl_unsigned_byte. there's no need create new array have.
gl.glteximage2d(gl10.gl_texture_2d, 0, gl10.gl_rgba, 1024, 512, 0, gl10.gl_rgba, gl10.gl_unsigned_byte, bytebuffer.wrap(mrgb));
Comments
Post a Comment