Skip to content

Instantly share code, notes, and snippets.

@belak
Forked from flexd/acurrent.java
Created March 3, 2012 23:44
Show Gist options
  • Select an option

  • Save belak/1969010 to your computer and use it in GitHub Desktop.

Select an option

Save belak/1969010 to your computer and use it in GitHub Desktop.
@Override
public void draw() {
this.sprite.getTexture().bind();
//double w = this.width/32;
//double h = this.height/32; // we should do the same for height.
double row = this.sprite.getsY();
double col = this.sprite.getsX();
double h0 = 1.0 / 32 * row;
double h1 = 1.0 / 32 * (row + 1);
double w0 = 1.0 / 32 * col;
double w1 = 1.0 / 32 * (col + 1);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2d(w0, h0); // upper left
glVertex2d(x, y);
glTexCoord2d(w1, h0); // upper right
glVertex2d(x + 32, y);
glTexCoord2d(w1, h1); // bottom right
glVertex2d(x + 32, y + 32);
glTexCoord2d(w0, h1); // bottom left
glVertex2d(x, y + 32);
glEnd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment