User Tools

Site Tools


en:tutorials:orxscroll:scroll_cameras_and_viewports

Scroll, Cameras and Viewports

This is a super short tutorial, more a reminder of how Cameras and Viewports are a tad different from a plain orx project.

The MainCamera and MainViewport

In a Scroll project, the MainCamera and MainViewport are created automatically. They are not created manually in the init() function like in a plain orx project.

Please be aware that this is currently changing. Creating the viewport will be the responsibility of the developer. There will be upgrade walkthrough when this change comes about.

As long as they are defined in the config file (and they come with a generated project), then they will be created when the game starts.

Getting Access

Of course you can still get access to the default ones via code using:

    orxFLOAT viewportWidth = 0;
    orxFLOAT viewportHeight = 0;
 
    orxViewport_GetSize(this->GetMainViewport(), &viewportWidth, &viewportHeight);

and…

    camera = this->GetMainCamera();
    currentZoom = orxCamera_GetZoom(camera);

Other Viewports

You can continue to create other viewports the standard way, for example:

  orxViewport_CreateFromConfig("SomeOtherViewport");
  

And matching config could be:

[HudViewport]
Camera          = HudCamera
Size = (200, 200, 0)
RelativePosition = bottom right
 
[HudCamera]
FrustumWidth  = 200
FrustumHeight = 200
FrustumFar    = 2.0
FrustumNear   = 0.0
Position      = (0.0, 0.0, -2.0)
Zoom = 0.02

That's it, nice and short.

en/tutorials/orxscroll/scroll_cameras_and_viewports.txt · Last modified: 2024/11/06 03:30 (7 weeks ago) by sausage