Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**********************************************************************
- *
- */
- private void updateTexture(String tex, int texTileID, String src, int srcTileID)
- {
- int texID = this.core.renderEngine.getTexture(tex);
- BufferedImage img;
- try
- {
- img = this.getImage(src);
- }
- catch(IOException e)
- {
- e.printStackTrace();
- return;
- }
- GL11.glBindTexture(3553 /* GL_TEXTURE_2D */, texID);
- int w = img.getWidth();
- int h = img.getHeight();
- int imgBuf[] = new int[w * h];
- byte byteBuf[] = new byte[16 * 16 * 4];
- img.getRGB(0, 0, w, h, imgBuf, 0, w);
- int wTiles = w / 16;
- int hTiles = h / 16;
- int sx = (srcTileID % wTiles) * 16;
- int sy = (srcTileID / hTiles) * 16;
- for(int y = 0; y < 16; ++y)
- {
- for(int x = 0; x < 16; ++x)
- {
- int spos = sx + x + ((sy + y) * w);
- int dpos = x + (y * 16);
- int a = (imgBuf[spos] >> 24) & 0xff;
- int r = (imgBuf[spos] >> 16) & 0xff;
- int g = (imgBuf[spos] >> 8) & 0xff;
- int b = imgBuf[spos] & 0xff;
- if((this.core.gameSettings != null) && this.core.gameSettings.anaglyph)
- {
- int ra = ((r * 30) + (g * 59) + (b * 11)) / 100;
- int ga = ((r * 30) + (g * 70)) / 100;
- int ba = ((r * 30) + (b * 70)) / 100;
- r = ra;
- g = ga;
- b = ba;
- }
- byteBuf[(dpos * 4) + 0] = (byte) r;
- byteBuf[(dpos * 4) + 1] = (byte) g;
- byteBuf[(dpos * 4) + 2] = (byte) b;
- byteBuf[(dpos * 4) + 3] = (byte) a;
- }
- }
- this.imageData.clear();
- this.imageData.put(byteBuf);
- this.imageData.position(0).limit(byteBuf.length);
- GL11.glTexSubImage2D(3553 /* GL_TEXTURE_2D */, 0, (texTileID % 16) * 16, (texTileID / 16) * 16, 16, 16, 6408 /* GL_RGBA */, 5121 /* GL_UNSIGNED_BYTE */, this.imageData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement