SFML community forums
Help => Window => Topic started by: crbn-hash on May 01, 2020, 05:49:29 pm
-
I'm looking to display a train track that extends horizonally out of the window. I would like to display the track as wrapping, and thus be able to scroll up and down to view the full length of the track - instead of including logic that would break the track up as it is rendered.
I would think that I could define a second view which contained the track outside the window, and then set a viewport stacked under the default view:
View view1 = getDefaultView(); //contains first portion of track
View view2(offscreen track x, offscreen track y); //contains second portion of track
view2.setViewport( 0 , offset from view1.y); //display second portion of track underneath first portion
//scroll down to view this portion
I've consulted:
https://en.sfml-dev.org/forums/index.php?topic=11526.msg80208#msg80208
https://en.sfml-dev.org/forums/index.php?topic=23574.0
and a few other threads to no avail.
Thanks for any input!
-
I must admit that I don't fully understand the problem you have.
Is the train a single image that is just too large to store in a single texture?
-
The train track length will be dynamic and rendered based on different map files that are fed to the program, so I can't assume it will fit in the initial window ie.
window with tracks extending outside of it
_______________________
|====================================================
| |
| |
| |
|______________________|
versus
_______________________
| ================ |
| ================ |
| ================ |
| ====== |
|______________________|
-
You could just draw it all; it allows you to draw outside of the window (it'll be clipped).
To scroll, either move the drawing or the view (that is used to draw it).
-
Right! But I would like to scroll vertically instead of horizontally. Moving the drawing everytime it hit the window limits would be a lot of extra logic.
-
You mean every now and again show it? If so, moving it seems simple :p You could just position it using the mod approach.