Splitscreen don't work with custom rendering

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
MolokoTheMole
Posts: 109
Joined: Tue Jan 09, 2007 1:18 pm

Splitscreen don't work with custom rendering

Post 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?
Crimson Glory full Irrlicht game source code!
What I Do - my blog & dev log
Currently developing Link-Dead
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

maybe you should show some of your code?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
MolokoTheMole
Posts: 109
Joined: Tue Jan 09, 2007 1:18 pm

Post 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?
Crimson Glory full Irrlicht game source code!
What I Do - my blog & dev log
Currently developing Link-Dead
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post 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.
MolokoTheMole
Posts: 109
Joined: Tue Jan 09, 2007 1:18 pm

Post by MolokoTheMole »

Woo!
DavidJE13: that's it. You've just won a medal :D
Crimson Glory full Irrlicht game source code!
What I Do - my blog & dev log
Currently developing Link-Dead
Post Reply