X11 Error

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
bboven
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 24, 2005 8:39 pm

X11 Error

Post by bboven »

Hello,

I am trying to combine wxwidgets and OpenSceneGraph and I get to the point where I try to draw the scene, and I get the following error everytime:

X Error of failed request:
Major opcode of failed request: 3 (X_GetWindowAttributes)
Resource id in failed request: 0x22000fc
Serial number of failed request: 8
Current serial number in output stream: 9

Does anyone know how to fix this or if it typically happens when you do one particular thing?

Thanks.
Game_Ender
Knows some wx things
Knows some wx things
Posts: 45
Joined: Wed Jun 15, 2005 5:47 pm

Post by Game_Ender »

How are you trying to integrate wxWidgets and OSG? The only way I have been able to do is to either tell osgProducer::viewer to set the render surface's parent window to be a wxWidget window (using the GetHandle() wxWidget method), like so:

Code: Select all

osgProducer::Viewer viewer;
viewer.getCamera(0)->getRenderSurface()->setParentWindow( (unsigned int)myWxWindow->GetHandle() ); 
I had to use setParentWindow, because with setWindow I would get X11 conflicts. These to stem from both viewer and wxWidgets issueing X commands to the windows.

Now the other way is to use the osgsimple example and just use:

Code: Select all

...
myRenderSurface()->setWindow( (unsigne int)myWxWindow->GetHandle() ); 
...
If this does not apply, post code snippets of where you integrated OSG and wxWidgets.
bboven
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Jun 24, 2005 8:39 pm

Post by bboven »

If this does not apply, post code snippets of where you integrated OSG and wxWidgets.
Consider this code, where TestFrame is just a class that inherits from wxFrame and puts up a file menu, with open and close in it (which don't even do anything at this time).

IMPLEMENT_APP(TestApp)

bool TestApp::OnInit()
{
TestFrame *frame = new TestFrame( "Hello World", wxPoint(50,50), wxSize(450,340) );
frame->Show(TRUE);
SetTopWindow(frame);

wxWindow *myWxWindow = new wxWindow(frame, -1) ;
osgProducer::Viewer *viewer = new osgProducer::Viewer();
viewer->setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
viewer->getCamera(0)->getRenderSurface()->setParentWindow( (unsigned int)myWxWindow->GetHandle() );

return TRUE;
}

This compiles and brings up the window. However, as soon as I call viewer->realize() before I return, the program gives me the error I gave before:

X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 3 (X_GetWindowAttributes)
Resource id in failed request: 0x22000fd
Serial number of failed request: 17
Current serial number in output stream: 18

If you could help me get this figured out I would appreciate it so much.

Thanks!
Game_Ender
Knows some wx things
Knows some wx things
Posts: 45
Joined: Wed Jun 15, 2005 5:47 pm

Post by Game_Ender »

Here is what I did right after your last line there:

Code: Select all

viewer.setSceneDate(root);
viewer.realize();
viewer.update();
viewer.frame();
See this tutorial for how i created the root scene data. In later tutorials they show how to load model instead.

Then you have to set up a timer (look at the code I emailed you) to update at a set interval. I just ripped the code right from the API wxTimer example.

Every time the timer event is trigger this code runs:

Code: Select all

void TestFrame::onTimer(wxTimerEvent& event){
   if(viewer != NULL){
      viewer.sync();
      viewer.update();
      viewer.frame();
   }
}
Post Reply