~ubuntu-branches/ubuntu/wily/oolite/wily-proposed

« back to all changes in this revision

Viewing changes to src/Cocoa/MyOpenGLView.h

  • Committer: Package Import Robot
  • Author(s): Nicolas Boulenguez
  • Date: 2011-12-22 00:22:39 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20111222002239-pr3upeupp4jw1psp
Tags: 1.76-1
* New upstream.
* watch: scan upstream stable releases instead of dev snapshots.
* control: use default gobjc instead of explicit 4.6.
* rules: use dpkg-dev build flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
MyOpenGLView.h
 
4
 
 
5
Oolite
 
6
Copyright (C) 2004-2011 Giles C Williams and contributors
 
7
 
 
8
This program is free software; you can redistribute it and/or
 
9
modify it under the terms of the GNU General Public License
 
10
as published by the Free Software Foundation; either version 2
 
11
of the License, or (at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program; if not, write to the Free Software
 
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
21
MA 02110-1301, USA.
 
22
 
 
23
*/
 
24
 
 
25
#import "OOCocoa.h"
 
26
#import "OOOpenGL.h"
 
27
 
 
28
#define OpenGLViewSuperClass    NSOpenGLView
 
29
 
 
30
#define MAX_CLEAR_DEPTH         100000000.0
 
31
// 100 000 km.
 
32
 
 
33
#define NUM_KEYS                        320
 
34
#define MOUSE_DOUBLE_CLICK_INTERVAL     0.40
 
35
 
 
36
@class Entity, GameController;
 
37
 
 
38
enum GameViewKeys
 
39
{
 
40
 
 
41
        gvFunctionKey1 = 241,
 
42
        gvFunctionKey2,
 
43
        gvFunctionKey3,
 
44
        gvFunctionKey4,
 
45
        gvFunctionKey5,
 
46
        gvFunctionKey6,
 
47
        gvFunctionKey7,
 
48
        gvFunctionKey8,
 
49
        gvFunctionKey9,
 
50
        gvFunctionKey10,
 
51
        gvFunctionKey11,
 
52
        gvArrowKeyRight,
 
53
        gvArrowKeyLeft,
 
54
        gvArrowKeyDown,
 
55
        gvArrowKeyUp,
 
56
        gvMouseLeftButton = 301,
 
57
        gvMouseDoubleClick,
 
58
        gvHomeKey,
 
59
        gvEndKey,
 
60
        gvInsertKey,
 
61
        gvDeleteKey,
 
62
        gvPageUpKey,
 
63
        gvPageDownKey,
 
64
        gvNumberKey0 = 48,
 
65
        gvNumberKey1,
 
66
        gvNumberKey2,
 
67
        gvNumberKey3,
 
68
        gvNumberKey4,
 
69
        gvNumberKey5,
 
70
        gvNumberKey6,
 
71
        gvNumberKey7,
 
72
        gvNumberKey8,
 
73
        gvNumberKey9
 
74
};
 
75
 
 
76
enum StringInput
 
77
{
 
78
        gvStringInputNo = 0,
 
79
        gvStringInputAlpha = 1,
 
80
        gvStringInputAll = 2
 
81
};
 
82
 
 
83
extern int debug;
 
84
 
 
85
@interface MyOpenGLView : OpenGLViewSuperClass
 
86
{
 
87
@private
 
88
        GameController          *gameController;
 
89
 
 
90
        BOOL                            keys[NUM_KEYS];
 
91
        BOOL                            supressKeys;    // DJS
 
92
 
 
93
        BOOL                            opt, ctrl, command, shift;
 
94
        BOOL                            allowingStringInput;
 
95
        BOOL                            isAlphabetKeyDown;
 
96
        BOOL                            commandQ;
 
97
        BOOL                            commandF;
 
98
        BOOL                            f12;
 
99
        
 
100
        int                                     keycodetrans[255];
 
101
        
 
102
        BOOL                            m_glContextInitialized;
 
103
        
 
104
        NSTimeInterval          timeIntervalAtLastClick;
 
105
        BOOL                            doubleClick;
 
106
        
 
107
        NSMutableString         *typedString;
 
108
        
 
109
        NSPoint                         virtualJoystickPosition;
 
110
        
 
111
        NSSize                          viewSize;
 
112
        GLfloat                         display_z;
 
113
        GLfloat                         x_offset, y_offset;
 
114
        
 
115
        int                                     _virtualScreen;
 
116
        NSData                          *_pixelFormatAttributes;
 
117
}
 
118
 
 
119
 
 
120
- (void) setStringInput: (enum StringInput) value;
 
121
- (void) allowStringInput: (BOOL) value;
 
122
- (enum StringInput) allowingStringInput;
 
123
- (NSString *) typedString;
 
124
- (void) resetTypedString;
 
125
- (void) setTypedString:(NSString*) value;
 
126
 
 
127
- (NSSize) viewSize;
 
128
- (GLfloat) display_z;
 
129
- (GLfloat) x_offset;
 
130
- (GLfloat) y_offset;
 
131
 
 
132
- (GameController *) gameController;
 
133
- (void) setGameController:(GameController *) controller;
 
134
 
 
135
- (void) initialiseGLWithSize:(NSSize) v_size;
 
136
 
 
137
- (NSData *)pixelFormatAttributes;
 
138
 
 
139
- (void) drawRect:(NSRect)rect;
 
140
- (void) updateScreen;
 
141
 
 
142
- (BOOL) snapShot:(NSString *)filename;
 
143
 
 
144
- (void)mouseDown:(NSEvent *)theEvent;
 
145
- (void)mouseUp:(NSEvent *)theEvent;
 
146
 
 
147
- (void) setVirtualJoystick:(double) vmx :(double) vmy;
 
148
- (NSPoint) virtualJoystickPosition;
 
149
 
 
150
- (void) clearKeys;
 
151
- (void) clearMouse;
 
152
- (void) clearKey: (int)theKey;
 
153
- (BOOL) isAlphabetKeyDown;
 
154
- (void) supressKeysUntilKeyUp; // DJS
 
155
- (BOOL) isDown: (int) key;
 
156
- (BOOL) isOptDown;
 
157
- (BOOL) isCtrlDown;
 
158
- (BOOL) isCommandDown;
 
159
- (BOOL) isShiftDown;
 
160
- (int) numKeys;
 
161
 
 
162
// Command-key combinations need special handling.
 
163
- (BOOL) isCommandQDown;
 
164
- (BOOL) isCommandFDown;
 
165
- (void) clearCommandF;
 
166
 
 
167
// Check current state of shift key rather than relying on last event.
 
168
+ (BOOL)pollShiftKey;
 
169
 
 
170
#ifndef NDEBUG
 
171
// General image-dumping methods.
 
172
- (void) dumpRGBAToFileNamed:(NSString *)name
 
173
                                           bytes:(uint8_t *)bytes
 
174
                                           width:(OOUInteger)width
 
175
                                          height:(OOUInteger)height
 
176
                                        rowBytes:(OOUInteger)rowBytes;
 
177
 
 
178
- (void) dumpRGBToFileNamed:(NSString *)name
 
179
                                          bytes:(uint8_t *)bytes
 
180
                                          width:(OOUInteger)width
 
181
                                         height:(OOUInteger)height
 
182
                                   rowBytes:(OOUInteger)rowBytes;
 
183
 
 
184
- (void) dumpGrayToFileNamed:(NSString *)name
 
185
                                           bytes:(uint8_t *)bytes
 
186
                                           width:(OOUInteger)width
 
187
                                          height:(OOUInteger)height
 
188
                                        rowBytes:(OOUInteger)rowBytes;
 
189
 
 
190
- (void) dumpGrayAlphaToFileNamed:(NSString *)name
 
191
                                                        bytes:(uint8_t *)bytes
 
192
                                                        width:(OOUInteger)width
 
193
                                                   height:(OOUInteger)height
 
194
                                                 rowBytes:(OOUInteger)rowBytes;
 
195
 
 
196
// Split alpha into separate file.
 
197
- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
 
198
                           andGrayFileNamed:(NSString *)grayName
 
199
                                                  bytes:(uint8_t *)bytes
 
200
                                                  width:(OOUInteger)width
 
201
                                                 height:(OOUInteger)height
 
202
                                           rowBytes:(OOUInteger)rowBytes;
 
203
#endif
 
204
 
 
205
@end