title: How can I rotate my image at an offset from the center using OpenGL and Java?
body: <p>Hello I am trying to rotate my image from an offset but anytime I attempt to translate something other than the center it stops rendering my image. I am fairly new to OpenGL and I understand that the way I am using it is &quot;old fashioned&quot; but I was told if I use this method I would better understand how OpenGL works.</p>
  <p>drawImage</p>
  <pre><code>    public static void drawImage(ImageResource image, float x, float y, float width, float height) {
          GL2 gl = EventListener.gl;
  
          Texture texture = image.getTexture();
  
          if(texture != null) {
              gl.glBindTexture(GL2.GL_TEXTURE_2D, texture.getTextureObject());
          }
  
          //Below is where I offset to the position I provide but when I add something to the x or y my image doesn't render
          gl.glTranslatef(x, y, 0);
          gl.glRotatef(rotation, 0, 0, 1);
  
          gl.glColor4f(red, green, blue, alpha);
          gl.glBegin(GL2.GL_QUADS);
              gl.glTexCoord2f(0, 1);
              gl.glVertex2f(-width / 2, -height / 2);
  
              gl.glTexCoord2f(1, 1);
              gl.glVertex2f(width / 2, -height / 2);
  
              gl.glTexCoord2f(1, 0);
              gl.glVertex2f(width / 2, height / 2);
  
              gl.glTexCoord2f(0, 0);
              gl.glVertex2f(-width / 2, height / 2);
          gl.glEnd();
          gl.glFlush();
  
          gl.glBindTexture(GL2.GL_TEXTURE_2D, 0);
  
          gl.glRotatef(-rotation, 0, 0, 1);
          gl.glTranslatef(-x, -y, 0);
      }
  </code></pre>
  <p>Below is the image I am rotating and I drew a circle overtop of it. The center of the image is somewhere between his arm and the rifle and I would like to offset it so that the image rotates about where his head is.</p>
  <p><a href="https://i.stack.imgur.com/web0e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/web0e.png" alt="Image to Rotate" /></a></p>