#46494 - blaisef01 - Sun Jun 26, 2005 7:26 am
Hi,
I wrote an glOrtho function as i couldn't see one in the ndslib. Hope it comes in useful for someone. It seems to work okay but haven't tested it extensively so it may bust in various situations.
void glOrthof32(f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far)
{
f32 f2;
f2 = F32_TWO; // 2 * 4096
glMatrixMode(GL_PROJECTION);
MATRIX_LOAD4x4 = divf32(F32_TWO, right - left);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = -divf32(right + left, right - left);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = divf32(F32_TWO, top - bottom);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = -divf32(top + bottom, top - bottom);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = divf32(F32_TWO, far - near);
MATRIX_LOAD4x4 = -divf32(far + near, far - near);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = F32_ONE; // 4096
glStoreMatrix(0);
}
void gluOrtho2Df32(f32 left, f32 right, f32 bottom, f32 top)
{
glOrthof32(left, right, bottom, top, intof32(-1), intof32(1));
}
void glOrtho(float left, float right, float bottom, float top, float near, float far)
{
glOrthof32(floatof32(left), floatof32(right), floatof32(bottom), floatof32(top), floatof32(near), floatof32(far));
}
void gluOrtho2D(float left, float right, float bottom, float top)
{
gluOrtho2Df32(floatof32(left), floatof32(right), floatof32(bottom), floatof32(top));
}
Any suggestions, dissings what ever would be appreciated.
Cheers,
Aaron
I wrote an glOrtho function as i couldn't see one in the ndslib. Hope it comes in useful for someone. It seems to work okay but haven't tested it extensively so it may bust in various situations.
void glOrthof32(f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far)
{
f32 f2;
f2 = F32_TWO; // 2 * 4096
glMatrixMode(GL_PROJECTION);
MATRIX_LOAD4x4 = divf32(F32_TWO, right - left);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = -divf32(right + left, right - left);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = divf32(F32_TWO, top - bottom);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = -divf32(top + bottom, top - bottom);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = divf32(F32_TWO, far - near);
MATRIX_LOAD4x4 = -divf32(far + near, far - near);
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = 0;
MATRIX_LOAD4x4 = F32_ONE; // 4096
glStoreMatrix(0);
}
void gluOrtho2Df32(f32 left, f32 right, f32 bottom, f32 top)
{
glOrthof32(left, right, bottom, top, intof32(-1), intof32(1));
}
void glOrtho(float left, float right, float bottom, float top, float near, float far)
{
glOrthof32(floatof32(left), floatof32(right), floatof32(bottom), floatof32(top), floatof32(near), floatof32(far));
}
void gluOrtho2D(float left, float right, float bottom, float top)
{
gluOrtho2Df32(floatof32(left), floatof32(right), floatof32(bottom), floatof32(top));
}
Any suggestions, dissings what ever would be appreciated.
Cheers,
Aaron