Quote: "How would I do On-Screen-Splitscreen-Multiplayer?"
Use SetCameraBounds()
I can not remember who posted this code and I take no credit for it, an example of using SetCameraBounds() to render view ports without having to render images.
// Project: MultipleViewports
// Created: 2018-04-17
// show all errors
//SetErrorMode(2)
// set window properties
SetWindowTitle( "Multiple Viewports Example" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetVSync(1)
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// Create a 3d scene
Plane = CreateObjectPlane(10,10)
RotateObjectGlobalX(Plane,90)
Ball = CreateObjectSphere(2,10,10)
SetObjectposition(Ball,0,1,0)
SetObjectColor(Ball,255,0,0,255)
Cube = CreateObjectBox(2,2,2)
SetObjectposition(Cube,3,1,0)
SetObjectColor(Cube,0,255,0,255)
Tube = CreateObjectCylinder(2,2,10)
SetObjectposition(Tube,-3,1,0)
SetObjectColor(Tube,0,0,255,255)
Cone = CreateObjectCone(2,2,10)
SetObjectposition(Cone,0,1,3)
SetObjectColor(Cone,255,0,255,255)
Angle# = 0
do
Print( "Example of multiple viewports - Useful for 3d apps or multiplayer games etc..." )
Print( "FPS: " + str(ScreenFPS(),1) )
// Update an angle so we can rotate the views
Angle# = Angle# + GetframeTime()*20
// Call update (even though there is nothing to update in this example....its good practice)
Update(GetFrameTime())
// render viewport 1
SetCameraPosition(1,5*Sin(Angle#+45),5,-5*Cos(Angle#+45))
SetCameraLookAt(1,0,1,0,0)
Render3DToArea(0,0,510,380)
// render viewport 2
SetCameraPosition(1,0,2,-5)
SetCameraLookAt(1,0,1,0,0)
Render3DToArea(514,0,1024,380)
// render viewport 3
SetCameraPosition(1,0,8,0)
SetCameraLookAt(1,0,1,0,Angle#/4)
Render3DToArea(0,768-380,510,768)
// render viewport 4
SetCameraPosition(1,8,6,0)
SetCameraLookAt(1,0,1,0,Angle#*2)
Render3DToArea(514,768-380,1024,768)
// reset the scissor so that any 2d can still be rendered
SetScissor(0,0,0,0)
// render 2d (Text and sprites etc...)
ClearDepthBuffer()
Render2DFront()
Swap()
loop
function Render3DToArea(l#,t#,r#,b#)
Fov# = GetCameraFOV(1)
Fnear# = 0.1
SetCameraRange(1,Fnear#,1000.0)
Width# = GetVirtualWidth()
Height# = GetVirtualHeight()
// Set the camera variables
rb# = Fnear#*Tan(Fov#/2)
lb# = -rb#
tb# = rb#*height#/width#
bb# = -tb#
// Now skew these figures to meet the correct area
xscale# = 2.0/(r#-l#)
yscale# = 2.0/(b#-t#)
// Apply the scale position
lb# = lb# + l#*xscale#*lb#
rb# = rb# + (Width#-r#)*xscale#*rb#
tb# = tb# + t#*yscale#*tb#
bb# = bb# + (Height#-b#)*yscale#*bb#
// Set ths screen scissor
SetScissor(l#,t#,r#,b#)
SetCameraOffCenter(1,1)
SetCameraBounds(1,lb#,rb#,tb#, bb#)
Render3D()
endfunction