【发布时间】:2012-08-09 10:14:20
【问题描述】:
我使用 JOGL 渲染图像,使用 Texture 对象,但是它被颠倒渲染(图片:http://puu.sh/Q2QT)。任何建议都会很棒,代码如下:
private void renderImage(GL2 gl, String filename, int width, int height) {
Texture texture = null;
try {
texture = TextureIO.newTexture(new File(this.getClass().getResource(filename).toURI()), true);
}
catch (URISyntaxException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
int left = 0;
int top = 0;
texture.enable(gl);
texture.bind(gl);
gl.glBegin(GL2.GL_POLYGON);
gl.glTexCoord2d(0, 0);
gl.glVertex2d(left, top);
gl.glTexCoord2d(1, 0);
gl.glVertex2d(left + width, top);
gl.glTexCoord2d(1, 1);
gl.glVertex2d(left + width, top + height);
gl.glTexCoord2d(0, 1);
gl.glVertex2d(left, top + height);
gl.glEnd();
gl.glFlush();
texture.disable(gl);
texture.destroy(gl);
}
【问题讨论】: