0

I have an app that mixes OpenGL with Motif. The big main window that has OpenGL in it redraws fine. But, the sub windows sitting on top of it all go black. Specifically, just the parts of those subwindows that are right on top of the main window. Those subwindows all have just Motif code in them (except for one).

The app doesn't freeze up or dump core. Data is still flowing, and as text fields, etcetera of various subwindows get updated, those parts redraw. Dragging windows across each other or minimizing/unminimizing also trigger redraws. The timing of the "blackout" is random. I run the same 1-hour dataset every time and sometimes the blackout happens 5 minutes into the run and sometimes 30 minutes in, etc.

I went through the process of turning off sections of code until the problem stopped. Narrowed it down more and more and found it had to do with the use of the depth buffer. In other words, when I comment out the glEnable(GL_ENABLE_DEPTH_TEST), the problem goes away. So the problem seems to have something do with the use of the depth buffer.

As far as I can tell, the depth buffer is being cleared before redrawing is done, as it should. There's if-statements wrapped around the glClear calls, so I put messages in there and confirmed that the glClear of the depth buffer is indeed happening even when the blackout happens. Also, glGetError didn't return anything.

UPDATE 6/30/2014 Looks like there's still at least one person looking at this (thanks, UltraJoe). If I remember correctly, it turned out that it was sometimes swapping buffers without first defining the back buffer and drawing anything to it. It wasn't obvious to me before because it's such a long routine. There were some other minor things I had to clean-up, but I think that was the main cause.

tealfan
  • 1
  • 2

2 Answers2

1

How did you create the OpenGL window/context. Did you just get the X11 Window handle of your Motif main window and created the OpenGL context on that one? Or did you create a own subwindow within that Motif window for OpenGL?

You should not use any window managed by a toolkit directly, unless this was some widget for exclusive OpenGL use. The reason is, that most toolkits don't create a own sub-window for each an every element and also reuse parts of their graphics resources.

Thus you should create a own sub-window for OpenGL, and maybe a further subwindow using glXCreateWindow as well.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Not a subwindow exactly, but an XmForm was created within the main window to contain the glwMDrawingArea and nothing else. The Display of that form is the parent of the GLXContext. – tealfan Nov 01 '12 at 18:43
  • (Sorry. Enter key issues. :) ) Not a subwindow exactly, but an XmForm (call it glForm) was created within the main window to contain the glwMDrawingArea and nothing else. The Display of that form is the parent of the GLXContext. Now glForm is contained in the main window with another form (call it motifForm) that is strictly Motif. Haven't had any problems with redrawing of motifForm. If I really do need to put glForm in it's own window, that's going to be a problem. Need to keep motifForm and glForm in the same window. – tealfan Nov 01 '12 at 18:51
  • Sigh. When I said "is the parent of the GLXContext", I should have said "is the Display of the GLXContext". – tealfan Nov 01 '12 at 19:01
  • @user1789943: I do not mean a top level window. I mean a very own X11 window, which can be perfectly parented within another window, i.e. be contained within another window. – datenwolf Nov 01 '12 at 21:07
  • I don't know if you caught that I'm using a glwMDrawingAreaWidget. Does that already prevent any of the problems you mentioned? Or would it still be better to replace it with a GLXWindow? Thanks for all your help so far. – tealfan Nov 01 '12 at 23:36
1

This is an old question, I know, but the answer may help someone else.

This sounds like you're selecting a bad visual for your OpenGL window, or you're creating a new colormap that's overriding the default. If at all possible, choose a DirectColor 24-plane visual for everything in your application. DirectColor visuals use read-only color cells, but 24 planes will allow every supported color to be available to every window without having to overwrite color cells.

Joe Sewell
  • 306
  • 1
  • 11