Should i compute model and projection matrices on my own and send them to shader?
Yes!
(If you are using C++ GLM as the library to help with that and it works great. For Java with LWJGL read on...)
Quick LWJGL example:
//-- Update matrices
// Reset view and model matrices
viewMatrix = new Matrix4f();
modelMatrix = new Matrix4f();
// Translate camera
Matrix4f.translate(cameraPos, viewMatrix, viewMatrix);
// Scale, translate and rotate model
Matrix4f.scale(modelScale, modelMatrix, modelMatrix);
Matrix4f.translate(modelPos, modelMatrix, modelMatrix);
Matrix4f.rotate(this.degreesToRadians(modelAngle.z), new Vector3f(0, 0, 1), modelMatrix, modelMatrix);
Matrix4f.rotate(this.degreesToRadians(modelAngle.y), new Vector3f(0, 1, 0), modelMatrix, modelMatrix);
Matrix4f.rotate(this.degreesToRadians(modelAngle.x), new Vector3f(1, 0, 0), modelMatrix, modelMatrix);
// Upload matrices to the uniform variables
GL20.glUseProgram(pId);
projectionMatrix.store(matrix44Buffer); matrix44Buffer.flip();
GL20.glUniformMatrix4(projectionMatrixLocation, false, matrix44Buffer);
viewMatrix.store(matrix44Buffer); matrix44Buffer.flip();
GL20.glUniformMatrix4(viewMatrixLocation, false, matrix44Buffer);
modelMatrix.store(matrix44Buffer); matrix44Buffer.flip();
GL20.glUniformMatrix4(modelMatrixLocation, false, matrix44Buffer);
GL20.glUseProgram(0);
The Vertex Shader:
#version 150 core
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 modelMatrix;
in vec4 in_Position;
in vec4 in_Color;
in vec2 in_TextureCoord;
out vec4 pass_Color;
out vec2 pass_TextureCoord;
void main(void) {
gl_Position = in_Position;
// Override gl_Position with our new calculated position
gl_Position = projectionMatrix * viewMatrix * modelMatrix * in_Position;
pass_Color = in_Color;
pass_TextureCoord = in_TextureCoord;
}
Full source - http://lwjgl.org/wiki/index.php?title=The_Quad_with_Projection,_View_and_Model_matrices
Why is self compute of model and projection matrices better?
In short, it is more flexible and allows you to optimize based on your use case. OpenGL 1.x uses fixed function render pipeline, is vendor/driver implementation dependent and cannot be optimized to suit a use case better.
A quick example is, lets say you just want to render a whole lot of quads 2D, you can use a 3x3 matrix for vertex transform saving GPU cycles.