How to create offscreen Texture and use it on Android with OpenGL ES 2 -
i new in opengl.
how can create offscreen texture, can informations of (e.g. pixelcolor clicking on view texture) ?
i tried many many things illustration fbo, did't work. have no imagination how load bitmap offscreen texture , info of it. frustated :/
edit: took this tutorial example, don't know if fits problem. createframebuffer
public void createframebuffer(gl10 gl) { floatbuffer uvbuffer2; int texture[] = new int[1]; gles20.glgentextures(1, texture, 0); gles20.glbindtexture(gles20.gl_texture0, texture[0]); float uvs2[] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f }; bytebuffer bb = bytebuffer.allocatedirect(uvs2.length * 4); bb.order(byteorder.nativeorder()); uvbuffer2 = bb.asfloatbuffer(); uvbuffer2.put(uvs2); uvbuffer2.position(0); gl.gltexcoordpointer(2, gles20.gl_byte, 0, uvbuffer2); //load image int idtest = mcontext.getresources().getidentifier("drawable/testgroesse", null, mcontext.getpackagename()); bitmap wood = bitmapfactory.decoderesource(mcontext.getresources(), idtest); gles20.gltexparameterf(gles20.gl_texture0, gles20.gl_texture_min_filter, gles20.gl_linear); gles20.gltexparameterf(gles20.gl_texture0, gles20.gl_texture_mag_filter, gles20.gl_linear); glutils.teximage2d(gles20.gl_texture0, 0, wood, 0); gles20.glenable(gles20.gl_texture0); gl.glenableclientstate(gles20.gl_texture0); //color picking background start bytebuffer bytepickedcolor = bytebuffer.allocate(4); bytepickedcolor.order(byteorder.nativeorder()); gles20.glflush(); gles20.glreadpixels(touchxint, touchyint, 1, 1, gles20.gl_rgba, gles20.gl_unsigned_byte, bytepickedcolor); byte b[] = new byte[4]; bytepickedcolor.get(b); string key = "" + b[0] + " " + b[1] + " " + b[2] + " " + b[3]; log.d("color_farbe: ", key); bytepickedcolor.rewind(); //color picking background end }
to oversimplify:
the fbo created buffer contains rgba + 16-bit depth. attaching texture can reuse texture have same rgba info fbo. @ origin buffer still empty, still need clear , draw other render buffer.
so set image/texture on buffer need create texture (with image) , draw textured rectangle on fbo.
it seem not after:
"how can create offscreen texture?" onscreen texture? textures offscreen. "get informations of it"? of what, texture?! there 2 ways of creating texture: first image in case rather lookup texel source image. sec drawing fbo procedure need read pixels (tryglreadpixels). "e.g. pixelcolor clicking on view texture" clicking on what?! can click on view/screen not texture. if 1 time again need sample of rendered view see before need read pixels described before. it looks looking glreadpixels colour values current buffer. if not case please rephrase question , explain goal here.
android opengl-es
No comments:
Post a Comment