iDevGames Forums
opengl bitmap font question: switching to fullscreen - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: opengl bitmap font question: switching to fullscreen (/thread-4111.html)

opengl bitmap font question: switching to fullscreen - moon_magic - Jul 7, 2006 06:56 PM

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.

opengl bitmap font question: switching to fullscreen - Jones - Jul 8, 2006 10:39 AM

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

opengl bitmap font question: switching to fullscreen - OneSadCookie - Jul 8, 2006 03:39 PM

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.