Source

kinect-viewer / KVRenderer.m

Diff from to

KVRenderer.m

 @property GLuint depthTexture;
 @property GLuint colorTexture;
 @property GLuint program;
-
-- (void) renderAsPointsWithOptions: (NSDictionary *) options;
+@property GLuint pointFieldVbo;
 @end
 
 @implementation KVRenderer
 @synthesize rayCastingCount, rayCastingTotal, vertexPlacementCount, vertexPlacementTotal;
 @synthesize depthTexture, colorTexture;
 @synthesize program;
+@synthesize pointFieldVbo;
 
 - init {
   if ((self = [super init])) {
   
   glEnable(GL_POINT_SPRITE);
   glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+  
+  glGenBuffers(1, &pointFieldVbo);
+  glBindBuffer(GL_ARRAY_BUFFER, pointFieldVbo);
+  glBufferData(GL_ARRAY_BUFFER, 640 * 480 * 2 * sizeof(GLfloat), points, GL_STATIC_DRAW);
+  
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glVertexPointer(2, GL_FLOAT, 0, 0);
 }
 
 - (void) setDepthSamples: (NSData *)data {
     glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, &colorImage);
   }
   
-  [self renderAsPointsWithOptions: options];
+  glColor3f(1, 1, 1);
+  glDrawArrays(GL_POINTS, 0, 640 * 480);
   
   NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];
   vertexPlacementCount++;
 
 #pragma mark --- Internals
 
-- (void) renderAsPointsWithOptions: (NSDictionary *) options {
-  glColor3f(1, 1, 1);
-  glEnableClientState(GL_VERTEX_ARRAY);
-  glVertexPointer(2, GL_FLOAT, 0, &points);
-
-  glDrawArrays(GL_POINTS, 0, 640 * 480);
-  
-  glDisableClientState(GL_VERTEX_ARRAY);
-}
-
 // We pre-fill the X and Y components with distance from the top-left
 // corner of the image.  These values never make it to the rasterizer:
 // they are merely input to the vertex shader that performs perspective