How to build a Head Up Display in OpenSceneGraph that resizes depending on the screen's resolution?

StackOverflow https://stackoverflow.com/questions/14401198

سؤال

I'm pretty new to OpenSceneGraph and I have the following problem:

I'm trying to build a 2D Head Up Display out of several images, so that it can resize depending on the screen's resolution. That means I have extra images for the corners and one image for the bar that connects the corners and so on. Well, that's the idea. But I have no clue how to do that in OpenSceneGraph.

Can anybody help me?

هل كانت مفيدة؟

المحلول

So, when the window resizes, you'll get an event from osgViewer telling you about the change.

You need to resize your viewport when the window size changes, so your HUD geometry has some idea of what the pixel-size of the display is (most of the HUD examples setup for a nominal 1024x768 screen and then just let that stretch around as the window is resized, pretending like the new viewport is still 1024x768).

Once you've resized the viewpoer, you need to rearrange your geometry. Your corner pieces need to be laid out at the fixed pixel size you want them to always appear, then you need your connecting elements to change size, horizontally or vertically, to fill the space between the corner pieces. You usually rely on texture stretching or repeating to fill the space as the piece of geometry gets stretched.

If none of that makes any sense, I can describe more.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top