- public static void drawSpriteSheet(Texture t, int x, int y, int width, int height, int frameXNum, int frameYNum, int frame)
- {
- int w = t.getImageWidth();
- int h = t.getImageHeight();
- int x1 = w / frameXNum;
- int y1 = h / frameYNum;
- int lx = ((frame % frameXNum) * x1) - x1;
- int ly = ((int) Math.floor(frame / frameXNum) * y1);
- int lw = x1;
- int lh = y1;
- t.bind();
- glBegin(GL_TRIANGLES);
- glTexCoord2f((lx / w) + (lw / w), ly / h);
- glVertex2i(x + width, y);
- glTexCoord2f(lx / w, ly / h);
- glVertex2i(x, y);
- glTexCoord2f(lx / w, (ly / h) + (lh / h));
- glVertex2i(x, y + height);
- glTexCoord2f(lx / w, (ly / h) + (lh / h));
- glVertex2i(x, y + height);
- glTexCoord2f((lx / w) + (lw / w), (ly / h) + (lh / h));
- glVertex2i(x + width, y + height);
- glTexCoord2f((lx / w) + (lw / w), ly / h);
- glVertex2i(x + width, y);
- glEnd();
- }
SHARE
TWEET
Untitled
a guest
Dec 26th, 2014
163
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

