New OGKDisplay methods.
This commit is contained in:
parent
96c5a44ae0
commit
7e755a78c9
3 changed files with 49 additions and 0 deletions
|
@ -27,9 +27,14 @@
|
||||||
ALLEGRO_DISPLAY *display;
|
ALLEGRO_DISPLAY *display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property (assign) of_point_t windowPosition;
|
||||||
|
@property (assign) of_dimension_t size;
|
||||||
|
|
||||||
- initWithSize: (of_dimension_t)size
|
- initWithSize: (of_dimension_t)size
|
||||||
|
position: (of_point_t)position
|
||||||
fullscreen: (BOOL)fullscreen
|
fullscreen: (BOOL)fullscreen
|
||||||
resizable: (BOOL)resizable;
|
resizable: (BOOL)resizable;
|
||||||
|
- (void)setWindowTitle: (OFString*)title;
|
||||||
- (void)update;
|
- (void)update;
|
||||||
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay;
|
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithSize: (of_dimension_t)size
|
- initWithSize: (of_dimension_t)size
|
||||||
|
position: (of_point_t)position
|
||||||
fullscreen: (BOOL)fullscreen
|
fullscreen: (BOOL)fullscreen
|
||||||
resizable: (BOOL)resizable
|
resizable: (BOOL)resizable
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,8 @@
|
||||||
flags |= ALLEGRO_OPENGL_FORWARD_COMPATIBLE;
|
flags |= ALLEGRO_OPENGL_FORWARD_COMPATIBLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
al_set_new_window_position(position.x, position.y);
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
flags |= ALLEGRO_FULLSCREEN;
|
flags |= ALLEGRO_FULLSCREEN;
|
||||||
else if (resizable)
|
else if (resizable)
|
||||||
|
@ -66,6 +69,38 @@
|
||||||
al_destroy_display(display);
|
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
|
- (void)update
|
||||||
{
|
{
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
|
|
|
@ -80,8 +80,17 @@ OF_APPLICATION_DELEGATE(TestMain)
|
||||||
- (void)applicationDidFinishLaunching
|
- (void)applicationDidFinishLaunching
|
||||||
{
|
{
|
||||||
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
|
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
|
||||||
|
position: of_point(200, 200)
|
||||||
fullscreen: NO
|
fullscreen: NO
|
||||||
resizable: 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 = [[OGKEventQueue alloc] init];
|
||||||
eventQueue.delegate = self;
|
eventQueue.delegate = self;
|
||||||
|
|
||||||
|
|
Reference in a new issue