Index: src/OGKDisplay.h ================================================================== --- src/OGKDisplay.h +++ src/OGKDisplay.h @@ -19,10 +19,18 @@ */ #include #import + +typedef enum ogk_display_flags_t { + OGK_DISPLAY_FLAGS_FULLSCREEN = 0x01, + OGK_DISPLAY_FLAGS_RESIZABLE = 0x02, + OGK_DISPLAY_FLAGS_OPENGL = 0x04, + OGK_DISPLAY_FLAGS_OPENGL_3 = 0x08, + OGK_DISPLAY_FLAGS_OPENGL_3_ONLY = 0x10 +} ogk_display_flags_t; @interface OGKDisplay: OFObject { ALLEGRO_DISPLAY *display; } @@ -31,11 +39,10 @@ @property (assign) of_dimension_t size; + OGK_displayForAllegroDisplay: (ALLEGRO_DISPLAY*)display; - initWithSize: (of_dimension_t)size position: (of_point_t)position - fullscreen: (BOOL)fullscreen - resizable: (BOOL)resizable; + flags: (ogk_display_flags_t)flags; - (void)setWindowTitle: (OFString*)title; - (void)update; - (ALLEGRO_DISPLAY*)OGK_allegroDisplay; @end Index: src/OGKDisplay.m ================================================================== --- src/OGKDisplay.m +++ src/OGKDisplay.m @@ -47,41 +47,40 @@ ALLEGRO_DISPLAY **cArray = [allegroDisplays cArray]; size_t i, count = [allegroDisplays count]; for (i = 0; i < count; i++) if (cArray[i] == display) - return [displays objectAtIndex: i]; + return displays[i]; } @finally { [mutex unlock]; } return nil; } - initWithSize: (of_dimension_t)size position: (of_point_t)position - fullscreen: (BOOL)fullscreen - resizable: (BOOL)resizable + flags: (ogk_display_flags_t)flags { - int flags = 0; + int allegroFlags = 0; self = [super init]; -#if 0 - /* TODO: Find a nice way to set these when requested */ - flags |= ALLEGRO_OPENGL_3_0; - flags |= ALLEGRO_OPENGL_FORWARD_COMPATIBLE; -#endif - al_set_new_window_position(position.x, position.y); - if (fullscreen) - flags |= ALLEGRO_FULLSCREEN; - else if (resizable) - flags |= ALLEGRO_RESIZABLE; + if (flags & OGK_DISPLAY_FLAGS_FULLSCREEN) + allegroFlags |= ALLEGRO_FULLSCREEN; + if (flags & OGK_DISPLAY_FLAGS_RESIZABLE) + allegroFlags |= ALLEGRO_RESIZABLE; + if (flags & OGK_DISPLAY_FLAGS_OPENGL) + allegroFlags |= ALLEGRO_OPENGL; + if (flags & OGK_DISPLAY_FLAGS_OPENGL_3) + allegroFlags |= ALLEGRO_OPENGL_3_0; + if (flags & OGK_DISPLAY_FLAGS_OPENGL_3_ONLY) + allegroFlags |= ALLEGRO_OPENGL_FORWARD_COMPATIBLE; - al_set_new_display_flags(flags); + al_set_new_display_flags(allegroFlags); display = al_create_display(size.width, size.height); if (display == NULL) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; Index: test/TestMain.m ================================================================== --- test/TestMain.m +++ test/TestMain.m @@ -85,14 +85,15 @@ [display update]; } - (void)applicationDidFinishLaunching { + ogk_display_flags_t flags = OGK_DISPLAY_FLAGS_RESIZABLE; + display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480) position: of_point(200, 200) - fullscreen: NO - resizable: NO]; + flags: flags]; display.size = of_dimension(800, 600); display.windowPosition = of_point(100, 100); display.windowTitle = @"ObjGameKit test"; of_log(@"Display is %.fx%.f at (%.f, %.f)",