Commits

Cliff Biffle  committed 0bf8cfa

Renamed depth buffers to distinguish background, foreground.

  • Participants
  • Parent commits c8d456c

Comments (0)

Files changed (2)

File KVDepthView.h

 
 @interface KVDepthView : NSOpenGLView <KFKinectDelegate> {
   NSMutableData *rawDepthField;
-  NSMutableData *linearDepthField;
   NSMutableData *backgroundDepthField;
+  NSMutableData *foregroundDepthField;
   
   camera_t camera;
   
 @property(copy) void (^renderAction)(NSData *);
 @property(assign) BOOL frozen;
 @property(assign, nonatomic) BOOL lightsOn;
-@property(nonatomic) BOOL useBackgroundBuffer;
+@property(nonatomic) BOOL separateForeground;
 
 - (void) depthFieldUpdated: (KFKinect *)kinect;
 

File KVDepthView.m

 @synthesize renderAction;
 @synthesize frozen;
 @synthesize lightsOn;
-@synthesize useBackgroundBuffer;
+@synthesize separateForeground;
 
 #pragma mark --- NSView Overrides ---
 
 - (void) awakeFromNib {
   rawDepthField = [[NSMutableData alloc] initWithBytesNoCopy: calloc(640 * 480, sizeof(uint16_t))
                                                       length: (640 * 480 * sizeof(uint16_t))];
-  linearDepthField = [[NSMutableData alloc] initWithBytesNoCopy: calloc(640 * 480, sizeof(GLfloat))
-                                                         length: (640 * 480 * sizeof(GLfloat))];
+  foregroundDepthField = [[NSMutableData alloc] initWithBytesNoCopy: calloc(640 * 480, sizeof(GLfloat))
+                                                             length: (640 * 480 * sizeof(GLfloat))];
   backgroundDepthField = [[NSMutableData alloc] initWithBytesNoCopy: calloc(640 * 480, sizeof(GLfloat))
                                                              length: (640 * 480 * sizeof(GLfloat))];
   [self buildDepthTable];
   
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
-  if (useBackgroundBuffer) (self.renderAction)(backgroundDepthField);
-  (self.renderAction)(linearDepthField);
+  if (separateForeground) (self.renderAction)(backgroundDepthField);
+  (self.renderAction)(foregroundDepthField);
   
   [[self openGLContext] flushBuffer];
 }
 
 - (void) depthFieldUpdated: (KFKinect *)kinect {
   if (!self.frozen) {
-    if (useBackgroundBuffer) {
+    if (separateForeground) {
      [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat x, GLfloat y){ return fmaxf(x,y); }]; 
     }
-    [self computeLinearDepthField: linearDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
+    [self computeLinearDepthField: foregroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
     [self setNeedsDisplay: YES];
   }
 }
 }
 
 - (IBAction) toggleBackgroundBuffer: sender {
-  self.useBackgroundBuffer = !self.useBackgroundBuffer;
-  [sender setState: self.useBackgroundBuffer? NSOnState : NSOffState];
+  self.separateForeground = !self.separateForeground;
+  [sender setState: self.separateForeground? NSOnState : NSOffState];
   memset([backgroundDepthField mutableBytes], 0, 640 * 480 * sizeof(GLfloat));
 }