title: Trying to texture a sphere using shaders in OpenGL
body: <p>I am learning OpenGL from the book OpenGL SuperBible. I am trying to render a sphere created using the function gltMakeSphere(). I bind a texture and run useProgram(). The shaders work with a triangle using a GLBatch, but the sphere just has a green colour to it. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>void RenderScene(void)
  {
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
       modelViewMatrix.PushMatrix();
  
       modelViewMatrix.Translate(0,0,-5.0f);
       GLint locMVP = glGetUniformLocation(testShader, "mvpMatrix");
       glBindTexture(GL_TEXTURE_2D, texture1ID);
       glUniformMatrix4fv(locMVP, 1, GL_FALSE,
           transformPipeline.GetModelViewProjectionMatrix()); 
       glUseProgram(testShader);
       testBatch.Draw();
       sphereObject.Draw();   
       glutSwapBuffers();
       glutPostRedisplay();
       modelViewMatrix.PopMatrix();
  }
  </code></pre>
  
  <p>Vertex Shader</p>
  
  <pre><code>#version 130
  
  in vec4 vVertex;
  in vec2 vTexCoords;
  
  smooth out vec2 vVaryingTexCoords;
  
  void main(void) 
  { 
  vVaryingTexCoords = vTexCoords;
  gl_Position = vVertex;
  }
  </code></pre>
  
  <p>Fragment Shader</p>
  
  <pre><code>#version 130
  
  
  uniform sampler2D colorMap;
  
  out vec4 vFragColor;
  smooth in vec2 vVaryingTexCoords;
  
  
  void main(void)
  { 
      vFragColor = texture(colorMap, vVaryingTexCoords.st);
  }
  </code></pre>