次の方法で2つの画像をブレンドしようとしています:
イメージ 1 はベース イメージとして描画する必要があります。画像 2 は、画像 1 の上に描画する必要があります。画像 2 が透明でない場合は、画像 1 の内容を置き換える必要があります (ブレンドではなく、そこにあるものを上書きします)。画像 2 が透明なところはどこでも、画像 1 が透けて見えるはずです。次のコードでこれを実行しようとしましたが、明らかにブレンディングで何か間違ったことをしています。
gl.glEnable(GL.GL_BLEND);
if (iconTexture1 != null)
{
gl.glEnable(GL.GL_TEXTURE_2D);
iconTexture1.bind();
double red = (double) fillColor.getRed() / 255.0;
double green = (double) fillColor.getGreen() / 255.0;
double blue = (double) fillColor.getBlue() / 255.0;
gl.glColor4d(red, green, blue, this.getOpacity());
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
TextureCoords texCoords = iconTexture1.getImageTexCoords();
gl.glScaled(width, height, 1d);
dc.drawUnitQuad(texCoords);
}
if (iconTexture2 != null)
{
gl.glEnable(GL.GL_TEXTURE_2D);
iconTexture2.bind();
// image2 is all white, so color it here
gl.glColor4d(1d, 0d, 0d, 1d);
// TODO: What blend function should I be using here to allow image 2 to overwrite what is already there?
TextureCoords texCoords = iconTexture2.getImageTexCoords();
gl.glScaled(width, height, 1d);
dc.drawUnitQuad(texCoords);
}
これを正しく機能させるための助けをいただければ幸いです。ありがとう。
ジェフ