Page 1 of 1

Splitscreen don't work with custom rendering

Posted: Mon Feb 15, 2010 11:30 am
by MolokoTheMole
I implemented splitscreen and it seems that everything I draw myself (99% of the game) doesn't work with the viewports. It just ignores it and renders fullscreen. The only thing that renders correctly is Irrlicht stuff like DrawLine.
How would I make my stuff work with viewports?

Posted: Mon Feb 15, 2010 12:36 pm
by Virion
maybe you should show some of your code?

Posted: Mon Feb 15, 2010 6:22 pm
by hybrid
Some 2d things (such as fonts) are known to ignore the viewport. If you know more elements, or reasons why this fails, it could help to fix these bugs. But it could also be a problem with projection matrices etc.

Posted: Tue Feb 16, 2010 7:31 am
by MolokoTheMole
It doesn't work for sprites and map rendering. Don't know about fonts.

I don't really use transform matrices. I just set the vertices of sprites and tiles in map rendering. Maybe that is the problem.
Here's how I render a map for example:

Code: Select all

driver->setTransform( irr::video::ETS_WORLD, matrix4() );

	for (int i = 0; i < buffertiles.size(); i++)
	{
		if (buffertiles[i]->tileoffset > -1)
		{
			vector3df tilepos( (float)(buffertiles[i]->tileoffset % buffertilessize.Width ) * scale,
						       (float)floor( (float) (buffertiles[i]->tileoffset) / buffertilessize.Width ) * scale, 0.0f );

			Vertices[0].Pos.X = -0.0f + tilepos.X;
			Vertices[1].Pos.X =  scale * 1.0f + tilepos.X;
			Vertices[2].Pos.X = -0.0f + tilepos.X;
			Vertices[3].Pos.X =  scale * 1.0f + tilepos.X;
			Vertices[0].Pos.Y = -0.0f + tilepos.Y;
			Vertices[1].Pos.Y = -0.0f + tilepos.Y;
			Vertices[2].Pos.Y =  scale * 1.0f + tilepos.Y;
			Vertices[3].Pos.Y =  scale * 1.0f + tilepos.Y;

			cellmaterial.TextureLayer[ 0 ].Texture = buffertiles[ i ]->texture;
			if (usenormals)
				cellmaterial.TextureLayer[ 1 ].Texture = normalbuffertiles[ i ]->texture;
		
			driver->setMaterial( cellmaterial );
			driver->drawIndexedTriangleList( &Vertices[0], 4, &ind[0], 2 );
		}
	}

EDIT---------

No. I used a transform matrix instead of setting the vertices and it still doesn't work.

How does the viewport work? Is there something special that should happen before drawIndexedTriangleList?

Posted: Wed Feb 17, 2010 3:28 am
by DavidJE13

Code: Select all

driver->setTransform( irr::video::ETS_WORLD, matrix4() );
is probably the culprit here - I don't know for sure, but it would make sense that the viewport is setting the world matrix. Try saving the viewport to a rect just before calling this it and setting it back after.

Posted: Wed Feb 17, 2010 9:28 am
by MolokoTheMole
Woo!
DavidJE13: that's it. You've just won a medal :D