I am in the process of trying to make a GLSL ES based camera system but have run in to a little snag (coming from a basic HLSL background).
This is what I have so far. It is incomplete as I haven't accounted for View and Projection yet (that will come when I get past this hiccup).
The problem that I am having is that the return type of gl_Position (as required in GameMaker) is a type of vec4 but the matrices I am using are of mat4 type. Thus, resulting in a compilation error.
attribute vec3 in_Position; // Vertex position in its own local space
uniform float xx;
uniform float yy;
uniform float zz;
void main()
{
mat4 identity;
mat4 world;
mat4 view;
mat4 projection;
identity = mat4(
1.0, 0.0, 0.0, 0.0, // first column (not row!)
0.0, 1.0, 0.0, 0.0, // second column
0.0, 0.0, 1.0, 0.0, // third column
0.0, 0.0, 0.0, 1.0 // third column
);
// Translation matrix (world matrix)
world = mat4(
1.0, 0.0, 0.0, in_Position.x + xx,
0.0, 1.0, 0.0, in_Position.y + yy,
0.0, 0.0, 1.0, in_Position.z + zz,
0.0, 0.0, 0.0, 1.0
);
gl_Position = identity * world; // This results in an error of vec4 not being compatible with mat4 (which is fair enough)
//gl_Position = vec4(identity * world); // This results in a hang eventually resulting in a generic error - with no other explanation
}
Could you please advise if I am on the right track?
And any help is always greatly appreciated.
Thanks in advance