ITextSceneNode and setViewPort

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
tehsilly
Posts: 6
Joined: Wed Mar 11, 2009 1:46 am

ITextSceneNode and setViewPort

Post by tehsilly »

Probably doing something pretty dumb here, but bear with me please.

I'm trying to render an ITextSceneNode in a viewport that's smaller than the full resolution of the window.

When I render an ITextSceneNode without calling setViewPort, it works perfectly and renders where I expect it to. However, if I call setViewPort first, the text renders in an unexpected location. I am rendering a billboard as well, and that renders where I expect.

Anyone able to let me know what's going on here?

Here are some screenshots of what I'm getting.
Without the setViewPort call:
Image

With the setViewPort call (I set the text to white because it shows up more clearly here; I would very much like the text to be in the white square):
Image

The offending line is commented out in the following code.

Code: Select all

	IBillboardSceneNode * bnode = smgr->addBillboardSceneNode(
		0,dimension2d<f32>(32,32),core::vector3df(0,0,10));
	bnode->setMaterialFlag(video::EMF_LIGHTING, false);
	bnode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
	bnode->setMaterialTexture(0, driver->getTexture("../media/textures/waypoint.png"));

	smgr->addTextSceneNode(guienv->getBuiltInFont(),
		L"TEST",
		video::SColor(255,255,255,255), bnode);

	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));
		//driver->setViewPort(rect<s32>(0,0,640/2,480/2));
		smgr->drawAll();
		driver->endScene();
	}
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Seems to have been scaled twice...
tehsilly
Posts: 6
Joined: Wed Mar 11, 2009 1:46 am

Post by tehsilly »

Yep :(
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Bug added to tracker so it doesn't get lost.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, found the actual reason, but I'm not sure how to solve it. The problem is not a double scale, but a wrong position calculation. The text node is rendered as 2D, but gets its position from the 3d coords of the scene node. When using a viewport, the conversion from 3d position to screen coord returns an absolute screen position. When rendering directly at this position, the viewport is still applied and the text is rendered too far to the outsides (in this case at w/4,h/4 instead of w/2,h/2). When disabling the viewport and rendering at the position, this would work again. But I guess that we need to change the screen coord calculation to return proper coords for rendering into the actual viewport. Not sure what will break by this, though.
Any comment appreciated.
Post Reply