Replies: 2 comments
-
that would be really great ! I guess that we should also finish/ensure that the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Clipping will absolutely be necessary for multiple viewports. 😉 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This was actually implemented within 0.9.x by a user on the forum by extending me.Viewport: https://groups.google.com/d/msg/melonjs/caOfioYFMrw/_C7BD9_RoJIJ
Creating additional cameras should be an officially supported feature, allowing rendering of any source location of the scene to any destination location on the backbuffer.
Some thoughts to consider:
With these in mind, I would like to propose kind of a radical change to our current viewport:
viewport
vsbackbuffer
backbuffer
is the region of the screen that is finally shown to the user. It is the area defining where pixels can be drawn. On the other hand, aviewport
could be a smaller (or larger) area that renders part of the scene onto part of thebackbuffer
.viewport
that is a small part in the center of the display, but you have a border still being rendered around it (within thebackbuffer
). For example, this image of Wolfenstein 3D shows what might be analogous to a melonJSviewport
(the 3D rendering) andbackbuffer
(the border and HUD):floating
objects are only rendered to thebackbuffer
. And non-floating objects may be rendered within aviewport
, which may have its source coordinates moved, and its destination coordinates moved, and its source size adjusted, and its destination size adjusted. This gives full freedom of which parts of the scene get rendered to where on the viewport, at any scaling ratio.viewport
works like a high-level variation ofcontext.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh)
whereimg
is the scene to be rendered with the provided source and destination parameters.viewport
can obviously be rendered to thebackbuffer
. But I might also want to render aviewport
onto anotherviewport
. A spy game with a CCTV system could use this to render parts of the map to a "monitor" (viewport
1) on the map, which is in turn rendered to the main viewport (viewport
2) in thebackbuffer
. Such that I can move my spy around the map while keeping an eye on the nearby CCTV monitors to know which areas are currently safe.viewport
onto aviewport
" scenario:viewport
should be like any other object, capable of being added to the world. With the "main viewport" outside of the world, and referenced as it is today, byme.game.viewport
.Beta Was this translation helpful? Give feedback.
All reactions