Overview
Context
Changes
Added Makefile version [9b7eb118a8].
|
1
2
3
4
5
6
7
8
|
+
+
+
+
+
+
+
+
|
all:
@cd src && ${MAKE} ${MFLAGS}
@cd test && ${MAKE} ${MFLAGS}
clean:
@cd src && ${MAKE} ${MFLAGS} clean
@cd test && ${MAKE} ${MFLAGS} clean
@rm -f *~
|
| | | | | | |
Added src/Makefile version [a545af16af].
|
1
2
3
4
5
6
7
|
+
+
+
+
+
+
+
|
all:
@mkdir -p build
@objfw-compile --lib 0.0 -o objgamekit --builddir build *.m \
--arc `pkg-config --cflags --libs allegro-5.0 allegro_main-5.0`
clean:
@rm -fr build libobjgamekit.* *~
|
| | | | | |
Added src/OGKDisplay.h version [575fe769bc].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2012 Jonathan Schleifer <js@webkeks.org>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1.) The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 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.
*/
#include <allegro5/allegro.h>
#import <ObjFW/ObjFW.h>
@interface OGKDisplay: OFObject
{
ALLEGRO_DISPLAY *display;
}
+ displayWithSize: (of_dimension_t)size
fullscreen: (BOOL)fullscreen
resizable: (BOOL)resizable;
- initWithSize: (of_dimension_t)size
fullscreen: (BOOL)fullscreen
resizable: (BOOL)resizable;
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay;
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OGKDisplay.m version [78f573a0bd].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2012 Jonathan Schleifer <js@webkeks.org>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1.) The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 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];
}
+ displayWithSize: (of_dimension_t)size
fullscreen: (BOOL)fullscreen
resizable: (BOOL)resizable
{
return [[self alloc] initWithSize: size
fullscreen: fullscreen
resizable: resizable];
}
- initWithSize: (of_dimension_t)size
fullscreen: (BOOL)fullscreen
resizable: (BOOL)resizable
{
int flags = 0;
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
if (fullscreen)
flags |= ALLEGRO_FULLSCREEN;
else if (resizable)
flags |= ALLEGRO_RESIZABLE;
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);
}
- (ALLEGRO_DISPLAY*)OGK_allegroDisplay
{
return display;
}
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OGKEvent.h version [19b5dab082].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
65
66
67
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2012 Jonathan Schleifer <js@webkeks.org>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1.) The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 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.
*/
#include <allegro5/allegro.h>
#import <ObjFW/ObjFW.h>
typedef enum ogk_event_type_t {
OGK_EVENT_TYPE_CLOSE = 1
} ogk_event_type_t;
@interface OGKEvent: OFObject
{
ALLEGRO_EVENT event;
}
- (ALLEGRO_EVENT*)OGK_allegroEvent;
@end
@interface OGKCloseEvent: OGKEvent
@end
@interface OGKKeyboardEvent: OGKEvent
@property (readonly, assign) int keycode;
@end
@interface OGKKeyPressEvent: OGKKeyboardEvent
@end
@interface OGKKeyReleaseEvent: OGKKeyboardEvent
@end
@interface OGKMouseEvent: OGKEvent
@property (readonly, assign) of_point_t cursor;
@property (readonly, assign) of_point_t wheel;
@end
@interface OGKMouseMovedEvent: OGKMouseEvent
@property (readonly, assign) of_point_t deltaCursor, deltaWheel;
@end
@interface OGKMouseButtonEvent: OGKMouseEvent
@property (readonly, assign) unsigned button;
@end
@interface OGKMouseButtonPressedEvent: OGKMouseButtonEvent
@end
@interface OGKMouseButtonReleasedEvent: OGKMouseButtonEvent
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OGKEvent.m version [5e13753beb].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2012 Jonathan Schleifer <js@webkeks.org>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1.) The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 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 "OGKEvent.h"
@implementation OGKEvent
- (ALLEGRO_EVENT*)OGK_allegroEvent
{
return &event;
}
@end
@implementation OGKCloseEvent
@end
@implementation OGKKeyboardEvent
- (int)keycode
{
return event.keyboard.keycode;
}
@end
@implementation OGKKeyPressEvent
@end
@implementation OGKKeyReleaseEvent
@end
@implementation OGKMouseEvent
- (of_point_t)cursor
{
return of_point(event.mouse.x, event.mouse.y);
}
- (of_point_t)wheel
{
return of_point(event.mouse.w, event.mouse.z);
}
@end
@implementation OGKMouseMovedEvent
- (of_point_t)deltaCursor
{
return of_point(event.mouse.dx, event.mouse.dy);
}
- (of_point_t)deltaWheel
{
return of_point(event.mouse.dw, event.mouse.dz);
}
@end
@implementation OGKMouseButtonEvent
- (unsigned)button
{
return event.mouse.button;
}
@end
@implementation OGKMouseButtonPressedEvent
@end
@implementation OGKMouseButtonReleasedEvent
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OGKEventQueue.h version [e90f6c2f9f].
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2012 Jonathan Schleifer <js@webkeks.org>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1.) The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 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.
*/
#include <allegro5/allegro.h>
#import <ObjFW/ObjFW.h>
#import "OGKEvent.h"
#import "OGKDisplay.h"
@protocol OGKEventQueueDelegate <OFObject>
@optional
- (void)displayWasClosed: (OGKCloseEvent*)event;
// FIXME: Those need to get the OGKDisplay passed!
- (void)keyWasPressed: (OGKKeyPressEvent*)event;
- (void)keyWasReleased: (OGKKeyReleaseEvent*)event;
- (void)mouseWasMoved: (OGKMouseMovedEvent*)event;
- (void)mouseButtonWasPressed: (OGKMouseButtonPressedEvent*)event;
- (void)mouseButtonWasReleased: (OGKMouseButtonReleasedEvent*)event;
@end
@interface OGKEventQueue: OFObject
{
ALLEGRO_EVENT_QUEUE *eventQueue;
/* FIXME: Make this weak once there is support in ObjFW for it */
__unsafe_unretained id <OGKEventQueueDelegate> delegate;
}
@property (unsafe_unretained) id <OGKEventQueueDelegate> delegate;
- (void)handleNextEvent;
- (void)registerDisplay: (OGKDisplay*)display;
- (void)unregisterDisplay: (OGKDisplay*)display;
- (void)registerKeyboard;
- (void)unregisterKeyboard;
- (void)registerMouse;
- (void)unregisterMouse;
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OGKEventQueue.m version [8d48ecf372].