Split-Screen

Share your ZGE-development tips and techniques here!

Moderator: Moderators

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

Split-Screen

Post by Kjell »

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 1316 times
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

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: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

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 33518 times
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

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: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

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 »

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: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

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 1079 times
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

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: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

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: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

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: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

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: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

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 1075 times
Demo.jpg
Demo.jpg (71.34 KiB) Viewed 31998 times
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Post by Ats »

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