-2
バックグラウンドのないスプライトのレンダリング方法は?私はスプライト全体をレンダリングすることができますが、背景を無視したいです。私はそれが可能であることを知っている、私は脛骨でそのようなレンダリングを見たので。脛骨のスプライトはピンクの背景色をしていますが、これは無視されます。
スプライト:LWJGL、Slick Util、背景のない2dレンダリングスプライト
public class Sprite {
private Texture texture;
private float sx;
private float sy;
private String extension;
private String path;
/**
*
* @param sx
* @param sy
* @param extension
* @param path
*/
public Sprite(float sx, float sy, String extension, String path) {
this.sx = sx;
this.sy = sy;
this.extension = extension;
this.path = path;
}
public void render() {
try {
initTexture();
} catch (Exception e) {
System.out.println(e.toString());
}
Color.white.bind();
texture.bind();
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(0, 1);
glVertex2f(0, texture.getTextureHeight()*2);
glTexCoord2f(1, 1);
glVertex2f(texture.getTextureWidth()*2, texture.getTextureHeight()*2);
glTexCoord2f(1, 0);
glVertex2f(texture.getTextureWidth()*2, 0);
glEnd();
}
public float getSx() {
return sx;
}
public void setSx(float sx) {
this.sx = sx;
}
public float getSy() {
return sy;
}
public void setSy(float sy) {
this.sy = sy;
}
public void initTexture() throws Exception {
texture = TextureLoader.getTexture(extension, ResourceLoader.getResourceAsStream(path));
}
}