I used a ndk library to decode the frames and update the ShortBuffer
with RGB565 format.
I allocate the buffer in the activity like below.
ShortBuffer m_byteCanvas = ShortBuffer.allocate(m_width * m_height);
.......
And I use GLSurfaceView and set the renderer for it.
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_LOG_GL_CALLS);
mGLSurfaceView.setRenderer(new GRenderer());
setContentView(mGLSurfaceView);
In the GRenderer class, I just need to update the ShortBuffer to
screen.
.....
gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, m_width, m_height,
0, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5, m_byteCanvas);
l_gl.glTexParameteriv(GL10.GL_TEXTURE_2D,
GL11Ext.GL_TEXTURE_CROP_RECT_OES,
new int[] {0, 0, 480, 320}, 0);
public void onDrawFrame(GL10 gl) {
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, m_width, m_height,
0, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5, m_byteCanvas);
((GL11Ext)gl).glDrawTexiOES(0, 0, 0, 480, 320);
}
This works fine on the emulator (1.5 and 1.6), but when I tested it on
my G2 and G1, it gave me glError 1281 on glTexImage2D. If anybody can
help with this?
PS:
I tried Canvas and the performance is not good enough, it takes more
than 30ms to draw a frame.(480x320).
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en