PDA

View Full Version : Glut subwindow



glcrazy
02-14-2004, 10:08 PM
Hello,

In my display routine I want to create a GLUT sub window for each "if " statement

I mean

If
{ create glut subwindow1 ;
.. ;
}

if .
{ create glut subwindow2 ;
.. ;
}

if .
{ create glut subwindow3 ;
.. ;
}

How can I do that ?

Thanks in advance for any help

tachyon_eagle
02-16-2004, 10:52 AM
Hi,
you nearly done that, it's easy :

it's useful to keep identifiers to those windows, so
make globals like :

int win1, win2, win3, win4;

then for each window paste code like :

win1= glutCreateSubWindow(mainWindow,startX,startY,sizeX ,sizeY);
//of course, you need main window set up already, for ex
//glutInitWindowSize(mainWidth, mainHeight);
//glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH | etc.);
//mainWindow=glutCreateWindow("YourMainWindow");


glutDisplayFunc(win1disp);
//as this subwindow is now "selected" by glut you shall register win1disp procedure , which renders its contents
// --> this is just void win1disp() {....}
// you can also register more callbacks or menu for this window if you like

btw: there's a simple example code for subwindows within glut distribution
(progs\examples\subwin.c)

[This message has been edited by tachyon_eagle (edited 02-16-2004).]

glcrazy
02-19-2004, 11:44 PM
Thankx alot tachyon_eagle . It works with me in proper way http://www.opengl.org/discussion_boards/ubb/smile.gif . There is still one thing . How can I "kill" the subwindow because it still there even if the program doing something else ?

and I wonder where I can get the example you mnetioned ? I mean progs\examples\subwin.c

Thankx again.

nexusone
02-20-2004, 05:07 AM
glutDestroyWindow( int window);



Originally posted by glcrazy:

Thankx alot tachyon_eagle . It works with me in proper way http://www.opengl.org/discussion_boards/ubb/smile.gif . There is still one thing . How can I "kill" the subwindow because it still there even if the program doing something else ?

and I wonder where I can get the example you mnetioned ? I mean progs\examples\subwin.c

Thankx again.

glcrazy
02-20-2004, 09:47 AM
Hello nexusone,

Thank you very much, I try to put this command, but I get unresolved error which stop the program.

As you see here ,
If
{ create glut subwindow1 ;
.. ;
}

if .
{ create glut subwindow2 ;
.. ;
}

if .
{ create glut subwindow3 ;
.. ;
}


I creat a sub window for each choice ( I mean each If statement ) and I was confuesed where to put "glutDestroyWindow( int window);" , Do I have to put it in each if statment or where exactly ?

nexusone
02-20-2004, 11:49 AM
Did you send the corrent window number to the command?
As for where to put it, not sure since I don't know what you are trying to do.

Should be at a place after you have done something in that window and are ready to close it.

glcrazy
02-22-2004, 10:22 AM
I don't know where to put 'glutDestroyWindow( int window);' exactly nexusone. It works now but not in proper way . I will keep trying till I can find the correct solution.

Thank you always nexusone for your cooperative and help.

nexusone
02-22-2004, 10:58 AM
If you give more details as to what you are tying to do?

Like open a window for dialog and close it after the user responds?

glcrazy
02-22-2004, 12:19 PM
I used each subwindow to render a part of the code .. I'm demonstaring an image resolution as illustration tool for understanding the meaning of resolution . Each different 'image' (resolution) must be in seprate subwindow. Once the user chose what resolution he wants ( 'if statments' as shown in my past replies) a subwindow appears . When he choose another choice the subwindow must disappear and another subwindow comes out with his choice and so on .

I hope I clarified my work correctly.!

nexusone
02-23-2004, 12:25 PM
You need to track which window is active and then use that as part of your "if" logic for when the user clicks on the window.