Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/gc_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,30 +2490,30 @@ static void draw_arrays_general(DrawMode gxmode, int first, int count)
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble near, GLdouble far)
{
Mtx44 mt;
float mt[16];
f32 tmp;

tmp = 1.0f / (right - left);
mt[0][0] = (2 * near) * tmp;
mt[0][1] = 0.0f;
mt[0][2] = (right + left) * tmp;
mt[0][3] = 0.0f;
mt[0] = (2 * near) * tmp;
mt[4] = 0.0f;
mt[8] = (right + left) * tmp;
mt[12] = 0.0f;
tmp = 1.0f / (top - bottom);
mt[1][0] = 0.0f;
mt[1][1] = (2 * near) * tmp;
mt[1][2] = (top + bottom) * tmp;
mt[1][3] = 0.0f;
mt[1] = 0.0f;
mt[5] = (2 * near) * tmp;
mt[9] = (top + bottom) * tmp;
mt[13] = 0.0f;
tmp = 1.0f / (far - near);
mt[2][0] = 0.0f;
mt[2][1] = 0.0f;
mt[2][2] = -(far + near) * tmp;
mt[2][3] = -2.0 * (far * near) * tmp;
mt[3][0] = 0.0f;
mt[3][1] = 0.0f;
mt[3][2] = -1.0f;
mt[3][3] = 0.0f;

glMultMatrixf((float *)mt);
mt[2] = 0.0f;
mt[6] = 0.0f;
mt[10] = -(far + near) * tmp;
mt[14] = -2.0 * (far * near) * tmp;
mt[3] = 0.0f;
mt[7] = 0.0f;
mt[11] = -1.0f;
mt[15] = 0.0f;

glMultMatrixf(mt);
}

void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
Expand Down
2 changes: 2 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ static inline void gl_matrix_to_gx(const GLfloat *source, Mtx mv)
float w = source[15];
if (w != 1.0 && w != 0.0) {
for (int i = 0; i < 16; i++) {
if (i % 4 == 3) continue;
mv[i%4][i/4] = source[i] / w;
}
} else {
for (int i = 0; i < 16; i++) {
if (i % 4 == 3) continue;
mv[i%4][i/4] = source[i];
}
}
Expand Down
Loading