ObjGameKit  Diff

Differences From Artifact [3e2683ad84]:

To Artifact [fbfc273e25]:


16
17
18
19
20
21
22




23
24
25
26
27
28
29
30
31






















32
33
34
35
36
37
38
 *   2.) Altered source versions must be plainly marked as such, and must not
 *       be misrepresented as being the original software.
 *   3.) This notice may not be removed or altered from any source distribution.
 */

#import "OGKDisplay.h"





@implementation OGKDisplay
+ (void)initialize
{
	if (self != [OGKDisplay class])
		return;

	if (!al_install_system(ALLEGRO_VERSION_INT, NULL))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];






















}

- initWithSize: (of_dimension_t)size
      position: (of_point_t)position
    fullscreen: (BOOL)fullscreen
     resizable: (BOOL)resizable
{







>
>
>
>









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 *   2.) Altered source versions must be plainly marked as such, and must not
 *       be misrepresented as being the original software.
 *   3.) This notice may not be removed or altered from any source distribution.
 */

#import "OGKDisplay.h"

static OFMutex *mutex = nil;
static OFMutableArray *displays = nil;
static OFDataArray *allegroDisplays = nil;

@implementation OGKDisplay
+ (void)initialize
{
	if (self != [OGKDisplay class])
		return;

	if (!al_install_system(ALLEGRO_VERSION_INT, NULL))
		@throw [OFInitializationFailedException
		    exceptionWithClass: self];

	mutex = [[OFMutex alloc] init];
	displays = [[OFMutableArray alloc] init];
	allegroDisplays = [[OFDataArray alloc]
	    initWithItemSize: sizeof(ALLEGRO_DISPLAY*)];
}

+ OGK_displayForAllegroDisplay: (ALLEGRO_DISPLAY*)display
{
	[mutex lock];
	@try {
		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];
	} @finally {
		[mutex unlock];
	}

	return nil;
}

- initWithSize: (of_dimension_t)size
      position: (of_point_t)position
    fullscreen: (BOOL)fullscreen
     resizable: (BOOL)resizable
{
55
56
57
58
59
60
61








62
63
64
65
66
67










68
69
70
71
72
73
74

	al_set_new_display_flags(flags);
	display = al_create_display(size.width, size.height);

	if (display == NULL)
		@throw [OFInitializationFailedException
		    exceptionWithClass: [self class]];









	return self;
}

- (void)dealloc
{










	if (display != NULL)
		al_destroy_display(display);
}

- (void)setWindowTitle: (OFString*)title
{
	al_set_window_title(display,







>
>
>
>
>
>
>
>






>
>
>
>
>
>
>
>
>
>







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

	al_set_new_display_flags(flags);
	display = al_create_display(size.width, size.height);

	if (display == NULL)
		@throw [OFInitializationFailedException
		    exceptionWithClass: [self class]];

	[mutex lock];
	@try {
		[allegroDisplays addItem: &display];
		[displays addObject: self];
	} @finally {
		[mutex unlock];
	}

	return self;
}

- (void)dealloc
{
	[mutex lock];
	@try {
		size_t index = [displays indexOfObject: self];

		[allegroDisplays removeItemAtIndex: index];
		[displays removeObjectAtIndex: index];
	} @finally {
		[mutex unlock];
	}

	if (display != NULL)
		al_destroy_display(display);
}

- (void)setWindowTitle: (OFString*)title
{
	al_set_window_title(display,