title: Basic Texture drawing with JOGL, using a Texture object
body: <p>I'm trying to give the user of my application the ability to load an image of their choice to make the background. Loading the image via Java is no problem, but I can't get the image into a texture....I just end up with a big grey box on my GLCanvas. This is the code I have so far:</p>
  
  <pre><code>  //if there's an image to overlay, render it
      if (renderImage) {
  
          gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
  
          if (texture == null &amp;&amp; img != null) {
  
              texture = TextureIO.newTexture(img, true);
              texture.enable();
              texture.bind();
          }
  
          gl.glBegin(GL.GL_POLYGON);
          gl.glNormal3f(0,0,1);
              gl.glTexCoord2d(-texture.getWidth(), -texture.getHeight());
              gl.glVertex2d(-25, -25);
              gl.glTexCoord2d(-texture.getWidth(), texture.getHeight());
              gl.glVertex2d(canvas.getWidth(),0);
              gl.glTexCoord2d(texture.getWidth(), texture.getHeight());
              gl.glVertex2d(canvas.getWidth(), canvas.getHeight());
              gl.glTexCoord2d(texture.getWidth(), -texture.getHeight());
              gl.glVertex2d(0, canvas.getHeight());
          gl.glEnd();
          gl.glFlush();
      }
      //otherwise, render "grass"
      else {
  
          gl.glClearColor(0.0f, 0.65f, 0.0f, 0.0f);
  
          //Clear buffer and set background color to green (the "grass" on the sides of the intersection)
          gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
      }
  </code></pre>