1

我在矩形多边形上绘制纹理时遇到问题。

这是我当前的代码。

texture.bind();

        GL11.glBegin(GL11.GL_QUADS);
        GL11.glColor3d(255, 255, 255);
        //Top
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1, y1, z1);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1+width, y1, z1);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1+width, y1, z1+length);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1, y1, z1+length);
        GL11.glTexCoord3f(1, 1, 1);
        //Bottom
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1, y1+height, z1);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1+width, y1+height, z1);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1+width, y1+height, z1+length);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1, y1+height, z1+length);
        //Front
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1, y1, z1);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1+width, y1, z1);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1+width, y1+height, z1);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1, y1+height, z1);
        //Back
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1, y1, z1+length);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1+width, y1, z1+length);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1+width, y1+height, z1+length);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1, y1+height, z1+length);
        //Left side
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1, y1, z1);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1, y1, z1+length);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1, y1+height, z1+length);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1, y1+height, z1);
        //Right side
        GL11.glTexCoord2f(0,0); GL11.glVertex3f(x1+width, y1, z1);
        GL11.glTexCoord2f(0,1); GL11.glVertex3f(x1+width, y1, z1+length);
        GL11.glTexCoord2f(1,1); GL11.glVertex3f(x1+width, y1+height, z1+length);
        GL11.glTexCoord2f(1,0); GL11.glVertex3f(x1+width, y1+height, z1);
        GL11.glEnd();



它似乎并没有画出来,只是在街区周围有一个很薄的东西。有谁知道我将如何解决这个问题?

4

1 回答 1

0

纹理的尺寸是否正确?或者尝试使用 glBindTexture(GL_TEXTURE_2D, texture.getTextureID());

于 2013-07-08T22:18:01.490 回答