Java Slick Util仅为所有三个变量加载一张图片

Java Slick Util仅为所有三个变量加载一张图片,java,lwjgl,Java,Lwjgl,我正在使用slick util库为lwjgl库加载纹理。我创建了三个“纹理”变量[topTex、sideTex、bottomTex],并用三张不同的图片加载它们。在考虑了不同的可能性之后,我不知道问题可能是什么。我不断地在我的每一个变量中得到最后的图像 private static double WIDTH = 1920; private static double HEIGHT = 1080; private static double DEPTH = 1200; private static

我正在使用slick util库为lwjgl库加载纹理。我创建了三个“纹理”变量[topTex、sideTex、bottomTex],并用三张不同的图片加载它们。在考虑了不同的可能性之后,我不知道问题可能是什么。我不断地在我的每一个变量中得到最后的图像

private static double WIDTH = 1920;
private static double HEIGHT = 1080;
private static double DEPTH = 1200;
private static double SPEED = 1;

private double posx = WIDTH / 2;
private double posy = HEIGHT / 2;
private double posz = DEPTH / 2;
private double rotx = 0;
private double roty = 0;
private double rotz = 0;

private Texture topTex;
private Texture sideTex;
private Texture bottomTex;

public static void main(String[] args) {

    Program program = new Program();
    program.start();
}
private void start() {

    try {

        if (WIDTH == Toolkit.getDefaultToolkit().getScreenSize().width && HEIGHT == Toolkit.getDefaultToolkit().getScreenSize().height) { Display.setFullscreen(true); }
        else { Display.setDisplayMode(new DisplayMode((int)WIDTH, (int)HEIGHT)); }
        Display.setTitle("LWJGL Minecraft Logo");
        Display.create();
    }
    catch (LWJGLException e) {

        e.printStackTrace();
        System.exit(0);
    }

    this.initGL11();
    this.loadTop();
    this.loadSide();
    this.loadBottom();

    while (!Display.isCloseRequested()) {

        this.pollInput();
        this.render();
        Display.update();
    }

    Display.destroy();
}
private void initGL11() {

    GL11.glEnable(GL11.GL_TEXTURE_2D);               
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);          
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glViewport(0, 0, (int)WIDTH, (int)HEIGHT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, WIDTH, HEIGHT, 0, 0, -DEPTH);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
}
private void loadTop() { 

    try {

        topTex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/topTex.png"));
    }
    catch (IOException e) {

        e.printStackTrace();
        System.exit(0);
    }
}
private void loadSide() {

    try {

        sideTex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/sideTex.png"));
    }
    catch (IOException e) {

        e.printStackTrace();
        System.exit(0);
    }
}
private void loadBottom() {

    try {

        bottomTex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/bottomTex.png"));
    }
    catch (IOException e) {

        e.printStackTrace();
        System.exit(0);
    }
}
private void pollInput() {

    if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { System.exit(0); }
    if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {

        posx = WIDTH / 2;
        posy = HEIGHT / 2;
        posz = DEPTH / 2;
        rotx = 0;
        roty = 0;
        rotz = 0;
    }

    if (Keyboard.isKeyDown(Keyboard.KEY_W)) { posy = posy + SPEED; }
    if (Keyboard.isKeyDown(Keyboard.KEY_A)) { posx = posx - SPEED; }
    if (Keyboard.isKeyDown(Keyboard.KEY_S)) { posy = posy - SPEED; }
    if (Keyboard.isKeyDown(Keyboard.KEY_D)) { posx = posx + SPEED; }
    if (Keyboard.isKeyDown(Keyboard.KEY_Q)) { posz = posz - SPEED; }
    if (Keyboard.isKeyDown(Keyboard.KEY_E)) { posz = posz + SPEED; }

    if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { rotx = rotx + SPEED / 2; }
    if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { roty = roty + SPEED / 2; }
    if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { rotz = rotz + SPEED / 2; }
    }
private void render() {

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    Color.white.bind();

    GL11.glPushMatrix();

        GL11.glTranslated(posx, posy, posz);
        GL11.glRotated(rotx, 1, 0, 0);
        GL11.glRotated(roty, 0, 1, 0);
        GL11.glRotated(rotz, 0, 0, 1);
        GL11.glTranslated(-posx, -posy, -posz);

        GL11.glBegin(GL11.GL_QUADS);

            topTex.bind();
            GL11.glTexCoord2d(0, 0);
            GL11.glVertex3d(posx - 16, posy - 16, posz - 16);
            GL11.glTexCoord2d(1, 0);
            GL11.glVertex3d(posx + 16, posy - 16, posz - 16);
            GL11.glTexCoord2d(1, 1);
            GL11.glVertex3d(posx + 16, posy + 16, posz - 16);
            GL11.glTexCoord2d(0, 1);
            GL11.glVertex3d(posx - 16, posy + 16, posz - 16);
            topTex.release();

            sideTex.bind();
            GL11.glTexCoord2d(0, 0);
            GL11.glVertex3d(posx + 16, posy - 16, posz - 16);
            GL11.glTexCoord2d(1, 0);
            GL11.glVertex3d(posx + 16, posy - 16, posz + 16);
            GL11.glTexCoord2d(1, 1);
            GL11.glVertex3d(posx + 16, posy + 16, posz + 16);
            GL11.glTexCoord2d(0, 1);
            GL11.glVertex3d(posx + 16, posy + 16, posz - 16);
            sideTex.release();

        GL11.glEnd();

     GL11.glPopMatrix();
}

我对LWJGL非常陌生,但我相信对Texture.bind的调用必须在对glBegin的调用之前。每个纹理都需要一对glBegin/glEnd