Renderers - Scaling

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
Hi
During my playing with Mojo2 and Shadows, Im now loking at renderers (so that i can render shadows)
Ive utilsied some of the code form the renderdemo example and now running into more issues.... these could be just me and the way i have done things previously in Mojo 1

Im used to having a fixed game resolution and scaling that to the Device Width and Height. this mean it can scale an 800*480 to any resolution (including smaller resolutions). My code scales proportionally and centers it on the device.
This has worked very well previously and still works when using canvas objects in Mojo2

Now when im using renderers, if i set my play area to 800*480, it will only render the Device Resolution (in this case 640*480). This leads to the right most play area not being rendered.

Is there anyway to Render shadows on to images larger than the resolution?

some pseudo code
Cerberus X:
        w=800
        h=480
        
        renderer=New Renderer
        renderer.SetAmbientLight( [0.1,0.1,0.1,1.0] )
        renderer.SetClearMode(1)

        ' all rendering is drawn on to img
        img = New Image(w,h,0,0)
        renderer.SetRenderTarget(img)
        
        'img gets scaled and drawn to screen
        cnvs.Scale game_scale,game_scale
        cnvs.DrawImage img,0,0
        cnvs.Flush()
i suppose the big question is.. how does everyone scale their games to Device Resolutions in mojo2. Am I doing it worng now?
 

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
OK, Ive solved the maths and it scales nicely now (but only if the Device dimensions are greater than the play area.)
Cerberus X:
        ' set up renderer
        w=800
        h=480

        renderer=New Renderer
        renderer.SetViewport( 0,0,w,h)
        renderer.SetAmbientLight( [0.1,0.1,0.1,1.0] )
        renderer.SetClearMode(1)
        
        ' image to draw shadows etc into
        img = New Image(w,h,0,0)
        renderer.SetRenderTarget(img)
and then when drawing img to the main canvas, I need to enlarge it by the scale between play area and render area

Cerberus X:
        cnvs.DrawImage img,0,0,0,DeviceWidth()/w,DeviceHeight()/h
Feel like there should be a simpler way, but happy at the moment
 

magic

Active Member
3rd Party Module Dev
3rd Party Tool Dev
Joined
Mar 5, 2018
but only if the Device dimensions are greater than the play area
I think your code should work both greater or lower dimensions
 

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
I think your code should work both greater or lower dimensions
It scales correctly, but some of the image is missing because the Renderer is as only as big as the physical resolution
 

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
*unless theres a way to make a renderer larger than the resolution
 
Top Bottom