Commits

Cliff Biffle committed 0ea4300

Camera RGB image is now bound to texure unit 1.

  • Participants
  • Parent commits e529285
  • Branches shaders

Comments (0)

Files changed (1)

 @property(assign, nonatomic) NSUInteger vertexPlacementCount;
 
 @property GLuint depthTexture;
+@property GLuint colorTexture;
 
 - (void) renderAsPointsWithOptions: (NSDictionary *) options;
 @end
 @implementation KVRenderer
 
 @synthesize rayCastingCount, rayCastingTotal, vertexPlacementCount, vertexPlacementTotal;
-@synthesize depthTexture;
+@synthesize depthTexture, colorTexture;
 
 - init {
   if ((self = [super init])) {
   glBindTexture(GL_TEXTURE_2D, depthTexture);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+  glGenTextures(1, &colorTexture);
+  glBindTexture(GL_TEXTURE_2D, colorTexture);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 }
 
 - (void) setDepthSamples: (NSData *)data {
   glBindTexture(GL_TEXTURE_2D, depthTexture);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, 640, 480, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, &depthImage);
   
+  glActiveTexture(GL_TEXTURE1);
+  glBindTexture(GL_TEXTURE_2D, colorTexture);
+  glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, &colorImage);
+  
   [self renderAsPointsWithOptions: options];
   
   NSTimeInterval end = [NSDate timeIntervalSinceReferenceDate];