opengl bitmap font question: switching to fullscreen

moon_magic
Unregistered
 
Post: #1
i've got a nehe display list going in my game. no problems drawing the font, moving it around, etc. except that when i switch to fullscreen mode, all the alignment that i was doing with glRasterPos2f is messed up. is there a good way to center text using a display list? how do i implement a fullscreen mode that keeps my text where i want it? also, i'm using a non-standard font; how do i include that with my game when i finish it? i'm using cocoa, and i used interface builder to set the size of my window to 640 by 480. when i switch to fullscreen, i use this:

Code:
else
    {
        unsigned int windowStyle;
        NSRect       contentRect;

        StartingWindow = [NSApp keyWindow];
        windowStyle    = NSBorderlessWindowMask;
        contentRect    = [[NSScreen mainScreen] frame];
        FullScreenWindow = [[NSWindow alloc] initWithContentRect:contentRect
                        styleMask: windowStyle backing:NSBackingStoreBuffered defer: NO];
        if(FullScreenWindow != nil)
        {
            NSLog(@"Window was created");            
            [FullScreenWindow setTitle: @"Versnoof"];            
            [FullScreenWindow setReleasedWhenClosed: YES];
            [FullScreenWindow setContentView: self];
            [FullScreenWindow makeKeyAndOrderFront:self ];
            [FullScreenWindow setLevel: NSScreenSaverWindowLevel - 1];
            [FullScreenWindow makeFirstResponder:self];
            [NSCursor hide];
            FullScreenOn = true;
        }

also, here's my reshape method:

Code:
- (void) reshape
{
    float aspect;
    NSSize bound = [self frame].size;
    aspect = bound.width / bound.height;
    glViewport(0, 0, bound.width, bound.height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f, (GLfloat)aspect, 0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}

i guess i just don't know enough about what's going on when i switch to fullscreen. i understand that it creates a new window, sets some arguments and whatnot, but i don't really know what's going on with the nib stuff, or if i should have coded it myself or what.

to sum up, i'm looking for a good way to align text and i want to make sure that what i draw on the screen stays the same when i switch to fullscreen mode.
Quote this message in a reply
Jones
Unregistered
 
Post: #2
I think, (and I'm not sure - I'm new to fonts, and only have a basic grasp of OpenGL projection), that if you stick a glOrtho command like this:

Code:
gluOrtho2D(0, screen_width, screen_height, 0);

Into your reshape function, it might help.

Just a semi wide guess though. I've never used Cocoa with OpenGL, only GLUT and SDL. Smile
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
If you're drawing your fonts with bitmaps, you're going to have immense problems coping with more than one resolution. I'd highly recommend drawing them as textures instead, in which case Jones' suggestion of using glOrtho to specify a particular "virtual" screen size will work just fine.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bitmap fonts markhula 6 7,568 Feb 27, 2011 12:55 PM
Last Post: markhula
  switching screen resolution NelsonMandella 3 3,237 Apr 25, 2010 01:33 PM
Last Post: SethWillits
  Mac OS X. Switching between fullscreen and windowed mode. e40pud 2 3,980 Jan 25, 2010 12:01 PM
Last Post: OneSadCookie
  Anyone experienced Performance ± with UILabels vs. Bitmap Font in OpenGL ES 1.1? Elphaba 3 4,162 Jul 28, 2009 10:40 AM
Last Post: AnotherJake
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 6,211 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin