Saturday 24 August 2013

X and Y in Bitmap and Open GL with Java

X and Y in Bitmap and Open GL with Java

I've a problem with LWJGL and texture a quad with an char of a bitmap. I
want to display an uppercase T. The T is on the 6th row and the 5th colum.
This is X: 40, Y: 32px from the upper left corner (see
http://i.stack.imgur.com/ICkYB.jpg).
I use the following code:
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);
But LWJGL count from the lower right corner sothat a strange ASCII symbol
will be displayed.
What can I do, sothat the T will be selected?
Thanks Thomas

No comments:

Post a Comment