New OGKDisplay methods.

This commit is contained in:
Jonathan Schleifer 2012-08-20 01:08:42 +02:00
parent 96c5a44ae0
commit 7e755a78c9
3 changed files with 49 additions and 0 deletions

View file

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

View file

@ -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();

View file

@ -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;