I am working on a 2d scrolling shooter, everything in the gameplay is happening in one "layer", and other decorative stuff, like stars in the background, or dust/debris in the foreground are in different layers, each object has a parallax multiplier, 1.0 as default, 0.+ for slowly moving background objects and 1.+ for in front of foreground ones.
Currently the way I have everything implemented is that everything has a default non-zero velocity (even static non-moving objects) accounted just for scrolling, which I would rather change, to take advantage of viewport, which in my understanding would be a better thing to serve as camera.
Using the viewport would be very straightforward if there is no fake depth added by parallax layers.
I am not sure how expensive it is to call sf::View.SetViewport(), depending on that I am thinking about doing one of the following:
1. if not expensive at all: for every object with a non-default parallax multiplier, during the render I set the viewport according to the objects parallax multiplier and when done set it back to default (there around 500-800 objects with parallax multipliers that need to be drawn each frame)
2. if it is somewhat expensive instead of using any random float 1.f-3.f for parallax multiplier I would instead use a few 10-20 "layers", each with its own parallax multiplier, and objects on the same layer will be grouped together (at least as a bunch of pointers to each on the same layer to be used in the same loop when they are rendered) so the viewport is only set once for each layer.
3. should I not use viewport at all, and go with my own implementation? (doesn't seem like a good idea..) should I do it in some other way than what I thought of above?
Your assistance on this would be much appreciated,
Thanks in advance