[BACK]Return to MyOpenGLController.m CVS log [TXT][DIR] Up to [local] / OpenXM / src / cfep

Diff for /OpenXM/src/cfep/MyOpenGLController.m between version 1.1 and 1.4

version 1.1, 2006/03/03 23:31:12 version 1.4, 2018/10/18 04:59:45
Line 9 
Line 9 
 #import "MyOpenGLController.h"  #import "MyOpenGLController.h"
   
 // MyOpenGL window id (gid) is an indeger.  // MyOpenGL window id (gid) is an indeger.
 static MyOpenGLController *oglWindow[GID_MAX];  // gid --> MyOpenGLController instance.  static MyOpenGLController *oglWindow[MY_GID_MAX];  // gid --> MyOpenGLController instance.
 static MyDocument *oglParent[GID_MAX];           // gid --> parent MyDocument.  static MyDocument *oglParent[MY_GID_MAX];           // gid --> parent MyDocument.
 static int MyOpenGLControllerInitialized = 0;  static int MyOpenGLControllerInitialized = 0;
 static int Gid=0;  static int Gid=0;
   
Line 19  static int Gid=0;
Line 19  static int Gid=0;
 +(void) initMyOpenGLController {  +(void) initMyOpenGLController {
   int i;    int i;
   if (MyOpenGLControllerInitialized) return;    if (MyOpenGLControllerInitialized) return;
   for (i=0; i<GID_MAX; i++) { oglWindow[i] = nil; oglParent[i] = nil; }    for (i=0; i<MY_GID_MAX; i++) { oglWindow[i] = nil; oglParent[i] = nil; }
   MyOpenGLControllerInitialized = 1;    MyOpenGLControllerInitialized = 1;
 }  }
 +(MyOpenGLController *)getOglWindow: (int) tid {  +(MyOpenGLController *)getOglWindow: (int) tid {
Line 31  static int Gid=0;
Line 31  static int Gid=0;
   
 +(int) myOpenGLControllerOwnedBy: (MyDocument *) owner with: (int) tid {  +(int) myOpenGLControllerOwnedBy: (MyDocument *) owner with: (int) tid {
    MyOpenGLController *ogl;     MyOpenGLController *ogl;
    if ((tid >= 0) && (tid <GID_MAX)) {     if ((tid >= 0) && (tid <MY_GID_MAX)) {
      if (oglWindow[tid]) return tid;       if (oglWindow[tid]) return tid;
          else {           else {
                 ogl = [[MyOpenGLController allocWithZone:[MyOpenGLController zone]] init];                  ogl = [[MyOpenGLController allocWithZone:[MyOpenGLController zone]] init];
Line 50  static int Gid=0;
Line 50  static int Gid=0;
   
    [MyOpenGLController initMyOpenGLController];     [MyOpenGLController initMyOpenGLController];
    tid = Gid;     tid = Gid;
    if (tid < GID_MAX) {     if (tid < MY_GID_MAX) {
     Gid++;      Gid++;
         return [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];          return [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];
    }else{     }else{
Line 60  static int Gid=0;
Line 60  static int Gid=0;
 +(void) removeMyOpenGLControllerOwnedBy: (MyDocument *) owner {  +(void) removeMyOpenGLControllerOwnedBy: (MyDocument *) owner {
   int i;    int i;
   [MyOpenGLController initMyOpenGLController];    [MyOpenGLController initMyOpenGLController];
   for (i=0; i<GID_MAX; i++) {    for (i=0; i<MY_GID_MAX; i++) {
     if (oglParent[i] == owner) {      if (oglParent[i] == owner) {
            [MyOpenGLController removeMyOpenGLControllerWithGid: i];             [MyOpenGLController removeMyOpenGLControllerWithGid: i];
         }          }
Line 84  static int Gid=0;
Line 84  static int Gid=0;
 */  */
   
 +(void) addOglComm:     (NSString *)comm to: (int) tid from: (MyDocument *) owner {  +(void) addOglComm:     (NSString *)comm to: (int) tid from: (MyDocument *) owner {
   if ((0<=tid) && (tid<GID_MAX)) {    if ((0<=tid) && (tid<MY_GID_MAX)) {
         if (oglWindow[tid] == nil) {          if (oglWindow[tid] == nil) {
           tid = [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];            tid = [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];
         }          }
Line 92  static int Gid=0;
Line 92  static int Gid=0;
   }else ;    }else ;
 }  }
 +(void) addOglInitComm: (NSString *)comm to: (int) tid from: (MyDocument *) owner {  +(void) addOglInitComm: (NSString *)comm to: (int) tid from: (MyDocument *) owner {
   if ((0<=tid) && (tid<GID_MAX)) {    if ((0<=tid) && (tid<MY_GID_MAX)) {
         if (oglWindow[tid] == nil) {          if (oglWindow[tid] == nil) {
           tid = [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];            tid = [MyOpenGLController myOpenGLControllerOwnedBy: owner with: tid];
         }          }
Line 115  static int Gid=0;
Line 115  static int Gid=0;
   
 -(void) windowDidLoad {  -(void) windowDidLoad {
   [super windowDidLoad];    [super windowDidLoad];
     [myogl setGid: gid];
     // [self showCount];
 }  }
   
 -(void) dealloc {  -(void) dealloc {
Line 141  static int Gid=0;
Line 143  static int Gid=0;
 -(void) addOglInitComm: (NSString *)comm {  -(void) addOglInitComm: (NSString *)comm {
   [myogl addOglInitComm: comm by: self];    [myogl addOglInitComm: comm by: self];
 }  }
   
   -(int) countOfOglComm {return [myogl countOfOglComm];}
   -(int) countOfOglInitComm {return [myogl countOfOglInitComm];}
   -(int) removeLastOfOglComm {return [myogl removeLastOfOglComm];}
   -(int) removeLastOfOglInitComm {return [myogl removeLastOfOglInitComm];}
   -(int) removeAllOfOglComm { return [myogl removeAllOfOglComm];}
   -(int) removeAllOfOglInitComm {return [myogl removeAllOfOglInitComm];}
   -(NSMutableArray *) getListOfOglComm { return [myogl getListOfOglComm];}
   -(NSMutableArray *) getListOfOglInitComm { return [myogl getListOfOglInitComm]; }
   -(void) showEyeX: (float) x Y: (float) y Z: (float) z {
     [self clearOutput];
     [self output: [NSString stringWithFormat: @"gid=%d, n=%d, position of your eye:(%1.2f,%1.2f,%1.2f), nc=%d, ni=%d",gid,[self countOfOglComm],x,y,z,[myogl getOglCommSize],[myogl getOglInitCommSize]]];
   }
   -(void) showCount {
     [self clearOutput];
     [self output: [NSString stringWithFormat: @"gid=%d, number of OpenGL commands=%d, init=%d",
                                                  gid, [self countOfOglComm], [self countOfOglInitComm]]];
   }
   -(void) clearOutput { [mymessage setBackgroundColor: [NSColor whiteColor]]; } //does it work?
 -(void) output: (NSString *)msg {  -(void) output: (NSString *)msg {
   [mymessage setStringValue: msg];    [mymessage setStringValue: msg];
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>