User Tools

Site Tools


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.

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);


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

Other Viewports

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


And matching config could be:

Camera          = HudCamera
Size = (200, 200, 0)
RelativePosition = bottom right
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: 2022/06/27 06:33 (23 months ago) by sausage