Image orientation

Hi folks!

Take a look at this screenshot from my ““game””:

http://img84.imageshack.us/img84/2901/screen9fh.png

Why is the image like that? I was expecting the samurai to be on foot =D

Code that renders the image:


/**
     * Draw the sprite at the specified location
     *
     * @param x The x location at which to draw this sprite
     * @param y The y location at which to draw this sprite
     */
    public void draw(int x, int y) {
        
        GL gl = Game.getRenderer().getGL();
        
        gl.glPushMatrix();
        
        texture.bind();
        
        gl.glTranslatef(x, y, 0);
        
        gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
        
        TextureCoords coords = texture.getImageTexCoords();
        
        gl.glBegin(GL.GL_QUADS);
        {
            gl.glTexCoord2f(coords.left(), coords.bottom());
            gl.glVertex2f(0, 0);
            gl.glTexCoord2f(coords.right(), coords.bottom());
            gl.glVertex2f(0, texture.getHeight());
            gl.glTexCoord2f(coords.right(), coords.top());
            gl.glVertex2f(texture.getWidth(), texture.getHeight());
            gl.glTexCoord2f(coords.left(), coords.top());
            gl.glVertex2f(texture.getWidth(), 0);
        }
        gl.glEnd();
        
        gl.glPopMatrix();
        
    }

I think your mapping between texcoords and vertices is wrong. Try this:


            gl.glTexCoord2f(coords.left(), coords.bottom());
            gl.glVertex2f(0, 0);
            gl.glTexCoord2f(coords.left(), coords.top());
            gl.glVertex2f(0, texture.getHeight());
            gl.glTexCoord2f(coords.right(), coords.top());
            gl.glVertex2f(texture.getWidth(), texture.getHeight());
            gl.glTexCoord2f(coords.right(), coords.bottom());
            gl.glVertex2f(texture.getWidth(), 0);

x1 -> 0 -> left
y1 -> 0 -> bottom
x2 -> w -> right
y2 -> h -> top

Chris.

Now he’s upside down =D

My first try on OpenGL, so I got confused with all these coordinates… :-\

I’ve heard somewhere that OpenGL treats the Y axis in a different way, compared to swing or other layouts. Might that be the case?

Son Of Cain