Use flags for -[OGKDisplay init...].
This commit is contained in:
parent
b72b6c8ac7
commit
c2baff8cd6
3 changed files with 26 additions and 19 deletions
|
@ -22,6 +22,14 @@
|
||||||
|
|
||||||
#import <ObjFW/ObjFW.h>
|
#import <ObjFW/ObjFW.h>
|
||||||
|
|
||||||
|
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
|
@interface OGKDisplay: OFObject
|
||||||
{
|
{
|
||||||
ALLEGRO_DISPLAY *display;
|
ALLEGRO_DISPLAY *display;
|
||||||
|
@ -33,8 +41,7 @@
|
||||||
+ OGK_displayForAllegroDisplay: (ALLEGRO_DISPLAY*)display;
|
+ OGK_displayForAllegroDisplay: (ALLEGRO_DISPLAY*)display;
|
||||||
- initWithSize: (of_dimension_t)size
|
- initWithSize: (of_dimension_t)size
|
||||||
position: (of_point_t)position
|
position: (of_point_t)position
|
||||||
fullscreen: (BOOL)fullscreen
|
flags: (ogk_display_flags_t)flags;
|
||||||
resizable: (BOOL)resizable;
|
|
||||||
- (void)setWindowTitle: (OFString*)title;
|
- (void)setWindowTitle: (OFString*)title;
|
||||||
- (void)update;
|
- (void)update;
|
||||||
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay;
|
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay;
|
||||||
|
|
|
@ -49,7 +49,7 @@ static OFDataArray *allegroDisplays = nil;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
if (cArray[i] == display)
|
if (cArray[i] == display)
|
||||||
return [displays objectAtIndex: i];
|
return displays[i];
|
||||||
} @finally {
|
} @finally {
|
||||||
[mutex unlock];
|
[mutex unlock];
|
||||||
}
|
}
|
||||||
|
@ -59,27 +59,26 @@ static OFDataArray *allegroDisplays = nil;
|
||||||
|
|
||||||
- initWithSize: (of_dimension_t)size
|
- initWithSize: (of_dimension_t)size
|
||||||
position: (of_point_t)position
|
position: (of_point_t)position
|
||||||
fullscreen: (BOOL)fullscreen
|
flags: (ogk_display_flags_t)flags
|
||||||
resizable: (BOOL)resizable
|
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int allegroFlags = 0;
|
||||||
|
|
||||||
self = [super init];
|
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);
|
al_set_new_window_position(position.x, position.y);
|
||||||
|
|
||||||
if (fullscreen)
|
if (flags & OGK_DISPLAY_FLAGS_FULLSCREEN)
|
||||||
flags |= ALLEGRO_FULLSCREEN;
|
allegroFlags |= ALLEGRO_FULLSCREEN;
|
||||||
else if (resizable)
|
if (flags & OGK_DISPLAY_FLAGS_RESIZABLE)
|
||||||
flags |= ALLEGRO_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);
|
display = al_create_display(size.width, size.height);
|
||||||
|
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
|
|
|
@ -87,10 +87,11 @@ OF_APPLICATION_DELEGATE(TestMain)
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching
|
- (void)applicationDidFinishLaunching
|
||||||
{
|
{
|
||||||
|
ogk_display_flags_t flags = OGK_DISPLAY_FLAGS_RESIZABLE;
|
||||||
|
|
||||||
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
|
display = [[OGKDisplay alloc] initWithSize: of_dimension(640, 480)
|
||||||
position: of_point(200, 200)
|
position: of_point(200, 200)
|
||||||
fullscreen: NO
|
flags: flags];
|
||||||
resizable: NO];
|
|
||||||
display.size = of_dimension(800, 600);
|
display.size = of_dimension(800, 600);
|
||||||
display.windowPosition = of_point(100, 100);
|
display.windowPosition = of_point(100, 100);
|
||||||
display.windowTitle = @"ObjGameKit test";
|
display.windowTitle = @"ObjGameKit test";
|
||||||
|
|
Reference in a new issue