vanthach / replicaisland

Automatically exported from code.google.com/p/replicaisland
0 stars 0 forks source link

Replicaisland show no wanda on my platform which does not support "draw_texture" gl extension. #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the game, can't see cartoon people wanda.
2.
3.

What is the expected output? What do you see instead?
Should see the cartoon people.

What version of the product are you using? On what operating system?
The opengles on my platform doesn't support "draw_texture" extention.
So glDrawTexfOES will show nothing in DrawableBitmap.java.

As in GameRender.java, we have dected whether "draw_texture" is supported, we 
should use other method to draw the texture in DrawableBitmap.java if this 
extenstion is not supported by the hardware.

Please provide any additional information below.
I try to use glDrawArray for the texture, but still show nothing, may need your 
help, the code is like below in DrawableBitmap.java:
                /*((GL11Ext) gl).glDrawTexfOES(snappedX * scaleX, snappedY * scaleY, 
                        getPriority(), width * scaleX, height * scaleY);*/
                // test use glDrawElements
                FloatBuffer vertexBuffer = ByteBuffer.allocateDirect(4 * 4 * 3).order(ByteOrder.nativeOrder()).asFloatBuffer();
                FloatBuffer texBuffer = ByteBuffer.allocateDirect(4 * 4 * 3).order(ByteOrder.nativeOrder()).asFloatBuffer();
                float ver_x = snappedX * scaleX;
                float ver_y = snappedY * scaleY;
                float ver_z = getPriority();
                float w = width * scaleX;
                float h = height * scaleY;
                vertexBuffer.put(0 * 3, ver_x);
                vertexBuffer.put(0 * 3 + 1, ver_y);
                vertexBuffer.put(0 * 3 + 2, ver_z);
                vertexBuffer.put(1 * 3, ver_x);
                vertexBuffer.put(1 * 3 + 1, ver_y + h);
                vertexBuffer.put(1 * 3 + 2, ver_z);
                vertexBuffer.put(2 * 3, ver_x + w);
                vertexBuffer.put(2 * 3 + 1, ver_y + h);
                vertexBuffer.put(2 * 3 + 2, ver_z);
                vertexBuffer.put(3 * 3, ver_x + w);
                vertexBuffer.put(3 * 3 + 1, ver_y);
                vertexBuffer.put(3 * 3 + 2, ver_z);

                // mCrop[0]-[3]:u,v,w,h
                texBuffer.put(0 * 2, mCrop[0] / mTexture.width );
                texBuffer.put(0 * 2 + 1, mCrop[1] / mTexture.height);
                texBuffer.put(1 * 2, mCrop[0] / mTexture.width);
                texBuffer.put(1 * 2 + 1, (mCrop[1] + mCrop[3]) / mTexture.height);
                texBuffer.put(2 * 2, (mCrop[0] + mCrop[2]) / mTexture.width);
                texBuffer.put(2 * 2 + 1, (mCrop[1] + mCrop[3]) / mTexture.height);
                texBuffer.put(3 * 2, (mCrop[0] + mCrop[2]) / mTexture.width);
                texBuffer.put(3 * 2 + 1, mCrop[1] / mTexture.height);

                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
                int err = gl.glGetError();
                if (err != GL10.GL_NO_ERROR) {
                    Log.e("vertexpointer", GLU.gluErrorString(err));
                }
                gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texBuffer);
                err = gl.glGetError();
                if (err != GL10.GL_NO_ERROR) {
                    Log.e("vertexpointer", GLU.gluErrorString(err));
                }
                gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4);
                err = gl.glGetError();
                if (err != GL10.GL_NO_ERROR) {
                    Log.e("vertexpointer", GLU.gluErrorString(err));
                }

Original issue reported on code.google.com by yangjin0...@gmail.com on 9 Aug 2011 at 3:45

GoogleCodeExporter commented 9 years ago
Also, in beginDrawing, I added 
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
in endDrawing, I added gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

Original comment by yangjin0...@gmail.com on 9 Aug 2011 at 3:48