You're presenting a bit of a broad problem. So this is likely going to take a bit of going back and forth while we narrow down what's going on.
You mentioned porting a matrix library, but you also said nothing appears on the screen. Does this mean
a.) It doesn't matter what matrix values are used (Id etc...) nothing renders.
b.) Nothing appears on screen using your matrices, but you've been able to render things with this engine in the past.Scenario A
I think the best place to start debugging here is from the Shader level. If you're familiar with Geometry shaders, you can create one to output a simple triangle and then just tell your fragment shader to output a single color (instead of the texture stuff you're trying to do).
On that note, I would just tell your fragment shader to output a single color until you get this stuff ironed out.Vertex Attribute Array Pointer
More often than not, when I've encountered something not rendering it was actually due to the Vertex array. Either I was passing in the wrong values, or the more common case where I was setting the vertex array attributes incorrectly.
If you're able to implement the Geometry shader this would help you determine if you have a Vertex array issue. If you can draw something with the shader, then you likely have a Vertex array issue.
Gemotry shaders are somewhat easy to work with and should be something like:
out vec3 vertex;
vertex = vec3(-0.5, 0, 0);
vertex = vec3(0, 0.5, 0);
vertex = vec3(0, 0, 0);
Keep your culling in mind with the order. Or just err on the safe side for now and disable any culling you may be doing.
If none of the above has gotten you to a point where you see at least -something- on the screen, then you've likely got a problem with initialization or calling the draw function incorrectly.
But I'll wait on your findings before trying to drill down into that.Scenario B
If you -have- in the past been able to render a "Hello World Triangle", then I just wrote a bunch of shit for no reason. But that's ok, it's all penance to please the coder gods.Perspective Projection
It also means I would wager a soul (not mine, of course) that you've got a perspective projection matrix problem.
You can check this by making the perspective matrix an Identity matrix and the same for the other matrices you pass in.
If that works, then here's a general overview about investigating the perspective projection matrix.
A lot of perspective matrix implementation looks similar to the following
R 0 0 0
0 R 0 0
0 0 A B
0 0 -1 0
A = (F+N)/(N-F)
B = (2FN)/(N-F)
R is the frustum
F is the far plane
N is the near plane
Unless you're doing something crazy, you can ignore the upper left portion of this matrix. All it does is compress the window by width or height.
The easiest place to make a mistake is the lower right quadrant, since this controls the Z. It's easily possible to project an object behind your view. You can try flipping the -1 to positive.Transpose
The classic transposed matrix, where your rows are your columns and columns are your rows. Though most of the time this just results in objects looking behaving strangely vs not appearing.
You can easily play with this by simply flipping the transpose boolean value from false to true in the function which sets the uniform matrices for the shaders.
glUniformMatrix4(int location, boolean transpose
, java.nio.FloatBuffer matrices)