| version 1.1, 2006/03/03 23:31:12 |
version 1.2, 2006/03/07 11:15:23 |
|
|
| // |
// |
| |
|
| #import "MyOpenGLView.h" |
#import "MyOpenGLView.h" |
| |
#import "MyOpenGLController.h" |
| #include "mygl.h" |
#include "mygl.h" |
| |
|
| @implementation MyOpenGLView |
@implementation MyOpenGLView |
|
|
| 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]; |
| } |
} |
|
|
| 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]; |
| } |
} |
|
|
| 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); |
|
|
| 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) countOfOglComm { return [oglComm count]; } |
| |
-(int) countOfOglInitComm { return [oglInitComm count];} |
| |
-(int) removeLastOfOglComm { if ([oglComm count]>0) [oglComm removeLastObject]; return [self countOfOglComm];} |
| |
-(int) removeLastOfOglInitComm {if ([oglInitComm count]>0) [oglInitComm removeLastObject]; return [self countOfOglInitComm];} |
| |
-(int) removeAllOfOglComm { if ([oglComm count]>0) [oglComm removeAllObjects]; return 0; } |
| |
-(int) removeAllOfOglInitComm {if ([oglInitComm count]>0) [oglInitComm removeAllObjects]; return 0; } |
| |
|
| -(void) drawOglInitComm { |
-(void) drawOglInitComm { |
| int i,n; |
int i,n; |
| MyOpenGLCommand *gc; |
MyOpenGLCommand *gc; |
|
|
| @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]; |
| } |
} |
| } |
} |
| |
|
|
|
| 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 CFEPglEnd: |
case CFEPglEnd: |
| glEnd(); break; |
glEnd(); break; |
| |
case CFEPglFlush: |
| |
glFlush(); [self setNeedsDisplay: YES]; 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: |
|
|
| 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 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; |