Commits

Cliff Biffle committed b22e416

The background depth buffer is now default, and the foreground buffer goes unused except when foreground separation is enabled. This obviates clearing the buffers on mode changes.

  • Participants
  • Parent commits 0bf8cfa

Comments (0)

Files changed (1)

   
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
-  if (separateForeground) (self.renderAction)(backgroundDepthField);
-  (self.renderAction)(foregroundDepthField);
+  (self.renderAction)(backgroundDepthField);
+  if (separateForeground) (self.renderAction)(foregroundDepthField);
   
   [[self openGLContext] flushBuffer];
 }
 - (void) depthFieldUpdated: (KFKinect *)kinect {
   if (!self.frozen) {
     if (separateForeground) {
-     [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat x, GLfloat y){ return fmaxf(x,y); }]; 
+      [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat x, GLfloat y){ return fmaxf(x,y); }]; 
+      [self computeLinearDepthField: foregroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
+    } else {
+      [self computeLinearDepthField: backgroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
     }
-    [self computeLinearDepthField: foregroundDepthField andFoldUsing: ^(GLfloat _, GLfloat y){ return y; }];
     [self setNeedsDisplay: YES];
   }
 }
 - (IBAction) toggleBackgroundBuffer: sender {
   self.separateForeground = !self.separateForeground;
   [sender setState: self.separateForeground? NSOnState : NSOffState];
-  memset([backgroundDepthField mutableBytes], 0, 640 * 480 * sizeof(GLfloat));
 }
 
 @end