Welcome! Log In Create A New Profile

Advanced

How to do a split screen ?

Posted by tchagui 
How to do a split screen ?
May 18, 2013 10:26PM
Hello,

I would like make another " Kurushi Wii " with two players and a split screen :-) I use GX/GRRLIB but I don't find how to initialize this split screen.
Somebody knows how to initialize a split screen ? or somebody has a link ? an example ?
Thanks :-)
Re: How to do a split screen ?
May 19, 2013 12:56PM
Sorry, I don't know how it's done using GRRLIB.

In Wire3D you simply do a 'SetViewport(left, right, top, bottom)' on the Camera to render to a rectangle on screen defined by the given values (ranging [0,1]).

In GX, you have to use GX_SetViewport/GX_SetViewportJitter and GX_SetScissor to set it up.
Re: How to do a split screen ?
May 19, 2013 04:14PM
Hello Antibyte,
Thank you for your answer. I will try your solution :-)
Re: How to do a split screen ?
May 20, 2013 02:07AM
I think you will have to set the Viewport then draw some stuff. then set the viewport for the second player and draw some more stuff from the second players point of view. At least thats how I think it works.
Re: How to do a split screen ?
May 20, 2013 11:59AM
Hello Owen,
Thank you for your answer too. I will post the result when it runs :-)

Another games after Newo Asteroids ?
Re: How to do a split screen ?
May 20, 2013 03:21PM
cool, right now I'm kinda stuck on the code for implementing online leader boards into NewoAsteroids. But I have started a multiplayer party game (probably zombies or like super mario war) and a long overdue update of NewoShooter with extra levels.
Re: How to do a split screen ?
August 12, 2013 10:48PM
Hello Antibyte, Owen,

It's ok. My splitscreen runs :-) Your ideas are good !
Here's how it's done :

// screen n°1 : left screen
GRRLIB_Camera3dSettings(camera1[0],camera1[1],camera1[2], 0.0f,1.0f,0.0f, 0.0f, 0.0f, 0.0f );
GX_SetViewport(0.0f, 0.0f, rmode->fbWidth / 2 , rmode->efbHeight, 0.0f, 1.0f);
GX_SetScissor (0, 0, rmode->fbWidth / 2 , rmode->efbHeight);
GRRLIB_3dMode(0.1f,1000,45, true, false);
Draw_SkyBox();
Texture_Apply(idtexture,true);
Draw_Box();	

// screen n°2 : right screen
GRRLIB_Camera3dSettings(camera2[0],camera2[1],camera2[2],0.0f,1.0f,0.0f,0.0f,	0.0f,	0.0f	);
GX_SetViewport(rmode->fbWidth / 2, 0.0f, rmode->fbWidth / 2 , rmode->efbHeight, 0.0f, 1.0f);
GX_SetScissor (rmode->fbWidth / 2, 0, rmode->fbWidth / 2 , rmode->efbHeight);
GRRLIB_3dMode(0.1f,1000,45, true, false);
Draw_SkyBox();
Texture_Apply(idtexture,true);
Draw_Box();

It's the result : (20fps with Dolphin - 50fps with the Wii)
Re: How to do a split screen ?
August 12, 2013 11:42PM
cool.

Tips for increasing speed;
store the screen centre value in a variable at the start of the program. screen_center = (rmode->fbWidth * 0.5f );
Do not use a loop to draw your boxes. It is often faster to hardcode the vertex positions for things you draw often.
Re: How to do a split screen ?
August 13, 2013 07:04AM
I was experimenting with drawing a view then taking a screenshot, then moving the camera and taking another screen shot but unfortunately you cannot move the camera after you start drawing the frame. Here is some code that you can experiment with;



	guVector center={0,0,0};

	float screen_width = rmode->fbWidth; float screen_height = rmode->efbHeight;
	float screen_center_x = screen_width*0.5f; float screen_center_y = screen_height*0.5f;
	
	GRRLIB_texImg *blank_tex, *blank_tex2;  //game pattern
	blank_tex=GRRLIB_CreateEmptyTexture(640,480);
	blank_tex2=GRRLIB_CreateEmptyTexture(640,480);
	
	while(1) {
		game_updatebuttons();		
		GRRLIB_Camera3dSettings( -5, 250, 5,  0,1,0,	5, 5, 5 ); 		
	
		draw_circle2( center, colour_alpha(GRRLIB_RED, circle_size), 5 ); //fading center

		GRRLIB_Screen2Texture( 0,0, blank_tex, false);
		
		GRRLIB_Camera3dSettings( -2500, 50, 5,  0,1,0,	5000, 5, 5 ); //does not work

		draw_circle2( center, colour_alpha(GRRLIB_YELLOW, circle_size), 50 ); 
		
		GRRLIB_Screen2Texture( 0,0, blank_tex2, false);
		
		engine_2d(); //print text

		GRRLIB_DrawImg(0,0,blank_tex, 0,0.5f,0.5f, GRRLIB_WHITE);
		GRRLIB_DrawImg(screen_center_x,0,blank_tex2, 0,0.5f,0.5f, GRRLIB_WHITE);

		engine_2d(); //print text
		
		GRRLIB_Render();
	}
	

Re: How to do a split screen ?
August 13, 2013 09:17AM
Quote
owen
It is often faster to hardcode the vertex positions for things you draw often.

If you draw things often, you should not use hardcoded vertex positions, since this cannot utilize the Wii's vertex cache. You should use vertex buffers (i.e. GX_SetArray() ) instead, they are faster.

Quote
owen
I was experimenting with drawing a view then taking a screenshot, then moving the camera and taking another screen shot but unfortunately you cannot move the camera after you start drawing the frame.

You can move the camera anytime by changing the view matrix. You have to calculate the Model * View matrix for each draw call anyways (unless your objects use the same world transformation).
Re: How to do a split screen ?
August 13, 2013 02:19PM
@antibyte I still have not figured out how that vertex array works!

I am trying to move the view two times in a single frame. Taking a screen shot each time. That's what the code above is doing but the second screenshot does not receive new camera positions. I am trying to avoid drawing the world twice.
Re: How to do a split screen ?
August 14, 2013 10:07AM
Quote
owen
@antibyte I still have not figured out how that vertex array works!

Come on, Owen. We have been through this! You're a smart guy and you have all the info, I bet you didn't really try. :)

Quote
owen
I am trying to move the view two times in a single frame. Taking a screen shot each time. That's what the code above is doing but the second screenshot does not receive new camera positions. I am trying to avoid drawing the world twice.

As you know I am not using GRRLIB. But I had a quick look and noticed that GRRLIB_Camera3dSettings() only sets global (non GX) camera vars, which are then used with guLookAt() (as well as other GX state being set) in GRRLIB_3dMode().

Have a look, you can easily work around that. But it's still a mess. I know a lot of people use it, but GRRLIB isn't suitable for complex 3D applications at all.
Re: How to do a split screen ?
August 14, 2013 05:34PM
@antibyte I tried switching the 3d mode after moving the camera. it still didn't work Hopefully @tchagui will have better luck experimenting with it.
Re: How to do a split screen ?
August 15, 2013 12:07AM
Hello
Quote
owen
GRRLIB_Camera3dSettings( -2500, 50, 5, 0,1,0, 5000, 5, 5 ); //does not work
sqrt(2500*2500+50*50+5*5) is a very big value.
What is your 'near' value and 'far' value ? Are your sure that your object is visible ? The object is in the cone of view ?
Re: How to do a split screen ?
August 15, 2013 12:58AM
@tchagui. Yes, I am sure its visible. I tried many combinations but never got the camera to look at something else other than the direction it was originally set to look. I even changed the 3dmode a several times. I suggest u set up a similar test for yourself. If you can get it to work it will save u from drawing twice.

Neoflash has a compo in progress as well.
Sorry, only registered users may post in this forum.

Click here to login