jPCT - a 3d engine for Java > Support

blitting text and images

(1/8) > >>

here is two small and (hopefully) handy classes for blitting text and images. i'm posting them hoping they may be helpful

TexturePack packs several arbitrary sized images into a jPCT texture. it automatically layouts images and adjusts Texture size.

GLFont creates GL renderable (blittable) fonts out of awt Fonts.

in the below image, the bubble images are blitted with TexturePack and text is blitted with GLFont :)

note: these two classes use new FrameBuffer.blit(..) method in the upcoming 1.16 release

r a f t

Both classes are very useful IMHO. I like the TexturePack-thingy most, because it can help to reduce texture memory usage on lower end cards (well, it also helps on better cards, but it may not matter on those).
If i could only find the time to do that bloody game that i have in my mind and put those classes (as well as Paul's SoundManager) to use... :-\

serve youself ;D

Is texture pack needed for GLFont?  Don't suppose you have a little demo or something to look at?  I'm still kind of learning all this.

yes, GLFont uses TexturePack behind the scenes. it creates an image for each chracter and packs all these images into a texture with TexturePack

there is nothing special using it. just create a GLFont somewhere in time:

--- Code: ---GLFont glFont = GLFont.getGLFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
--- End code ---

and at the end of your game loop, after FrameBuffer.update() before FrameBuffer.display() draw any string with it:

--- Code: ---while (running) {
   // your game logic and rendering here
   glFont.blitString(frameBuffer, "this is a blitted text", x, y, Color.ORANGE);   
--- End code ---


[0] Message Index

[#] Next page

Go to full version