Here s GLSL 1.50 code for doing the same thing as gluPerspective. You can easily convert it to your language of choice, and upload it via glUniformMatrix4fv instead.
mat4 CreatePerspectiveMatrix(in float fov, in float aspect,
in float near, in float far)
{
mat4 m = mat4(0.0);
float angle = (fov / 180.0f) * PI;
float f = 1.0f / tan( angle * 0.5f );
/* Note, matrices are accessed like 2D arrays in C.
They are column major, i.e m[y][x] */
m[0][0] = f / aspect;
m[1][1] = f;
m[2][2] = (far + near) / (near - far);
m[2][3] = -1.0f;
m[3][2] = (2.0f * far*near) / (near - far);
return m;
}
Then you do:
mat4 worldMatrix = CreateSomeWorldMatrix();
mat4 clipMatrix = CreatePerspectiveMatrix(90.0, 4.0/3.0, 1.0, 128.0);
gl_Position = worldMatrix * clipMatrix * myvertex;
some_varying1 = worldMatrix * myvertex;
some_varying2 = worldMatrix * vec4(mynormal.xyz, 0.0);