Add Border to Viewport

@pspeed at first as I had not found a membermethod of the viewport like setBorder or similar, my first thaught was to draw some lines on my hud. But my second thaugt was that if this is a common problem there may be some fancy solution with dropshadows, titled border or something. That is why I started this topic.It may has drift a little bit of course, but i like to discuss and so it doesn’t matter much to me.

@remy_vd that’s look like something I want to find, thanks!

Yeah, I thought we were past that and looking for actual solutions.

“Viewport” != “big fat fancy window of a UI”

“Viewport” = “tell OpenGL to render to this part of the screen”

…it’s not really any fancier than that. The nice thing about JME is that it’s really flexible because it’s basically strapped directly to OpenGL. With freedom comes responsibility, though… in this case, making a viewport “look” like something fancier is left up to the game dev. The trade offs necessary for making it look like something it isn’t are going to be different from game to game.

So now we are back to what the easiest way is to get the effect you want… and all approaches are going to involve knowing how big on the screen you want the border to be.

For example, probably the simplest (but maybe not as efficient and certainly not as flexible) way would be to add two viewports… one that just clears the background to a specific color and doesn’t have a scene at all and the one on top of that which is a little smaller and has the scene in it. But it’s still necessary to figure out “how much smaller”… which is going to be based on camera.getWidth()/getHeight().

2 Likes

so I drawed 4 lines on the Hud, its look quite ok, maybe I will make the Stroke-size inverse depending on the screen size. Because I now use 2px which is ok on desktop, but when run in android on an AVD, its look nearly to thin.