aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/detrav/gui/DetravMapTexture.java
blob: 487bdc3b1eb9ea8724b253baa1b5fc24f522f624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.detrav.gui;

import com.detrav.net.DetravProPickPacket01;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResourceManager;
import org.lwjgl.opengl.GL11;

import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * Created by wital_000 on 21.03.2016.
 */
public class DetravMapTexture extends AbstractTexture {

    private DetravProPickPacket01 packet;

    public DetravMapTexture(DetravProPickPacket01 aPacket)
    {
        packet = aPacket;
    }

    public int width = -1;
    public int height = -1;

    @Override
    public void loadTexture(IResourceManager p_110551_1_){
        this.deleteGlTexture();
        if(packet!=null)
        {
            int tId = getGlTextureId();
            if(tId <0) return;
            BufferedImage bufferedimage = packet.getImage();
            TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, false, false);
            width = bufferedimage.getWidth();
            height = bufferedimage.getHeight();
        }
        //GL11.glDrawPixels();
    }

    public int glBindTexture() {
        if (this.glTextureId < 0) return this.glTextureId;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.getGlTextureId());
        return this.glTextureId;
    }

}