Search code examples
javaopenglmatrixglsllwjgl

OpenGL application, The Black Screen of Faliure


Without the perspective projection and view matrix my scene is fine: good rendering

If i use the camera the result is weird: not so good rendering

When i'm using the projection combined with view/camera matrix i always(even if move in every direction) get an empty screen or as i like to call it: the "Black Screen of Faliure".

Here's the matrices i pass to the VS:

Model Mat4: (model rotation on x-axis)

1.0 0.0 0.0 0.0 
0.0 0.4888726 0.8723553 0.0 
0.0 -0.8723553 0.4888726 0.0 
0.0 0.0 0.0 1.0 

View Mat4: (Camera slightly moved and rotated on y-axis)

0.94107544 0.0 0.33819667 -0.53266037 
0.0 1.0 0.0 0.0 
-0.33819667 0.0 0.94107544 2.4321942 
0.0 0.0 0.0 1.0 

Projection Mat4:

1.299038 0.0 0.0 0.0 
0.0 1.7320509 0.0 0.0 
0.0 0.0 1.002002 -2.002002 
0.0 0.0 1.0 0.0 

perspective proj calculation:

thf=tan(torad(60)/2); ar=800/600; zn=1; zf=1000;

1/(thf*ar) 0 0 0
0 1/thf 0 0 
0 0 (-zn-zf)/(zn-zf) 2*zn*zf/(zn-zf) 
0 0 1 0
  

My Vertex Shader:

#version 330

attribute layout(location = 0) vec3 Position;
attribute layout(location = 1) vec3 TexCoord;
attribute layout(location = 2) vec3 Normal;
out vec3 TexCoords;
uniform mat4 Model;
uniform mat4 View;
uniform mat4 Projection;

void main(){
        
    gl_Position = Projection * View * Model * vec4(Position, 1);
    TexCoords=TexCoord;     
}

Solution

  • Turns out that there sometimes a boolean can screw you badly.

     glUniformMatrix4(UniformHandle, true, ubo); // true for row-major order