GLUT win management

Hi,

Are there any sites that show the results of the GLUT commands for window creation/management? I have the commands but would like to be able to see pictures of what they result in. (Kind of ironic that tutorials on graphics langs wouldn’t do this.)

Thanks a lot.

Why should a graphics tutor try to deal with all the aspects of window creation?
It takes to much time to cover both also not all OS’s have the same windowing features.

Also for most who only want to write a game or demo, other window functions the top bar drop down menus are not needed.

So best to only cover the basic idea of opening and closeing a window, this way you don’t get traped into one OS structure.
And get right into doing graphincs on the screen.

Those who want advanced menu features can always go to a windows site to learn to use them.

Originally posted by cg-hci_novice:
[b]Hi,

Are there any sites that show the results of the GLUT commands for window creation/management? I have the commands but would like to be able to see pictures of what they result in. (Kind of ironic that tutorials on graphics langs wouldn’t do this.)

Thanks a lot.[/b]

What do you mean by a windows site? Do those cover GLUT commands? Still looking for an ans. to this question.

Thanks.

Also looking for any Web site that covers error msgs?

Because I am currently getting:

Fatal Error: redisplay needed for window 1, but no display callback

I tried adding glutPostRedisplay call at the end of my main window display routine but am still getting this msg.

Are u registering a callback for display function?:slight_smile:

Can u post some code - where u initialize glut and create window(s)

  • Chetan

All the glut functions are listed on this website under documentation, also if you put a glut function in the search window on the main page of this website you will get a webpage with details on the useage of that function that includes errors.

Originally posted by cg-hci_novice:
[b]What do you mean by a windows site? Do those cover GLUT commands? Still looking for an ans. to this question.

Thanks.[/b]

I have glut examples on my website with details in the example as to what the functions are doing in the program.

Go to my website and download my basic glut frame work.

wwww.angelfire.com/linux/nexusone/

Here is the basic stucture for setting up a glut window.
Note that you have to have defind some basic routines before glut will work.

Fatal Error: redisplay needed for window 1, but no display callback

This error tell’s us you have not created a display routine. glutPostRedisplay requires you define a routine for it to run when called.

Look at my basic glut frame work and you will be able to see how everything works together.

// Main program
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (10, 10);
glutCreateWindow (argv[0]);
glutSetWindowTitle(“GlutWindow”);
init ();
glutDisplayFunc(display); // Routine to call when needing to draw to the window
glutReshapeFunc(reshape); // This is what routine glut is to call when the window is resphaped
glutKeyboardFunc(keyboard); // What routine to call when the keyboard is pressed
glutSpecialFunc(arrows);
glutTimerFunc( 10, TimeEvent, 1);
glutMainLoop(); // Always call last
return 0;
}

[This message has been edited by nexusone (edited 10-13-2003).]

I was aware of the of the GLUT info on this site but since I couldn’t find any pics of the wins, I couldn’t tell if I needed to create subwins or just small wins that are located close to a large win (from a screen shot I was provided with) since I am not very familiar with GLUT (and didn’t know what a subwin would imply).

I talked to someone today about it and found out that I need to make additional small wins not subwins.

I did have a display function but due to my trying to create subwins incorrectly, I was getting the error message I posted.

I appreciate that not everyone feels pics are necessary part of every tutorial but for this specific purpose, it would probably have been helpful to me.

Thanks very much for the info/links. I will now go ahead apply it to creating the small wins, etc.

Hi,

I was wondering if someone could explain why you would use glutSetWindow vs just creating and displaying multiple windows? Or, maybe give an example where this is necessary?

Thanks a lot.

glutSetWindow() is used to set the window (of the ones you have created) into which your OpenGL commands are rendered!

e.g. setting which window is cleared with glClear() etc etc etc etc …

r

Thanks Rob

I am able to create wins and use glutSetWindow but seems like the main is coming out to be the size of the win2 and win2 is coming out to be the size of main. (I did intentionally use disp_win1 in all the glutDisplayFunc calls).

Any suggestions?

Thanks.

w1=glutCreateWindow(“main”);

glutSetWindow(w1);
glutInitWindowSize(650, 650);
glutInitWindowPosition(0, 0);
glutDisplayFunc(disp_win1);

w2=glutCreateWindow(“win2”);

glutSetWindow(w2);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 0);
glutDisplayFunc(disp_win1);

w3=glutCreateWindow(“win3”);

glutSetWindow(w3);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 220);
glutDisplayFunc(disp_win1);

w4=glutCreateWindow(“win4”);

glutSetWindow(w4);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 440);
glutDisplayFunc(disp_win1);

Take a look at glutInitWindowSize and glutReshapeWindow here http://www.opengl.org/developers/documentation/glut/spec3/spec3.html

Actually, I am not supposed to need to use glutReshape… to do this. I am trying to create 4 wins - 1 win 650x650 w/some user interaction, 3 210x210 w/o but right now, I can’t even display all of them. The first win works ok alone but when I try to add the others, it doesn’t come up (wins are empty). Here is what I have:

In main:

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(650, 650);
glutInitWindowPosition(0, 0);
w1=glutCreateWindow(“main”);

/* user interaction for main win */

glutKeyboardFunc(keyboard);
glutSpecialFunc(processSpecialKeys);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutTimerFunc(50, update, 1);
glutIdleFunc(display);
glutDisplayFunc(display);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 0);
w2=glutCreateWindow(“win2”);
glutDisplayFunc(display);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 220);
w3=glutCreateWindow(“win3”);
glutDisplayFunc(display);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(210, 210);
glutInitWindowPosition(652, 440);
w4=glutCreateWindow(“win4”);
glutDisplayFunc(display);

In display routine:

glutSetWindow(w2);
gluPerspective(60, 1, 1, 1000);
gluLookAt(eye_x, eye_y, eye_z, wcenter_x, wcenter_y, wcenter_z, up_x, up_y, up_z);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
render_scene_only();

glutSetWindow(w3);
gluPerspective(60, 1, 1, 1000);
gluLookAt(eye_x, eye_y, eye_z, wcenter_x, wcenter_y, wcenter_z, up_x, up_y, up_z);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
render_scene_only();

glutSetWindow(w4);
gluPerspective(60, 1, 1, 1000);
gluLookAt(eye_x, eye_y, eye_z, wcenter_x, wcenter_y, wcenter_z, up_x, up_y, up_z);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
render_scene_only();

Any suggestions on what I am doing wrong in either main or my display routine?

Thanks.

OpenGL has different matrix modes. You should set the proper mode and not use the same for gluPerspective and gluLookAt. Take a look at some NeHe tutorial.

Thanks for your response.

I was told it is not necessary for this particular application - that’s why I didn’t get into it. My main difficulty now is just getting those 3 small windows to display ok. I am not sure if I only need to register 1 display callback for all 4 cases or not (?) GLUT seems to give me an error when I try to do that…

Ok, think I just found out the info I was given was not 100% accurate/clear (unfortunately) so I think I know what I need to do from here on out.

Thanks for the info all.