Hi Robert,

Thanks for your help but I think I might have not asked my question very well. 
Regardless, I was able to find a solution to my problem. I case anybody wants 
my answer, it is below:

Using osgHud as a reference.

1)
Set up the camera's projection matrix such that 
hud_camera->setProjectionMatrix(osg::Matrix::ortho2D(0, width_of_viewer,  0, 
height_of_viewer));
//the osgHud example gives some default numbers (0,1280,0,1024), but your 
geometry will deform if you shrink your viewer to be less than 1280 x 1024
//Note, I use qt's qwidget to hold my viewer so I just use qwidget->size() to 
obtain width and height

2)
draw your geometry (use the osgHud rectangle that you draw text onto as a 
starting point) and add it to the camera. I also translate my geometry to the 
center of the screen which is just width_of_viewer/2, height_of_viewer/2

3)
somehow capture the resize event of your viewer when it resizes. I use qt so I 
just use the QWidget::resizeEvent.

4)
In your resize event function:

hud_camera->setProjectionMatrix(osg::Matrix::ortho2D(0, new_viewer_width, 0, 
new_viewer_height));

And reposition your Geometry after. Luckily for me this is easy because I 
always want my geometry in the center: new_viewer_width/2, new_viewer_height/2

Your Geometry will now stay the same proportion AND size AND position (if you 
do everything I do) as it was in the beginning. It will not shrink or grow in 
any way on resize on the viewer/window. 


Cheers,
John-Luke

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=62145#62145





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to