I'm working with Android and OpenGL ES 2.0 and I am having an issue that I can't really formulate into a solid question. In the image, http://i.imgur.com/XuCHF.png, I basically have a shape to represent a ship in the middle and when it's moved to the side it gets stretched toward the vanishing point. What I am wanting to accomplish is to have the ship maintain most of its shape when it is moved. I believe it may be due to my matrices but every resource I've looked seems to use the same method.
//Setting up the projection matrix
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 1000.0f;
Matrix.frustumM(projection_matrix, 0, left, right, bottom, top, near, far);
//Setting the view matrix
Matrix.setLookAtM(view_matrix, 0, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f);
//Setting the model matrix
Matrix.setIdentityM(model_matrix, 0);
Matrix.translateM(model_matrix, 0, 2f, 0f, 0f);
//Setting the model-view-projection matrix
Matrix.multiplyMM(mvp_matrix, 0, view_matrix, 0, model_matrix, 0);
Matrix.multiplyMM(mvp_matrix, 0, GL.projection_matrix, 0, mvp_matrix, 0);
GLES20.glUniformMatrix4fv(mvp_matrix_location, 1, false, mvp_matrix, 0);
The shaders are very basic as well:
private final static String vertex_shader =
"uniform mat4 u_mvp_matrix;"
+ "attribute vec4 a_position;"
+ "void main()"
+ "{"
+ " gl_Position = u_mvp_matrix * a_position;"
+ "}";
private final static String fragment_shader =
"precision mediump float;"
+ "void main()"
+ "{"
+ " gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);"
+ "}";
Any thoughts/insight is greatly appreciated.
Thanks.