// // MyOpenGLController.m // cfep // // Created by Nobuki Takayama on 06/02/18. // Copyright 2006 OpenXM.org. All rights reserved. // #import "MyOpenGLController.h" // MyOpenGL window id (gid) is an indeger. static MyOpenGLController *oglWindow[GID_MAX]; // gid --> MyOpenGLController instance. static MyDocument *oglParent[GID_MAX]; // gid --> parent MyDocument. static int MyOpenGLControllerInitialized = 0; static int Gid=0; @implementation MyOpenGLController +(void) initMyOpenGLController { int i; if (MyOpenGLControllerInitialized) return; for (i=0; i= 0) && (tid gtest.rr [MyOpenGLController addOglComm: @"[glColor4f,1.0,0.0,0.0,1.0]" to: 0 from: self]; [MyOpenGLController addOglComm: @"[glRectf,-0.5,-0.5,0.5,0.5]" to: 0 from: self]; [MyOpenGLController addOglComm: @"[glib_flush0]" to: 0 from: self]; */ +(void) addOglComm: (NSString *)comm to: (int) tid from: (MyDocument *) owner { if ((0<=tid) && (tid= 0) [oglWindow[tid] addOglComm: comm]; }else ; } +(void) addOglInitComm: (NSString *)comm to: (int) tid from: (MyDocument *) owner { if ((0<=tid) && (tid= 0) [oglWindow[tid] addOglInitComm: comm]; }else ; } -(id) init { self = [self initWithWindowNibName: @"MyOpenGL"]; if (self) [self setWindowFrameAutosaveName: @"cfep OpenGLView"]; return self; } -(void) setGid: (int) mygid { gid = mygid; } -(int)getGid { return gid; } -(void) windowDidLoad { [super windowDidLoad]; } -(void) dealloc { NSLog(@"dealloc of MyOpenGL instance.\n"); // [[NSNotificationCenter defaultCenter] removeObserver: self]; [super dealloc]; } -(void) closeMyOpenGL: (MyDocument *) md { NSLog(@"closeMyOpenGL. \n"); [self close]; } -(BOOL) windowShouldClose: (NSWindow *)sender { // p.299 of O'reilly book. Connect "Window --> file's owner" to connect the delegate outlet of the window // to MyOpenGLController. NSLog(@"x is clicked.\n"); [MyOpenGLController removeMyOpenGLControllerWithGid: [self getGid]]; return YES; } -(void) addOglComm: (NSString *)comm { [myogl addOglComm: comm by: self]; } -(void) addOglInitComm: (NSString *)comm { [myogl addOglInitComm: comm by: self]; } -(void) output: (NSString *)msg { [mymessage setStringValue: msg]; } @end