How to display a sub window?

I’ve created a subwindow of a window using glutCreateSubWindow as follows:

sWin = glutCreateWindow(“IOS”);

iosSubWin = glutCreateSubWindow(sWin, 0, 405, 640, 155);

I need to be able to show or hide the window, so for showing the subwindow and drawing to it, this should work:

glutSetWindow( iosSubWin ); // specify sub window
glutShowWindow(); // show subwindow
draw some stuff to the subwindow

-and to hide the subwindow:

glutSetWindow( iosSubWin );

But nothing shows up when I draw to the subwindow. 'Sup with this stupid thing?

Are you using the proper display callback? I think you would need two, one for each window.

Yep. Have a display callback for the parent window and a separate one for the subwindow.

Was able to get something to display on the subwindow just now. Used the following code to draw a big red X:

glColor3f( 1.0f, 0.0f, 0.0f );

But I specified a subwindow 640 pixels wide by 155 pixels high. And yet the above code draws a big red X that takes up half the window. The subwindow is not in the same mode as the parent window. Must be something wrong in the way I
created the subwindow.

By the way, if I don’t move or resize the subwindow, I don’t need a reshape callback function for it, right?

added a call to glOrtho:

iosSubWin = glutCreateSubWindow(iosWin, 0, 400, 640, 80);
glOrtho (0.0, 640, 0.0, 80, -1.0, 1.0); // multiply the current matrix

and now it works. Since I’m currently only displaying bitmapped text, this is really what I need.

Well, whether you need a (different) reshape callback depends on other needs as well. By means of the reshape callback we set up the view frustum, which creates our “world”. Everything in it, is drawn; anything out gets clipped out. The default view frustum, if I remember correctly is a -1, 1, -1, 1, -1, 1 cube. So yes, if this frustum is enough for you and you’re not going to change the size of the window, you’re ok.
Also remember that by calling the reshape callback we usually set the viewport to the proper dimensions as well.
And yes, I believe that using a frustum with the analogy 1 unit = 1 pixel is the best solution for bitmaped graphics. Good luck!