draw to viewport getting clipped

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
gheft
Posts: 34
Joined: Mon Jul 30, 2007 4:11 am

draw to viewport getting clipped

Post by gheft »

Hi,
so I am trying to get a custom GUI button working similar to this compass by vitek http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=16887

problem is, I put this on a bar that scrolls across the bottom of the screen, if the button goes past the edge of the screen, it is clipped against the screen, so it gets squeezed against the side of the screen and then fills up the entire screen if it goes completely outside the screen.
I think it is driver->setViewPort(AbsoluteRect); that clips it.
So I'm trying to do this instead by setting the mesh vertices to the rectangle position but I'm not sure what to set the transforms (ETS_VIEW etc.) to, to just draw a simple rectangle mesh.
Any suggestions?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

This may help:
http://irrlicht.sourceforge.net/phpBB2/ ... 077#183077

Although the aspect ratio is wrong, you may need to change the part "setTransform(ETS_PROJECTION, ... )" to accept a projection matrix with an aspect ratio of ScreenSize.height / ScreenSize.width.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
gheft
Posts: 34
Joined: Mon Jul 30, 2007 4:11 am

Post by gheft »

yessss finally got it working, Thanks Blindside :D

heres the alternative to changing the view port

recti vp = driver->getViewPort();
recti mRect = meshRect - vector2di(vp.getWidth(),vp.getHeight())/2;

mRect.LowerRightCorner.Y *= -1;
mRect.UpperLeftCorner.Y *= -1;

Mesh.Vertices[0].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[0].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[3].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[3].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[2].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[2].Pos.Y = mRect.UpperLeftCorner.Y;
Mesh.Vertices[1].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[1].Pos.Y = mRect.UpperLeftCorner.Y;

matrix4 ProjMatrix;
ProjMatrix.buildProjectionMatrixOrthoLH(vp.getWidth(),vp.getHeight(), -100.0f, 1000.0f);
driver->setTransform(ETS_PROJECTION, ProjMatrix);
driver->setTransform(ETS_VIEW, matrix4());
driver->setTransform(ETS_WORLD, matrix4());

driver->setMaterial(Mesh.Material);
driver->drawMeshBuffer(&Mesh);
Post Reply