On Fri, Dec 23, 2011 at 11:21:37AM -0700, Chris 'Xenon' Hanson wrote:
> Trying to run OSG/osgviewer (and the GLES2 osgvertexattributes test
> program) on Linux,
> under Ubuntu with the PowerVR emulator.
>
> It's not clear why eglChooseConfig is failing.
>
> This post:
> http://www.imgtec.com/forum/forum_posts.asp?TID=1378
The Nokia N900 (Maemo Linux) has a PowerVR and I had to make some
changes for it to get to initialize OpenGL ES there. At one point in
time I had the hang glider up. I included the patches related to
GraphicsWindowX11.cpp and skipped the rest. I haven't looked at them
in a while, so I'm not sure exactly what the status of them is. I
don't expect some of them to make any difference for you, like the one
preventing osgviewer from going full screen or the one relating to
input, I just included them in case the later patches failed without
them applied. You might not apply the last patch, it might work
better without it. These are off svn revision 12737.
Please Cc: me on any replies.
--
David Fries PGP pub CB1EE8F0
http://fries.net/~david/
>From a6699b411eccca28bbe497d690fc4dca26c4f60d Mon Sep 17 00:00:00 2001
From: David Fries
Date: Fri, 22 Jan 2010 12:16:42 -0600
Subject: [PATCH 08/23] osgviewer changes to not go full screen
It is very annoying for it to startup full screen and when you resize
it doesn't add the window handles.
---
include/osgViewer/Viewer|2 +-
src/osgViewer/GraphicsWindowX11.cpp | 20 ++--
src/osgViewer/Viewer.cpp| 14 --
src/osgViewer/ViewerBase.cpp|7 ---
4 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/include/osgViewer/Viewer b/include/osgViewer/Viewer
index 998e249..6b46efd 100644
--- a/include/osgViewer/Viewer
+++ b/include/osgViewer/Viewer
@@ -120,8 +120,8 @@ class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
virtual void viewerInit() { init(); }
osg::observer_ptr _cameraWithFocus;
-
+bool _grabFocus;
};
diff --git a/src/osgViewer/GraphicsWindowX11.cpp b/src/osgViewer/GraphicsWindowX11.cpp
index d9eef95..c46e483 100644
--- a/src/osgViewer/GraphicsWindowX11.cpp
+++ b/src/osgViewer/GraphicsWindowX11.cpp
@@ -485,7 +485,11 @@ bool GraphicsWindowX11::setWindowRectangleImplementation(int x, int y, int width
checkAndSendEventFullScreenIfNeeded(display, x, y, width, height, _traits->windowDecoration);
-XMoveResizeWindow(display, _window, x, y, width, height);
+// Let the window manager specify the position if x and y are -1.
+if(x==-1 && y==-1)
+XResizeWindow(display, _window, width, height);
+else
+XMoveResizeWindow(display, _window, x, y, width, height);
XFlush(display);
XSync(display, 0);
@@ -911,6 +915,16 @@ bool GraphicsWindowX11::createWindow()
}
}
+// How do you specify the window settings on startup? Hack it for now.
+if(_traits->x == 0 && _traits->y == 0 &&
+ _traits->width == 3200 && _traits->height == 1200)
+{
+ _traits->x = -1;
+ _traits->y = -1;
+ _traits->width = 320;
+ _traits->height = 200;
+}
+
_window = XCreateWindow( _display, _parent,
x,
y,
@@ -937,7 +951,9 @@ bool GraphicsWindowX11::createWindow()
sh.flags = 0;
sh.flags |= USSize;
sh.flags &= 0x7;
-sh.flags |= USPosition;
+// Let the window manager specify the position if x and y are -1.
+if(_traits->x!=-1 || _traits->y!=-1)
+sh.flags |= USPosition;
sh.flags &= 0xB;
sh.x = _traits->x;
sh.y = _traits->y;
diff --git a/src/osgViewer/Viewer.cpp b/src/osgViewer/Viewer.cpp
index 7469268..7ce47ed 100644
--- a/src/osgViewer/Viewer.cpp
+++ b/src/osgViewer/Viewer.cpp
@@ -34,6 +34,7 @@ using namespace osgViewer;
Viewer::Viewer()
{
_viewerBase = this;
+_grabFocus = false;
constructorInit();
}
@@ -41,6 +42,7 @@ Viewer::Viewer()
Viewer::Viewer(osg::ArgumentParser& arguments)
{
_viewerBase = this;
+_grabFocus = false;
constructorInit();
@@ -121,6 +123,15 @@ Viewer::Viewer(osg::ArgumentParser& arguments)
int x = -1, y = -1, width = -1, height = -1;
while (arguments.read("--window",x,y,width,height)) {}
+
+if(const char *ptr = getenv("OSG_GRAB"))
+{
+if(!strcmp(ptr, "OFF"))
+_grabFocus=false;
+else if(!strcmp(ptr, "ON"))
+_grabFocus=true;
+}
+while (arguments.read("--grab")) { _grabFocus=true; }
bool ss3d = false;
bool wowvx20 = false;
@@ -519,8 +530,7 @@ void Viewer::realize()
// attach contexts to _incrementalCompileOperation if attached.
if (_incrementalCompileOperation) _incrementalCompileOperation->assignContexts(contexts);
-bool grabFocus = true;
-if (grabFocus)
+if (_grabFocus)
{
for(Contexts::iterator citr = contexts.begin();
c