Commits

Cliff Biffle  committed 7472722

Parameterized the renders, and renderAction, over the depth field.

  • Participants
  • Parent commits fe74e9d

Comments (0)

Files changed (2)

File KVDepthView.h

   GLfloat spin;
   
   GLfloat depthTable[2048];
-  
-  void (^renderAction)();
 }
 
 @property(retain) NSMutableData *rawDepthField;
-@property(copy) void (^renderAction)();
+@property(copy) void (^renderAction)(NSData *);
 @property(assign) BOOL frozen;
 @property(assign, nonatomic) BOOL lightsOn;
 

File KVDepthView.m

 - (void) updateModelView;
 
 - (void) computeLinearDepthField: (NSMutableData *)output;
-- (void) drawDepthFieldAsPoints;
-- (void) drawDepthFieldAsCards;
-- (void) drawDepthFieldAsMesh;
-- (void) drawDepthFieldAsQuadsUsingMode: (GLenum)mode;
-- (void) drawDepthFieldAsTrisUsingMode: (GLenum)mode;
+- (void) drawDepthFieldAsPoints: (NSData *)field;
+- (void) drawDepthFieldAsCards: (NSData *)field;
+- (void) drawDepthFieldAsMesh: (NSData *)field;
+- (void) drawDepthFieldAsQuads: (NSData *)field usingMode: (GLenum)mode;
+- (void) drawDepthFieldAsTris: (NSData *)field usingMode: (GLenum)mode;
 @end
 
 @implementation KVDepthView
   
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
-  (self.renderAction)();
+  (self.renderAction)(linearDepthField);
   
   [[self openGLContext] flushBuffer];
 }
 #pragma mark --- Actions ---
 
 - (IBAction) selectPointCloudRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsPoints]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsPoints: field]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectMeshRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsMesh]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsMesh: field]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectCardCloudRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsCards]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsCards: field]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectFilledQuadRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsQuadsUsingMode: GL_FILL]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsQuads: field usingMode: GL_FILL]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectMeshedQuadRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsQuadsUsingMode: GL_LINE]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsQuads: field usingMode: GL_LINE]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectFilledTriRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsTrisUsingMode: GL_FILL]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsTris: field usingMode: GL_FILL]; };
   [self setNeedsDisplay: YES];
 }
 
 - (IBAction) selectMeshedTriRenderer: sender {
-  self.renderAction = ^{ [self drawDepthFieldAsTrisUsingMode: GL_LINE]; };
+  self.renderAction = ^(NSData *field){ [self drawDepthFieldAsTris: field usingMode: GL_LINE]; };
   [self setNeedsDisplay: YES];
 }
 
 	cross_product(&a, &b, out);
 }
 
-- (void) drawDepthFieldAsTrisUsingMode: (GLenum)mode {
+- (void) drawDepthFieldAsTris: (NSData *)field usingMode: (GLenum)mode {
   /*
    * Theory: each horizontal raster row of the image is converted to a
    * triangle strip, using the simplest possible method:
    */
   axes();
   
-  const GLfloat *depths = [linearDepthField bytes];
+  const GLfloat *depths = [field bytes];
   vec3f_t normal;
   
   glPolygonMode(GL_FRONT, mode);
   }
 }
 
-- (void) drawDepthFieldAsQuadsUsingMode: (GLenum)mode {
+- (void) drawDepthFieldAsQuads: (NSData *)field usingMode: (GLenum)mode {
   axes();
   
-  const GLfloat *depths = [linearDepthField bytes];
+  const GLfloat *depths = [field bytes];
   vec3f_t normal;
 
   glPolygonMode(GL_FRONT, mode);
   glEnd();
 }
 
-- (void) drawDepthFieldAsMesh {
+- (void) drawDepthFieldAsMesh: (NSData *)field {
   /*
    * Implementation note: each iteration needs only draw the top and left lines.
    */
   axes();
   
-  const GLfloat *depths = [linearDepthField bytes];
+  const GLfloat *depths = [field bytes];
   
   glBegin(GL_LINES);
   for (int y = 0; y < 479; y++) {
   glEnd();
 }
 
-- (void) drawDepthFieldAsCards {
+- (void) drawDepthFieldAsCards: (NSData *)field {
   axes();
   
-  const GLfloat *depths = [linearDepthField bytes];
+  const GLfloat *depths = [field bytes];
   
   glBegin(GL_QUADS);
   glNormal3f(0, 0, -1);
   glEnd();
 }
 
-- (void) drawDepthFieldAsPoints {
+- (void) drawDepthFieldAsPoints: (NSData *)field {
   axes();
   
-  const GLfloat *depths = [linearDepthField bytes];
+  const GLfloat *depths = [field bytes];
 
   glBegin(GL_POINTS);
   for (int y = 0; y < 480; y++) {