0

LWJGL に問題があり、ビットマップの文字でクワッドをテクスチャリングします。大文字のTを表示したい。T は 6 行目の 5 列目にあります。こちらは左上からX:40、Y:32pxです。

次のコードを使用します。

GL11.glTexCoord2f((float) (Math.floor(charID / this.charsInRow) * charSize) / bitmapSize, (float) (Math.floor(charID % this.charsInRow) * charSize) / bitmapSize);
GL11.glVertex2f((charPosition * fontSize) + x, y);
GL11.glTexCoord2f((float) (Math.floor(charID / this.charsInRow) * charSize + charSize) / bitmapSize, (float) (Math.floor(charID % this.charsInRow) * charSize) / bitmapSize);
GL11.glVertex2f((charPosition * fontSize) + x + fontSize, y);
GL11.glTexCoord2f((float) (Math.floor(charID / this.charsInRow) * charSize + charSize) / bitmapSize, (float) (Math.floor(charID % this.charsInRow) * charSize + charSize) / bitmapSize);
GL11.glVertex2f((charPosition * fontSize) + x + fontSize, y + fontSize);
GL11.glTexCoord2f((float) (Math.floor(charID / this.charsInRow) * charSize) / bitmapSize, (float) (Math.floor(charID % this.charsInRow) * charSize + charSize) / bitmapSize);
GL11.glVertex2f((charPosition * fontSize) + x
                            ,y + fontSize);

しかし、LWJGL は右下から数えるので変な ASCII 記号が表示されます。

Tが選択されるようにするにはどうすればよいですか?

4

1 に答える 1

1

OpenGL の正規化されたテクスチャ座標は、左下隅 (0,0) から始まり、右上 (1,1) に進みます。あなたの質問では、グリフィに対処するために間違ったアプローチを使用しています。特に、上ではなく下から開始する必要があります。

サンプル画像から判断すると、座標はおそらく次の形式に従う必要があります。

Glyph Bottom Left: (X - <GlyphWidth>, <TextureResY> - Y - <GlyphHeight>)
Glyph Top Right:   (X,                <TextureResY> - Y                )

  ここで、X と Y はそれぞれ 40 と 32 です。

また、行と列を入れ替えたようです。

于 2013-08-24T19:54:10.210 に答える