[osg-users] How to prevent resize of viewer window (Windows and Linux)

373 views
Skip to first unread message

John Simpson

unread,
Feb 16, 2012, 7:40:42 AM2/16/12
to osg-...@lists.openscenegraph.org
Hi,

I need to display a viewer window that the user can't resize. Tried all sorts. I assume it's the viewer's graphics context traits resize boolean but can't figure out a way to change it. This is a cross-platform app and I guess there will be a way of messing with the underlying Windows and X subsystems to achieve this but I'm hoping for something more elegant within OSG

Help required.

Thanks,

John

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

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

Werner Modenbach

unread,
Feb 16, 2012, 7:51:42 AM2/16/12
to osg-...@lists.openscenegraph.org
Does cross platform mean you are using Qt framework? In this case just
assign a fixed size to the embedding window.

John Simpson

unread,
Feb 16, 2012, 8:09:29 AM2/16/12
to osg-...@lists.openscenegraph.org
Hi Werner

Thanks for the reply. No I'm not using Qt, it's cross-platform at the console level so I'm relying on OSG's viewer windowing.

John

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=45506#45506

John Simpson

unread,
Feb 16, 2012, 8:46:41 AM2/16/12
to osg-...@lists.openscenegraph.org
Hi,

For info: this can be achieved using...

osgViewer::ViewerBase::Windows windows;
viewer.getWindow(windows);
windows[0]->setWindowDecoration(false);

But this also prevents the window being moved - not ideal.

John

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=45508#45508

Jason Daly

unread,
Feb 16, 2012, 11:56:52 AM2/16/12
to osg-...@lists.openscenegraph.org
On 02/16/2012 08:46 AM, John Simpson wrote:
> Hi,
>
> For info: this can be achieved using...
>
> osgViewer::ViewerBase::Windows windows;
> viewer.getWindow(windows);
> windows[0]->setWindowDecoration(false);
>
> But this also prevents the window being moved - not ideal.

Hi, John,

There should be a better way to do that:

osg::GraphicsContext::Traits *traits = new osg::GraphicsContext::Traits;

traits->x = 100;
traits->y = 100;
traits->width = 640;
traits->height = 480;
traits->windowDecoration = true;
traits->supportsResize = false;
traits->sharedContext = 0;

osg::Camera *camera = new osg::Camera();
camera->setGraphicsContext(gc);
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));

viewer.setCamera(camera);
viewer.realize();


Haven't tested this code, but something like that should be enough to
get what you're looking for.

--"J"

John Simpson

unread,
Feb 17, 2012, 2:58:44 AM2/17/12
to osg-...@lists.openscenegraph.org
Jason

Thanks but the viewer still resizes taking the viewport with it.

This is a screen capture app with the resultant data being streamed to an image processing algorithm for which the image size is fixed. It's based on the osgscreencapture example which does mysterious things with the viewers gc so your new camera thing results in a blank screen, however getting the viewer's camera and applying a new, modified, gc to it does at least produce an image but as I said both the viewer and the viewport can still be resized.

John

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=45528#45528

John Simpson

unread,
Feb 23, 2012, 10:20:16 AM2/23/12
to osg-...@lists.openscenegraph.org
Hi,

I still haven't got to the bottom of this.

Use the source?

John

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=45726#45726

Jason Daly

unread,
Feb 23, 2012, 11:54:41 AM2/23/12
to osg-...@lists.openscenegraph.org
On 02/23/2012 10:20 AM, John Simpson wrote:
> Hi,
>
> I still haven't got to the bottom of this.
>
> Use the source?

Hi, John,

You mentioned this is going to be cross-platform. Is your code not
working on any platform? I looked at the relevant code in
GraphicsWindowX11.cpp, and it seems like it should work (I haven't had
time to test it myself, though).

Bottom line is that every desktop platform has a way to mark a window as
not resizeable, so this should be possible. If it's not working, it can
be made to work.

--"J"

John Simpson

unread,
Feb 23, 2012, 10:53:35 PM2/23/12
to osg-...@lists.openscenegraph.org
Jason

I know it's possible if I dig into the windowing system for a specific platform, but I was hoping to do it using an OSG cross-platfom method (see first post).

The app's developing and I'm now using a CompositeViewer for which I'm explicitly creating a GraphicsContext so I have access to the supportsResize trait and it still resizes (on both platforms).

I'll stop pestering this thread now and do it the long way.

John

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=45739#45739

Robert Osfield

unread,
Feb 24, 2012, 4:13:34 AM2/24/12
to osg-...@lists.openscenegraph.org
Hi John,

On 24 February 2012 03:53, John Simpson <john.s...@mbda.co.uk> wrote:
> I know it's possible if I dig into the windowing system for a specific platform, but I was hoping to do it using an OSG cross-platfom method (see first post).
>
> The app's developing and I'm now using a CompositeViewer for which I'm explicitly creating a GraphicsContext so I have access to the supportsResize trait and it still resizes (on both platforms).
>
> I'll stop pestering this thread now and do it the long way.

You should be able to do the cross platform route, but if there is a
bug on the OSG side on one particular platform we as a community just
need to fix it. I just have access to Linux, and have very little
Windows experience so can't help out with debugging the Windows side,
so have to rely on Windows dev to get things working perfectly under
Windows - this normally works out pretty well.

To resolve the issue the best route would be to create a small example
that illustrates the problem so that others can reproduce, confirm the
problem and then work to fix it. Modifying an existing osg example
would probably be a good place to start.

Robert.

Jason Daly

unread,
Feb 24, 2012, 10:52:01 AM2/24/12
to osg-...@lists.openscenegraph.org
On 02/23/2012 10:53 PM, John Simpson wrote:
> Jason
>
> I know it's possible if I dig into the windowing system for a specific platform, but I was hoping to do it using an OSG cross-platfom method (see first post).

I think you misunderstood me. What I meant was that OSG should be able
to provide the ability to disable resizing in a cross-platform way
(because all of the underlying platforms support it).

If it's not doing that properly, then something needs fixing. If you
can create a simple example, like Robert suggested, I can try to help
with the Linux and Windows implementations.

--"J"

Stephan Maximilian Huber

unread,
Feb 24, 2012, 11:38:13 AM2/24/12
to OpenSceneGraph Users
Hi,

Am 24.02.12 16:52, schrieb Jason Daly:


>
> If it's not doing that properly, then something needs fixing. If you
> can create a simple example, like Robert suggested, I can try to help
> with the Linux and Windows implementations.

The os x / cocoa implementation works as intended.

cheers,

Stephan

Jason Daly

unread,
Feb 24, 2012, 12:05:11 PM2/24/12
to osg-...@lists.openscenegraph.org
On 02/24/2012 04:13 AM, Robert Osfield wrote:
> You should be able to do the cross platform route, but if there is a
> bug on the OSG side on one particular platform we as a community just
> need to fix it. I just have access to Linux, and have very little
> Windows experience so can't help out with debugging the Windows side,
> so have to rely on Windows dev to get things working perfectly under
> Windows - this normally works out pretty well.
>
> To resolve the issue the best route would be to create a small example
> that illustrates the problem so that others can reproduce, confirm the
> problem and then work to fix it. Modifying an existing osg example
> would probably be a good place to start.

I found a little program I can test with. It looks like the MWM
property for resizing is being set correctly, just the window manager
(Metacity, in my case) is ignoring it. I'm putting together a
submission that uses the ICCCM hints instead.

--"J"

Cary, Karl A.

unread,
Feb 28, 2012, 4:04:59 PM2/28/12
to OpenSceneGraph Users
I would be very interested in this as well. I have been having this
issue for a long time. Our development systems all have one widescreen
monitor at 1920x1080 and then one SD monitor at 1280x1024. If we want to
run a 1280x1024 window on the widescreen as the left monitor, all is
fine. However if you want it to run on the 1280x1024 monitor and it is
the left most monitor, only 75% of the time it's fine. The other 25% go
between showing up on the wrong screen and running at 1280x1024 inside
of a 1920x1080 full screen window.

Jason Daly

unread,
Feb 28, 2012, 4:26:54 PM2/28/12
to OpenSceneGraph Users
On 02/28/2012 04:04 PM, Cary, Karl A. wrote:
> I would be very interested in this as well. I have been having this
> issue for a long time. Our development systems all have one widescreen
> monitor at 1920x1080 and then one SD monitor at 1280x1024. If we want to
> run a 1280x1024 window on the widescreen as the left monitor, all is
> fine. However if you want it to run on the 1280x1024 monitor and it is
> the left most monitor, only 75% of the time it's fine. The other 25% go
> between showing up on the wrong screen and running at 1280x1024 inside
> of a 1920x1080 full screen window.

Hi, Karl,

Sounds like you've got a different problem to me.

My patch is only for preventing the interactive resizing of the window
(i.e: by clicking the mouse on the window's border and dragging it).

I've seen problems like you mention before (I'm guessing you're on
Linux). Usually, some combination of options to the xorg.conf file can
be set to fix it, or at least make it behave consistently. If you're
using the NVIDIA proprietary driver, check the driver's README.txt file
for a list of options you can set.

Robert Osfield

unread,
Feb 29, 2012, 5:15:06 AM2/29/12
to OpenSceneGraph Users
Hi Karl,

Is that you are trying to prevent the resize done by the window
manager? Under X11 there is the override redirect flag to prevent the
window manager taking control of the window size so you can get
exactly the size you want, however, it also prevents the window
manager from decorating the window so only ideal for full screen
windows. To set this flag when creating your GraphicsWindows set the
osg::Traits::overrideRedirect member variable to true.

Robert.

Reply all
Reply to author
Forward
0 new messages