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 > Switching between perspective and ortho in the same scene

#160587 - FireSlash - Fri Jul 18, 2008 4:28 am

I'm trying to get some text to display on the 3d screen, but I can't get the dimensions to 1:1 in perspective mode, so I'd like to flip into ortho for displaying it. I wrote some code to swap in and out on the fly, but it's not working out so well. Maybe someone knows where I've gone wrong?

The code is supposed to work like this:
// blah blah 3d rendering wee
screen.toOrtho();
fnt_Arial.print("lol text");
screen.toPerspective();
// lol lol lol more rendering weeeeeeeeee

Code:
void screen3d::toOrtho()
{
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();
   glOrtho( 0, 255 , 191 , 0, -1, 1 );
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();
}

void screen3d::toPerspective()
{
   glMatrixMode( GL_PROJECTION );
   glPopMatrix(1);
   glMatrixMode( GL_MODELVIEW );
   glPopMatrix(1);
}

_________________
FireSlash.net

#160597 - a128 - Fri Jul 18, 2008 8:06 am

Oh, the famous glOrtho problem. Please search this forum.

#160599 - DiscoStew - Fri Jul 18, 2008 8:14 am

Obi-wan: *waves hand* "This is the post you're looking for..." (*I think*)

http://forum.gbadev.org/viewtopic.php?p=114624#114624
_________________
DS - It's all about DiscoStew

#160600 - Dwedit - Fri Jul 18, 2008 8:21 am

You could also skip that stuff and just use the BG layers or sprites.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."