Split-Screen

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Split-Screen

Post by Kjell » Sat Feb 20, 2010 7:09 pm

8)

Proper split-screen using opengl32 ( no shader tricks ). Two things to pay attention to ..

- Only clear the screen before the first pass.
- Adjust the Viewport Ratio each pass to match your view.

Example is build for 640x360 resolution.

K
Attachments
Split-Screen.zip
(32.48 KiB) Downloaded 459 times

User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et » Sat Feb 20, 2010 8:00 pm

Judging from your code, please confirm -

The default App.RenderPasses is obviously one (1), in the app component, and you have (3) specified. Yet you have
if(App.CurrentRenderPass)
if(App.CurrentRenderPass == 1)
if(App.CurrentRenderPass == 2)

This signifies the need to offset the index by -1? But then, that would imply the first if(...) has a value of 0. I admit I don't have a full understanding of the render passes.
"great expectations"

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Sat Feb 20, 2010 8:03 pm

:)

Correct, the first render pass is 0. Just like when you have a Array with a length of 1, you still need to access it by Array[0] = "Value";

All that renderpasses does / means is how many times the OnBeginRenderPass + OnRender events occur per frame.

+ Screenshot of the example

K
Attachments
Split-Screen.jpg
Split-Screen.jpg (136.94 KiB) Viewed 10152 times

User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et » Sat Feb 20, 2010 8:21 pm

Oh, I think I get it now.
What the actual portion of the full screen to be cleared on each pass is determined by the elements of the array.
If that's true, then your first comment seems confusing.
"great expectations"

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Sat Feb 20, 2010 8:34 pm

:)

The ClearScreenMode flag clears the complete back-buffer regardless of the viewport settings. But I can understand your confusion .. these kind of things you just have to know I guess ( it's just the way OpenGL works ).

K

User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et » Sat Feb 20, 2010 9:01 pm

My fault! I forgot to read my own definition of App.ClearScreenMode .
I thought I was looking at a Bool.
"great expectations"

User avatar
Ats
Posts: 257
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Tue Oct 01, 2013 4:59 pm

Hi everyone, I'm back for some new little games.
Today I was playing with the split-screen method described in this topic, but I have a little problem with your exemple, Kjell.

In the application properties I changed the number of RenderPasses to 4.

In the OnBeginRenderPass, I commented what comes after "Just some camera debugging" so the cameras won't move.

And I changed the Array View like that:

0,180,320,180
320,180,640,180
0,0,320,180
320,0,640,180

Now I have four split screens. The problem is that the ones one the right (P2 and P4) have a shift in their camera position. How can I fix that ?

I provided the modified zgeproj.

Thanks for your help.
Attachments
Split-Screen.zgeproj
4 viewports, bug with a camera shift for the ports 2 and 4 :(
(4.1 KiB) Downloaded 256 times

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Tue Oct 01, 2013 5:24 pm

Hi Ats,
Ats wrote:The problem is that the ones one the right (P2 and P4) have a shift in their camera position. How can I fix that ?
The values for each viewport are X, Y, Width, Height .. so the two times you used 640 should be 320 instead ( all viewports are 320x180 ) ;)

K

User avatar
Ats
Posts: 257
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Wed Oct 02, 2013 2:41 pm

Ooooh. I though it was the coordinates of the little viewports inside the big one :oops:
Thanks for your quick response !


-

Edit:

So this morning I started playing with ZGameEditor on Android. Thanks to ZGEAndroid-debug.apk it took mere seconds to watch my stuff working on my phone, then on my Ouya. Splendid!

But the splitscreen is not working at all... I do beleive it's because of opengl32?
Is there a way to bypass that, or is it a dead end?

Thanks ;)

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Wed Oct 02, 2013 3:44 pm

Hi Ats,
Ats wrote:But the splitscreen is not working at all... I do believe it's because of opengl32?
Does your ZExternalLibrary component have the following in the BeforeInitExp property?

Code: Select all

if(ANDROID)
{
  this.ModuleName = "libGLESv1_CM.so";
}
K

User avatar
Ats
Posts: 257
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Wed Oct 02, 2013 4:11 pm

Sorry I'm quite a noob when it comes to that... So I've read through http://www.zgameeditor.org/index.php/Co ... nalLibrary

And added it like that:
http://tinypic.com/r/24gn77m/5

But the app keeps opening and closing.

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell » Wed Oct 02, 2013 5:04 pm

Hmm,

Not exactly sure what's causing the problem, but attached is a demo / version that does work properly on Android ( using a Nexus 7 at least ).

K
Attachments
Demo.zgeproj
(2.23 KiB) Downloaded 268 times
Demo.jpg
Demo.jpg (71.34 KiB) Viewed 8632 times

User avatar
Ats
Posts: 257
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats » Wed Oct 02, 2013 10:31 pm

Ok... So after A LOT of tries, I finaly discovered that the dat file with a ZExternalLibrary can only be exported using Windows.

I was on linux, running ZGE with Wine. That method can compile exe file without problems, and exporting dat file too. But with the addition of ZExternalLibrary opengl32, the exported dat don't work at all.

Anyway, thanks for your help Kjell, I discovered new ways to add components by watching your example.

Edit: Now, no dat file exported from ZGE under linux/wine are working. Weird but never mind...

Edit 2: I was working with ZGE 3.1b but had ZGEAndroid-debug.apk 3.0 installed on my Android... Now everything is good.
Thanks Kjell !

Post Reply