那么问题是类同我以前的一个约glOrtho变种
glOrtho OpenGL es 2.0 variant how fix blank screen?
Opengl ES 2.0中的glFrustrum变体 - 如何修复空白屏幕?
三角下面是邻投影完美的画(而不是在矩形视三个等边三角形,而不投影它压扁三角形)
GLfloat triangle_vertices[] =
{
-0.5, -0.25, 0.0,
0.5, -0.25, 0.0,
0.0, 0.559016994, 0.0
};
正交矩阵代码:
typedef float[16] matrix;
void ortho_matrix(float right, float left, float bottom, float top, float near, float far, matrix result)
{
// First Column
result[0] = 2.0/(right - left);
result[1] = 0.0;
result[2] = 0.0;
result[3] = 0.0;
// Second Column
result[4] = 0.0;
result[5] = 2.0/(top - bottom);
result[6] = 0.0;
result[7] = 0.0;
// Third Column
result[8] = 0.0;
result[9] = 0.0;
result[10] = -2.0/(far - near);
result[11] = 0.0;
// Fourth Column
result[12] = -(right + left)/(right - left);
result[13] = -(top + bottom)/(top - bottom);
result[14] = -(far + near)/(far - near);
result[15] = 1;
}
设置我的投影矩阵T ø邻位,其中ASPECT_RATIO = SCREEN_WIDTH/screen_heigth
ortho_matrix(-aspect_ratio, aspect_ratio, -1.0, 1.0, -1.0, 1.0, PROJECTION_MATRIX);
任务是邻投影更改为立体,所以我写此
UPD功能:改变为COL-主要
void frustum_matrix(float right, float left, float bottom, float top, float near, float far, matrix result)
{
// First Column
result[0] = 2 * near/(right - left);
result[1] = 0.0;
result[2] = 0.0;
result[3] = 0.0;
// Second Column
result[4] = 0.0;
result[5] = 2 * near/(top - bottom);
result[6] = 0.0;
result[7] = 0.0;
// Third Column
result[8] = (right + left)/(right - left);
result[9] = (top + bottom)/(top - bottom);
result[10] = -(far + near)/(far - near);
result[11] = -1;
// Fourth Column
result[12] = 0.0;
result[13] = 0.0;
result[14] = -(2 * far * near)/(far - near);
result[15] = 0.0;
}
将我的投影设置为平截头矩阵,其中aspect_ratio = screen_width/screen_heigth
frustum_matrix(-aspect_ratio, aspect_ratio, -1.0, 1.0, 0.1, 1.0, PROJECTION_MATRIX);
那么我在glFrustrum页面查看矩阵页面http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml,但矩阵为ortho func是从相同的来源和工作正常。无论如何,我看到类似https://stackoverflow.com/a/5812983/1039175截锥体函数类似的平截头体矩阵。
所有我得到的是空白屏幕,视口和其他与绘制有关的东西设置正确。
+1列主要矩阵:) – Erik 2012-03-13 21:53:20
将仔细检查,谢谢 – Aristarhys 2012-03-14 16:41:49