The below matrix set up works until I hit the projection matrix. Until that point the square shows up flat - nearly in the middle of the screen. After adding the proj_mat, depending on the calcs I use I get differing results. Normally, I can’t see the graphic - some of the calculations I tried allow me to see the square if I roll around an angle, but it’s never where I expect it to be. I’ve tried multiple solutions
http://www.songho.ca/opengl/gl_projectionmatrix.html
http://www.geeks3d.com/20090729/howto-perspective-projection-matrix-in-opengl/
http://ogldev.atspace.co.uk/www/tutorial12/tutorial12.html
glViewport(0.0f, 0.0f, width, height);
glEnable(GL_DEPTH_TEST);
.....
GLfloat x_roll_floaters[4][4] = {
{1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, cos((x_roll_angle*3.141592654)/180), sin((x_roll_angle*3.141592654)/180), 0.0f},
{0.0f, -sin((x_roll_angle*3.141592654)/180), cos((x_roll_angle*3.141592654)/180), 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
};
GLfloat y_roll_floaters[4][4] = {
{cos((y_roll_angle*3.141592654)/180), 0.0f, -sin((y_roll_angle*3.141592654)/180), 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{sin((y_roll_angle*3.141592654)/180), 0.0f, cos((y_roll_angle*3.141592654)/180), 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
};
GLfloat z_roll_floaters[4][4] = {
{cos((z_roll_angle*3.141592654)/180), sin((z_roll_angle*3.141592654)/180), 0.0f, 0.0f},
{-sin((z_roll_angle*3.141592654)/180), cos((z_roll_angle*3.141592654)/180), 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
};
GLfloat view_floaters[4][4] = {
/*right up look*/
{1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
};
GLfloat proj_floaters[4][4] = {
{0.138f/1.777f, 0.0f, 0.0f, 0.0f},
{0.0f, 0.222f, 0.0f, 0.0f},
{0.0f, 0.0f, -1.0f, -0.2f},
{0.0f, 0.0f, -1.0f, 0.0f}
};
vertex shader
mat4 model = z_roll * y_roll * x_roll;/
gl_Position = proj_mat * view_mat * model * vec4(position, 1.0f);/
Graphic
0.2f, 0.2f, -1.0f,
0.2f, 0.4f, -1.0f,
-0.2f, 0.4f, -1.0f,
-0.2f, 0.2f, -1.0f
Thanks.