Source

kinect-viewer / KVDepthView.m

Diff from to

File KVDepthView.m

 - (void) updateProjectionWithOffset: (float) offset;
 - (void) updateModelViewWithOffset: (float) offset;
 - (void) updateTextureMatrix;
-- (GLuint) loadShaderOfType: (GLenum) type fromFiles: (NSArray *) names;
 
 @property(assign, nonatomic) BOOL updateQueued;
 - (void) requestUpdateFromBackgroundThread;
 - (void) markAsDirty;
 
-@property GLuint program;
-@property GLuint textureEnableUniform;
-
 @end
 
 @implementation KVDepthView
 #pragma mark --- Properties ---
 
-@synthesize program;
-@synthesize textureEnableUniform;
 @synthesize updateQueued;
 
 @synthesize textured;
 #pragma mark --- GL Stuff ---
 
 - (void) prepareOpenGL {
-  GLint vertexShader = [self loadShaderOfType: GL_VERTEX_SHADER
-                                    fromFiles: [NSArray arrayWithObject: @"main"]];
-  
-  GLint fragmentShader = [self loadShaderOfType: GL_FRAGMENT_SHADER
-                                      fromFiles: [NSArray arrayWithObjects: @"lighting", @"main", nil]];
-  
-  program = glCreateProgram();
-  glAttachShader(program, vertexShader);
-  glAttachShader(program, fragmentShader);
-  glLinkProgram(program);
-  glUseProgram(program);
-  
   // Sync to vertical blank.
   GLint swapInterval = 1;
   [[self openGLContext] setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval];
   glEnable(GL_COLOR_MATERIAL);
   
   glClearColor(0.3f, 0, 0.5f, 0);
-  
-  GLint depthUniform = glGetUniformLocation(program, "depthTex");
-  glUniform1i(depthUniform, 0);
-
-  GLint colorUniform = glGetUniformLocation(program, "colorTex");
-  glUniform1i(colorUniform, 1);
-  
-  textureEnableUniform = glGetUniformLocation(program, "useTextureFromCamera");
-  glUniform1i(textureEnableUniform, 1);
 
   [self resetCamera];
   [renderer initGL];
   [self resizeGL];
   [self updateTextureMatrix];
   
-  glUniform1i(textureEnableUniform, textured);
-    
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
   if (self.anaglyph) {
   self.updateQueued = NO;
 }
 
-- (GLuint) loadShaderOfType: (GLenum) type fromFiles: (NSArray *) names {
-  NSString *extension;
-  if (type == GL_VERTEX_SHADER) {
-    extension = @"vs";
-  } else if (type == GL_FRAGMENT_SHADER) {
-    extension = @"fs";
-  } else if (type == GL_GEOMETRY_SHADER_EXT) {
-    extension = @"gs";
-  } else {
-    @throw [NSException exceptionWithName: @"KVContractError" reason: @"Bad value for shader type" userInfo: nil];
-  }
-
-  const char *sources[[names count]];
-  GLint lengths[[names count]];
-  int i = 0;
-  for (NSString *name in names) {
-    NSData *source = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource: name ofType: extension]];
-    sources[i] = [source bytes];
-    lengths[i] = (GLint) [source length];
-    i++;
-  }
-  
-  GLuint shader = glCreateShader(type);
-  glShaderSource(shader, i, &sources[0], &lengths[0]);
-  glCompileShader(shader);
-  
-  return shader;
-}
-
 - (void) requestUpdateFromBackgroundThread {
   @synchronized (self) {
     if (!self.updateQueued) {