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

Diff for /OpenXM/src/cfep/MyOpenGLView.m between version 1.1.1.1 and 1.6

version 1.1.1.1, 2006/03/03 23:31:12 version 1.6, 2008/11/24 07:54:04
Line 6 
Line 6 
 //  Copyright 2006 OpenXM.org. All rights reserved.  //  Copyright 2006 OpenXM.org. All rights reserved.
 //  //
   
   #import <OpenGL/OpenGL.h>
   #import <OpenGL/gl.h>
   #import <OpenGL/glu.h>
   #import <GLUT/glut.h>
   
 #import "MyOpenGLView.h"  #import "MyOpenGLView.h"
   #import "MyOpenGLController.h"
 #include "mygl.h"  #include "mygl.h"
   
   
   
 @implementation MyOpenGLView  @implementation MyOpenGLView
 -(id) initWithFrame: (NSRect) frame {  -(id) initWithFrame: (NSRect) frame {
   NSLog(@"initWithFrame\n");    NSLog(@"initWithFrame\n");
Line 20 
Line 28 
   yeye = 0.0;    yeye = 0.0;
   zeye = 2.0;    zeye = 2.0;
   initGl = 1;    initGl = 1;
     myfont = [ NSFont systemFontOfSize: 10];
   [super initWithFrame: frame];    [super initWithFrame: frame];
   if (self) {    if (self) {
     NSOpenGLPixelFormatAttribute attributes[]={      NSOpenGLPixelFormatAttribute attributes[]={
Line 36 
Line 44 
   return self;    return self;
 }  }
   
   -(void) showEyePos {[[MyOpenGLController getOglWindow: gid] showEyeX: xeye Y: yeye Z: zeye];}
 -(IBAction) setXeye: (id) sender {  -(IBAction) setXeye: (id) sender {
    xeye=([sender floatValue]-50)*0.1; initGl = 1;     xeye=([sender floatValue]-50)*0.1; initGl = 1;
    NSLog(@"xeye=%f\n",xeye);     NSLog(@"xeye=%f\n",xeye);
      [self showEyePos];
    [self setNeedsDisplay: YES];     [self setNeedsDisplay: YES];
 }  }
 -(IBAction) setYeye: (id) sender {  -(IBAction) setYeye: (id) sender {
    float y;     float y;
    y=([sender floatValue]-50)*0.1; initGl = 1;     y=([sender floatValue]-50)*0.1; initGl = 1;
    yeye=y;     yeye=y;
      [self showEyePos];
    //NSLog(@"yeye=%f\n",yeye);     //NSLog(@"yeye=%f\n",yeye);
    [self setNeedsDisplay: YES];     [self setNeedsDisplay: YES];
 }  }
Line 52 
Line 63 
    float z;     float z;
    z=([sender floatValue]-50)*0.1+2.0; initGl = 1;     z=([sender floatValue]-50)*0.1+2.0; initGl = 1;
    zeye=z;     zeye=z;
      [self showEyePos];
    //NSLog(@"zeye=%f\n",zeye);     //NSLog(@"zeye=%f\n",zeye);
    [self setNeedsDisplay: YES];     [self setNeedsDisplay: YES];
 }  }
Line 67 
Line 79 
   initGl=1;    initGl=1;
   [self setNeedsDisplay: YES];    [self setNeedsDisplay: YES];
 }  }
   -(void) setGid: (int) p{
     gid = p;
   }
 -(void) initGL {  -(void) initGL {
   // Initialization codes are here.    // Initialization codes are here.
   glClearColor(1.0,1.0,1.0,1.0);    glClearColor(1.0,1.0,1.0,1.0);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   [self drawOglInitComm];    [self drawOglInitComm];
 }  }
   -(void) setInitGL: (id) sender { initGl = 1; }
 // It was for a test.  // It was for a test.
 -(void) drawRectSimple: (NSRect) rect withColor: (double) c {  -(void) drawRectSimple: (NSRect) rect withColor: (double) c {
   glClearColor(1.0,1.0,1.0,1.0);    glClearColor(1.0,1.0,1.0,1.0);
Line 106 
Line 122 
                 if ([oc isEndGroup] == YES) oglCommSize=[oglComm count];                  if ([oc isEndGroup] == YES) oglCommSize=[oglComm count];
         }          }
         if ([oc getOpCode] == CFEPglib_flush) [self setNeedsDisplay: YES];          if ([oc getOpCode] == CFEPglib_flush) [self setNeedsDisplay: YES];
           else if ([oc getOpCode] == CFEPglFlush) [self setNeedsDisplay: YES];
         // If oc is glib_flush, then call drawRect. (Generate an event.)          // If oc is glib_flush, then call drawRect. (Generate an event.)
         // Calling [self drawOglComm] directly is not safe, because the window might not be ready.          // Calling [self drawOglComm] directly is not safe, because the window might not be ready.
    }     }
 }  }
   
   -(NSMutableArray *)getListOfOglComm { return oglComm; }
   -(NSMutableArray *)getListOfOglInitComm { return oglInitComm; }
   -(int) getOglCommSize { return oglCommSize; }
   -(int) getOglInitCommSize { return oglInitCommSize; }
   -(int) countOfOglComm { return [oglComm count]; }
   -(int) countOfOglInitComm { return [oglInitComm count];}
   -(int) removeLastOfOglComm { if ([oglComm count]>0) [oglComm removeLastObject]; [self updateOglCommSize]; return [self countOfOglComm];}
   -(int) removeLastOfOglInitComm {if ([oglInitComm count]>0) [oglInitComm removeLastObject]; [self updateOglInitCommSize]; return [self countOfOglInitComm];}
   -(int) removeAllOfOglComm { if ([oglComm count]>0) [oglComm removeAllObjects]; oglCommSize = 0; return 0; }
   -(int) removeAllOfOglInitComm {if ([oglInitComm count]>0) [oglInitComm removeAllObjects]; oglInitCommSize = 0; return 0; }
   -(void) updateOglCommSize {
     int n,i;
     MyOpenGLCommand *cc;
     n = [oglComm count];
     for (i=n-1; i>=0; i--)  {
       cc = [oglComm objectAtIndex: i];
           if ([cc isEndGroup]) { oglCommSize = i+1; return ; }
     }
     oglCommSize = 0;
   }
   -(void) updateOglInitCommSize {
     int n,i;
     MyOpenGLCommand *cc;
     n = [oglInitComm count];
     for (i=n-1; i>=0; i--)  {
       cc = [oglInitComm objectAtIndex: i];
           if ([cc isEndGroup]) { oglInitCommSize = i+1; return ; }
     }
     oglInitCommSize = 0;
   }
   
 -(void) drawOglInitComm {  -(void) drawOglInitComm {
   int i,n;    int i,n;
   MyOpenGLCommand *gc;    MyOpenGLCommand *gc;
Line 130 
Line 178 
         @synchronized(self) {          @synchronized(self) {
                 if ([oc isEndGroup] == YES) oglInitCommSize=[oglInitComm count];                  if ([oc isEndGroup] == YES) oglInitCommSize=[oglInitComm count];
         }          }
         if ([oc getOpCode] == CFEPglib_flush) { initGl = 1; [self setNeedsDisplay: YES]; }          initGl = 1;
           if ([oc getOpCode] == CFEPglib_flush) { [self setNeedsDisplay: YES]; }
           else if ([oc getOpCode] == CFEPglFlush) [self setNeedsDisplay: YES];
    }     }
 }  }
   
Line 151 
Line 201 
   case CFEPglBegin:    case CFEPglBegin:
     glBegin(p);      glBegin(p);
         break;          break;
     case CFEPglClear:
       glClear(p); break;
     case CFEPglClearColor:
       glClearColor(x,y,z,c); break;
     case CFEPglClearDepth:
       glClearDepth(x); break;
   case CFEPglColor4f:    case CFEPglColor4f:
     glColor4f(x,y,z,c); break;      glColor4f(x,y,z,c); break;
     case CFEPglDisable:
       glDisable(p); break;
     case CFEPglEnable:
       glEnable(p); break;
   case CFEPglEnd:    case CFEPglEnd:
     glEnd(); break;      glEnd(); break;
     case CFEPglFlush:
       glFlush(); [self setInitGL: nil]; [self setNeedsDisplay: YES]; break;
     case CFEPglLineStipple:
       glLineStipple(p,q); break;
     case CFEPglLineWidth:
       glLineWidth(x); break;
     case CFEPglNormal3f:
       glNormal3f(x,y,z); break;
     case CFEPglPointSize:
       glPointSize(x); break;
   case CFEPglRectf:    case CFEPglRectf:
         glRectf(x,y,z,c); break;          glRectf(x,y,z,c); break;
   case CFEPglVertex3f:    case CFEPglVertex3f:
     glVertex3f(x,y,z); break;      glVertex3f(x,y,z); break;
     case CFEPglVertex2f:
       glVertex2f(x,y); break;
   
   case CFEPglib_line:    case CFEPglib_line:
     glib_line(x,y,z,c,p); break;      glib_line(x,y,z,c,p); break;
   case CFEPglib_putpixel:    case CFEPglib_putpixel:
     glib_putpixel(x,y,p); break;      glib_putpixel(x,y,p); break;
   case CFEPglib_flush:    case CFEPglib_flush:
         [self setNeedsDisplay: YES]; break;          [self setInitGL: nil]; [self setNeedsDisplay: YES];
           // [[MyOpenGLController getOglWindow: gid] showCount];
           break;
   
   case CFEPglib3_bounding_box:    case CFEPglib3_bounding_box:
         glib3_bounding_box(x); break;          glib3_bounding_box(x); break;
Line 193 
Line 267 
 -(void) glib3_std_scene0 {  -(void) glib3_std_scene0 {
   glib3_std_scene0(xeye,yeye,zeye);    glib3_std_scene0(xeye,yeye,zeye);
 }  }
   -(void) mouseDown: (NSEvent *) theEvent {
     NSLog(@"Mouse is down\n");
   }
 @end  @end
   
 // Original glib functions  // Original glib functions

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

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