Commits

Cliff Biffle committed afbe1ef

CmdT can now toggle texturing again.

  • Participants
  • Parent commits 0ea4300
  • Branches shaders

Comments (0)

Files changed (2)

File KVDepthView.m

 @property GLuint vertexShader;
 @property GLuint fragmentShader;
 @property GLuint program;
+@property GLuint textureEnableUniform;
 
 @end
 
 #pragma mark --- Properties ---
 
 @synthesize vertexShader, fragmentShader, program;
+@synthesize textureEnableUniform;
 @synthesize updateQueued;
 
 @synthesize textured;
 
   GLint colorUniform = glGetUniformLocation(program, "colorTex");
   glUniform1i(colorUniform, 1);
+  
+  textureEnableUniform = glGetUniformLocation(program, "useTextureFromCamera");
+  glUniform1i(textureEnableUniform, 1);
 
   [self resetCamera];
   [renderer initGL];
 #define INTEROCULAR_DISTANCE (0.0635F/2)
 - (void) drawRect: (NSRect)dirtyRect {
   [self resizeGL];
+  
+  glUniform1i(textureEnableUniform, textured);
     
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
  
 uniform sampler2D depthTex;
 uniform sampler2D colorTex;
+uniform bool useTextureFromCamera;
 
 /*
  * Vertex Shader entry point.
     gl_FrontColor = light_vertex(normal);
   }
   
+  if (useTextureFromCamera) {
+    vec2 fovScale = vec2(1.02, 1.30);
+    vec2 skew = vec2(-0.0, -0.05) / vertex.z;
+    vec2 colorCoord = (gl_Vertex.xy * fovScale + skew) * -0.5 + 0.5;
+    gl_FrontColor = texture2D(colorTex, colorCoord);
+  }
+  
   vec4 vertexInEye = gl_Position;
 	float dist = distance(vertexInEye.xyz, vec3(0,0,0));
 	float psize = clamp(1.5 / dist * vertex.z, gl_Point.sizeMin, gl_Point.sizeMax);