BitmapText not visible when render to a texture?


I’m trying to create a terminal screen in my little test game where I want to be able to print text. (Inspired by Notch/Mojang game 0x10c and the DCPU-16)

I have been looking at the render to texture example and I now have a black flattened cube that I can get a box on. However, when I try to attach a BitmapText instead it’s never shown. I must have overlooked something. Can anyone spot what it is I’m doing wrong?

Also: Is there a better way to create a text terminal in JME3? Can I manipulate the texture directly or something?

The setup code I have at the moment for the render to texture:


public Texture setupOffscreenView( AssetManager assetManager, RenderManager renderManager ) {

int w = 128,h=128;

Camera offCamera = new Camera(w, h);

offView = renderManager.createPreView(“Offscreen View”, offCamera);

offView.setClearFlags(true, true, true);


// create offscreen framebuffer

FrameBuffer offBuffer = new FrameBuffer(w, h, 1);

//setup framebuffer’s cam

offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);

offCamera.setLocation(new Vector3f(0f, 0f, -5f));

offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);

//setup framebuffer’s texture

Texture2D offTex = new Texture2D(w, h, Image.Format.RGBA8);



//setup framebuffer to use texture



//set viewport to render to offscreen framebuffer


// setup framebuffer’s scene

node = new Node();

// Works just great:

Box boxMesh = new Box(Vector3f.ZERO, 0.3f,0.3f,0.3f);

Material material = assetManager.loadMaterial(“Interface/Logo/Logo.j3m”);

Geometry offBox = new Geometry(“box”, boxMesh);




// Not shown:

BitmapFont fnt = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

BitmapText txt = new BitmapText(fnt, false);





txt.setLocalTranslation( Vector3f.ZERO );

node.attachChild( txt );



return offTex;



Nifty would be the obvious solution, I seem to remember it even has a console control.

Failing that you could use either BitmapText or ImagePainter…

I haven’t been able to get BitmapText to work.

Will take a look at that ImagePainter thingy.

Nifty might work, but it feels a bit overkill to use it just for a text terminal. But will take a quick look at it none the less.


Yeah, there is a nifty control ‘nifty-console’. Like zarch said nifty seems to be the approach.

But actually the ‘nifty-console’ control fails; failing text selecting, focus losing etc; still some work to do :slight_smile:

Currently playing around with this, and it looks promising. With some work and a bit of luck I might even be able to support programmable font characters like the “real” DCPU-16 does. :slight_smile:

Haven’t looked at Nifty yet. But having text selecting and focus and what not is not needed here, as all I want is to write some text on to a texture.

That’s ImagePainter. It’s not properly integrated into the core though due to some…complications…

Thanks, will try it out.

Actually the bitmap text works fine in texturerenderer, the whole gui i use is renderd to a texture and overlayed over the main scene, and I heavly use bitmaptext

I went with the route I started yesterday using the code I linked to. It didn’t take long until I had letters all over the screen. It was fun coding it. :slight_smile:

It even responds to keypresses! Now to decide if I should write my own simple and not very realistic CPU architecture, for the lols, or if I should steal borrow the DCPU specs from 0x10c.

Thanks for the help and suggestions!

1 Like