opengl bitmap font question: switching to fullscreen

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:

        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:

- (void) reshape
    float aspect;
    NSSize bound = [self frame].size;
    aspect = bound.width / bound.height;
    glViewport(0, 0, bound.width, bound.height);
    gluPerspective(45.0f, (GLfloat)aspect, 0.1f,100.0f);

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
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:

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
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 12,552 Feb 27, 2011 12:55 PM
Last Post: markhula
  switching screen resolution NelsonMandella 3 5,338 Apr 25, 2010 01:33 PM
Last Post: SethWillits
  Mac OS X. Switching between fullscreen and windowed mode. e40pud 2 6,255 Jan 25, 2010 12:01 PM
Last Post: OneSadCookie
  Anyone experienced Performance ± with UILabels vs. Bitmap Font in OpenGL ES 1.1? Elphaba 3 6,392 Jul 28, 2009 10:40 AM
Last Post: AnotherJake
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 8,885 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin