Subversion Repositories gelsvn

Rev

Rev 648 | Rev 657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 648 Rev 656
Line 160... Line 160...
160
    if ([theEvent modifierFlags] & NSAlternateKeyMask) // send to pan
160
    if ([theEvent modifierFlags] & NSAlternateKeyMask) // send to pan
161
		[self rightMouseDown:theEvent];
161
		[self rightMouseDown:theEvent];
162
	else {
162
	else {
163
        
163
        
164
        NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
164
        NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
165
        
165
        [[self openGLContext] makeCurrentContext];
166
        Vec2i pos(location.x,location.y);
166
        Vec2i pos(location.x,location.y);
-
 
167
        pos *= int([[self window]backingScaleFactor]);
-
 
168
        if(!me.grab_mesh(pos))
167
        me.grab_ball(ROTATE_ACTION,pos);
169
            me.grab_ball(ROTATE_ACTION,pos);
168
	}
170
	}
169
}
171
}
170
 
172
 
171
 
173
 
172
 
174
 
Line 174... Line 176...
174
 
176
 
175
- (void)rightMouseDown:(NSEvent *)theEvent // pan
177
- (void)rightMouseDown:(NSEvent *)theEvent // pan
176
{
178
{
177
	NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
179
	NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
178
    Vec2i pos(location.x,location.y);
180
    Vec2i pos(location.x,location.y);
-
 
181
    pos *= int([[self window]backingScaleFactor]);
179
    me.grab_ball(PAN_ACTION,pos);
182
    me.grab_ball(PAN_ACTION,pos);
180
}
183
}
181
 
184
 
182
// ---------------------------------
185
// ---------------------------------
183
 
186
 
Line 187... Line 190...
187
 
190
 
188
// ---------------------------------
191
// ---------------------------------
189
 
192
 
190
- (void)mouseUp:(NSEvent *)theEvent
193
- (void)mouseUp:(NSEvent *)theEvent
191
{
194
{
-
 
195
    me.release_mesh();
192
    me.release_ball();
196
    me.release_ball();
193
}
197
}
194
 
198
 
195
// ---------------------------------
199
// ---------------------------------
196
 
200
 
Line 210... Line 214...
210
 
214
 
211
- (void)mouseDragged:(NSEvent *)theEvent
215
- (void)mouseDragged:(NSEvent *)theEvent
212
{
216
{
213
	NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
217
	NSPoint location = [self convertPoint:[theEvent locationInWindow] fromView:nil];
214
    Vec2i pos(location.x,location.y);
218
    Vec2i pos(location.x,location.y);
-
 
219
    pos *= int([[self window]backingScaleFactor]);
-
 
220
    [[self openGLContext] makeCurrentContext];
-
 
221
    if(!me.drag_mesh(pos))
215
    me.roll_ball(pos);
222
        me.roll_ball(pos);
216
    [self setNeedsDisplay: YES];
223
    [self setNeedsDisplay: YES];
217
 
224
    
218
}
225
}
219
 
226
 
220
// ---------------------------------
227
// ---------------------------------
221
 
228
 
222
- (void)scrollWheel:(NSEvent *)theEvent
229
- (void)scrollWheel:(NSEvent *)theEvent
Line 245... Line 252...
245
 
252
 
246
// ---------------------------------
253
// ---------------------------------
247
 
254
 
248
- (void) drawRect:(NSRect)rect
255
- (void) drawRect:(NSRect)rect
249
{
256
{
250
    glReportError (__LINE__);
-
 
251
 
-
 
252
    NSOpenGLContext* ctxt = [self openGLContext];
257
    NSOpenGLContext* ctxt = [self openGLContext];
253
    glReportError (__LINE__);
-
 
254
    if(ctxt != nil) {
258
    if(ctxt != nil) {
255
        [ctxt makeCurrentContext];
259
        [ctxt makeCurrentContext];
256
        glReportError (__LINE__);
-
 
257
        me.display(int([[self window]backingScaleFactor]));
260
        me.display(int([[self window]backingScaleFactor]));
258
        glReportError (__LINE__);
-
 
259
        [ctxt flushBuffer];
261
        [ctxt flushBuffer];
260
        glReportError (__LINE__);
-
 
261
    }
262
    }
262
}
263
}
263
 
264
 
264
// ---------------------------------
265
// ---------------------------------
265
 
266
 
266
// set initial OpenGL state (current context is set)
267
// set initial OpenGL state (current context is set)
267
// called after context is created
268
// called after context is created
268
- (void) prepareOpenGL
269
- (void) prepareOpenGL
269
{
270
{
270
    glReportError (__LINE__);
-
 
271
    [[self openGLContext] makeCurrentContext];
271
    [[self openGLContext] makeCurrentContext];
272
    glReportError (__LINE__);
-
 
273
    GLint swapInt = 1;
272
    GLint swapInt = 1;
274
    glReportError (__LINE__);
-
 
275
    [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
273
    [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
276
    glReportError (__LINE__);
-
 
277
    me.init();
274
    me.init();
278
    glReportError (__LINE__);
-
 
279
    NSLog(@"OpenGL Initialized");
275
    NSLog(@"OpenGL Initialized");
280
}
276
}
281
// ---------------------------------
277
// ---------------------------------
282
 
278
 
283
// this can be a troublesome call to do anything heavyweight, as it is called on window moves, resizes, and display config changes.  So be
279
// this can be a troublesome call to do anything heavyweight, as it is called on window moves, resizes, and display config changes.  So be
Line 349... Line 345...
349
    if(me.add_file([ filename UTF8String])) {
345
    if(me.add_file([ filename UTF8String])) {
350
        [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:filename]];
346
        [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:filename]];
351
        [self setNeedsDisplay: YES];
347
        [self setNeedsDisplay: YES];
352
        return YES;
348
        return YES;
353
    }
349
    }
354
       return NO;
350
    return NO;
355
}
351
}
356
 
352
 
357
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
353
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
358
{
354
{
359
    NSURL* fileURL = [NSURL URLFromPasteboard: [sender draggingPasteboard]];
355
    NSURL* fileURL = [NSURL URLFromPasteboard: [sender draggingPasteboard]];