diff --git a/src/OGKDisplay.h b/src/OGKDisplay.h index b7ed740..d43f744 100644 --- a/src/OGKDisplay.h +++ b/src/OGKDisplay.h @@ -27,9 +27,14 @@ ALLEGRO_DISPLAY *display; } +@property (assign) of_point_t windowPosition; +@property (assign) of_dimension_t size; + - initWithSize: (of_dimension_t)size + position: (of_point_t)position fullscreen: (BOOL)fullscreen resizable: (BOOL)resizable; +- (void)setWindowTitle: (OFString*)title; - (void)update; - (ALLEGRO_DISPLAY*)OGK_allegroDisplay; @end diff --git a/src/OGKDisplay.m b/src/OGKDisplay.m index 13e6f3f..55676bf 100644 --- a/src/OGKDisplay.m +++ b/src/OGKDisplay.m @@ -32,6 +32,7 @@ } - initWithSize: (of_dimension_t)size + position: (of_point_t)position fullscreen: (BOOL)fullscreen resizable: (BOOL)resizable { @@ -45,6 +46,8 @@ flags |= ALLEGRO_OPENGL_FORWARD_COMPATIBLE; #endif + al_set_new_window_position(position.x, position.y); + if (fullscreen) flags |= ALLEGRO_FULLSCREEN; else if (resizable) @@ -66,6 +69,38 @@ al_destroy_display(display); } +- (void)setWindowTitle: (OFString*)title +{ + al_set_window_title(display, + [title cStringWithEncoding: OF_STRING_ENCODING_NATIVE]); +} + +- (void)setWindowPosition: (of_point_t)position +{ + al_set_window_position(display, position.x, position.y); +} + +- (of_point_t)windowPosition +{ + int x, y; + + al_get_window_position(display, &x, &y); + + return of_point(x, y); +} + +- (void)setSize: (of_dimension_t)size +{ + al_resize_display(display, size.width, size.height); +} + +- (of_dimension_t)size +{ + return of_dimension( + al_get_display_width(display), + al_get_display_height(display)); +} + - (void)update { al_flip_display(); diff --git a/test/TestMain.m b/test/TestMain.m index 9748e13..d65767a 100644 --- a/test/TestMain.m +++ b/test/TestMain.m @@ -80,8 +80,17 @@ OF_APPLICATION_DELEGATE(TestMain) - (void)applicationDidFinishLaunching { display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480) + position: of_point(200, 200) fullscreen: NO resizable: NO]; + 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)", + display.size.width, display.size.height, + display.windowPosition.x, display.windowPosition.y); + eventQueue = [[OGKEventQueue alloc] init]; eventQueue.delegate = self;