So I’m trying to extract a sub image from a main image and display it. I’m not to sure on how I’m meant to achieve it though.
public void init() {//load the texture
try {
level = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("images/test_tiles.png"));
}
catch (IOException e) {
e.printStackTrace();
}
}
public void render(int img_x, int img_y, int px, int py, int pw, int ph) {
Color.white.bind();
level.bind();
FloatBuffer winZ= BufferUtils.createFloatBuffer(32*32);
GL11.glTexSubImage2D(1, 0, px, py, pw, ph, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, winZ);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex2f(img_x,img_y);
GL11.glTexCoord2f(1,0);
GL11.glVertex2f(img_x+level.getTextureWidth(),img_y);
GL11.glTexCoord2f(1,1);
GL11.glVertex2f(img_x+level.getTextureWidth(),img_y+level.getTextureHeight());
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(img_x,img_y+level.getTextureHeight());
GL11.glEnd();
}
If someone could tell me what I’m doing wrong and point me in the right direction i’d be most thankful.
Also please take into consideration that i’ve spent a good 2 days trying to nut this out using java and trying several techniques so it’s not as if i’m being lazy and getting others to do the dirty work for me ![]()