glmxLoadPerspective 関数を利用しようとすると、何も表示されません。ただし、私の glmxLoadOrtho 関数は正常に表示されます。私の計算は間違っていますか?以下の関連コード (無関係なビットは切り捨て):
(APP_WIDTH = 1000、APP_HEIGHT = 1000)
使用法:
glmxMatrix ortho;
glmxGenMatrix(&ortho, GLMX_4X4); //This simply loads the identity matrix.
glmxLoadPerspective(&ortho, 45.0f, APP_WIDTH / APP_HEIGHT, 1.0f, 10.0f); //Implementation below.
glmxMatrix modelview;
glmxGenMatrix(&modelview, GLMX_4X4); //Same as above.
const GLfloat verts[] = {
//verts
100.0f, 100.0f, -3.0f, 1.0f,
200.0f, 200.0f, -3.0f, 1.0f,
100.0f, 200.0f, -3.0f, 1.0f,
200.0f, 100.0f, -3.0f, 1.0f,
//colors
1.0f, 0.3f, 0.4f, 0.5f,
0.5f, 0.1f, 0.4f, 0.3f,
0.0f, 1.0f, 0.5f, 0.6f,
0.0f, 1.0f, 0.5f, 0.6f,
};
glmxMultMatrix(&ortho, &modelview);
錐台機能:
glmxvoid glmxLoadFrustrum(glmxMatrix* matrix, glmxfloat left, glmxfloat right, glmxfloat bottom,
glmxfloat top, glmxfloat near, glmxfloat far){
if(matrix -> mx_type != GLMX_4X4){GLMX_ERROR = GLMX_NOT_4X4; return;}
matrix -> mx_data[0] = (2.0f * near) / (right - left);
matrix -> mx_data[1] = 0.0f;
matrix -> mx_data[2] = 0.0f;
matrix -> mx_data[3] = 0.0f;
matrix -> mx_data[4] = 0.0f;
matrix -> mx_data[5] = (2.0f * near) / (top - bottom);
matrix -> mx_data[6] = 0.0f;
matrix -> mx_data[7] = 0.0f;
matrix -> mx_data[8] = (right + left) / (right - left);
matrix -> mx_data[9] = (top + bottom) / (top - bottom);
matrix -> mx_data[10] = (-far - near) / (far - near);
matrix -> mx_data[11] = -1.0f;
matrix -> mx_data[12] = 0.0f;
matrix -> mx_data[13] = 0.0f;
matrix -> mx_data[14] = -(2.0f * near) * far / (far - near);
matrix -> mx_data[15] = 0.0f;
}
透視機能:
glmxvoid glmxLoadPerspective(glmxMatrix* matrix, glmxfloat fovy, glmxfloat aspect, glmxfloat near,
glmxfloat far){
glmxfloat ymax = near * tanf(fovy * GLMX_PI / 360.0f), xmax = ymax * aspect;
glmxLoadFrustrum(matrix, -xmax, xmax, -ymax, ymax, near, far);
}