gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > glOrtho? A crap attempt....

#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

#46495 - Normmatt - Sun Jun 26, 2005 7:51 am

What exactly does this function do and any screens of what it outputs?

#46496 - blaisef01 - Sun Jun 26, 2005 8:13 am

It's supposed to work in the same way as the opengl glOrtho function - to create an orthographic viewport, so i can line up 3d coords with 2d coords.
hopefully then using the 3d hardware to break the 128 sprite limit.. that's the plan anyway.

That probably didn't make much sense seeing as it's 8am and i haven't been to sleep yet. And no i have no screenshots as of yet as I'm running of hardware, haven't bothered with emulators in a while.

Aaron

#46516 - tepples - Sun Jun 26, 2005 3:33 pm

You get 2048 quads per scene with the Nintendo DS 3D core, but how many quads and how many pixels can be on the current scanline?

And are you trying to break 128 sprites per scene or 128 sprites on one scanline? If the former, have you tried swapping OAM using hblank DMA?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.