I am work my game on android, using OpenGL developing 2D game, running on 320×480 device was work.(no any broken)
Unfortunately issue on my motorola defy (480×854), seems like the adjust UV point object having 1-px diff(up or down 1 px position deviation).
SurfaceChanged return width 320,height 569
AndroidManifest anyDensity is setting false
Below two images have two rectangle, the left one is original image(w=36,h=35), no crop; middle one is clip by uv, draw from px1 and crop only width 34px,height 33px,right one very long rectangle, draw from top to bottom from px0 to px480 width 34px,height 1px, sorry for virtual code but you know what I means.
My previous game is written in SurfaceView, worked on 320×480, 480×800, 480×854 and 1024×768.
The picture look like work, width filled but bottom has biggest empty.
If I insert w=320; h=480; before GLUgluOrtho2D in SurfaceChanged,some object work(which not use crop by UV)

http://i1105.photobucket.com/albums/h355/ch_mac/device_str5.png
The result I would like :

http://i1105.photobucket.com/albums/h355/ch_mac/device_str6.png
My texture drawing method :
public void draw(int from_x,int from_y,int w,int h,int pos_x,int pos_y)
{
bind();
float texW=(float)mPow2Width;
float texH=(float)mPow2Height;
float minU= from_x/texW;
float maxU = (from_x+w)/texW;
float minV= from_y/texH;
float maxV = (from_y+h)/texH;
float verticleBuffer[] = {
x, y,
x+w, y,
x, y+h,
x+w, y+h,
};
float coordBuffer[] = {
minU, minV,
maxU, minV,
minU, maxV,
maxU, maxV,
};
FloatBuffer m_vertexBuffer;
FloatBuffer m_textureBuffer;
ByteBuffer l_byteBuf;
l_byteBuf = ByteBuffer.allocateDirect( verticleBuffer.length * 4 );
l_byteBuf.order( ByteOrder.nativeOrder() );
m_vertexBuffer = l_byteBuf.asFloatBuffer();
m_vertexBuffer.put( verticleBuffer );
m_vertexBuffer.position( 0 );
l_byteBuf = ByteBuffer.allocateDirect( coordBuffer.length * 4 );
l_byteBuf.clear();
l_byteBuf.order( ByteOrder.nativeOrder() );
m_textureBuffer = l_byteBuf.asFloatBuffer();
m_textureBuffer.put( coordBuffer );
m_textureBuffer.position( 0 );
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, m_textureBuffer);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, m_vertexBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,4);
}
SurfaceChanged :
public void onSurfaceChanged(GL10 gl, int w, int h)
{
gl.glViewport(0, 0, w, h);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
float aspect_w=(float)h/(float)w;
float aspect_h=(float)w/(float)h;
//w=320;
//h=480;
GLU.gluOrtho2D(gl, 0, w, h, 0);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
Place the viewport and projection setup in the drawing handler. It’s the only place where they actually make sense (like most other OpenGL operation). Doing those things somewhere else is a bookkeeping nightmare and gains no performance.
EDIT: Another issue:
Are you sure that coordBuffer is right? To me it looks like the last two lines are swappned, i.e. that one made more sense: