• Advertisement

Archived

This topic is now archived and is closed to further replies.

To GLUT or not to GLUT?

This topic is 5735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve had a little experience using GLUT and a little experience not using GLUT for Windows programs. I''ve also heard some people swear by GLUT for games programming, but I''ve heard smarter people say it is not the way to go. I am told that going non-GLUT will give your game better speed and flexibility (and better accuracy with input). Yet I still hear constant mentionings of GLUT (even in the Game Programming Gems book). So, basically I''m just wondering if any *enlightened*, and obviously way more experienced, game programmers could share their divine knowledge with me as to why or why not you would want to use GLUT. Thanks, P

Share this post

Share on other sites
Advertisement
Personally, I use GLUT for apps as long as I can get along with it. So programs often start out using GLUT and if I find that I need some feature GLUT does not provide then I port it to eliminate GLUT - which often is quite easy.

The advantage of GLUT clearly is that it makes you code shorter, easier to read and more portable code. All of these are good reasons to use GLUT in text books and tutorials which is why you see it all over.

That was my 2 cents.

Share this post

Share on other sites
felonius,

It sounds like, from your response, that you usually end up getting rid of GLUT anyway. You don''t feel like you waste time by starting with it in the first place?

...

How does GLUT compare to things like plib and glt?

Thanks again!

P

Share this post

Share on other sites
a glut application is a console app, so changing it to win32 is not as easy as just changing the code, you have to start a new project. Does anyone know how to make glut work in a win32 app? I remember having trouble with the glutinit in winmain but it was a while ago.

Share this post

Share on other sites
Glut is a tool kit.

If you find that the tools dont fit, then its time to find a new one. With glut that normally comes when you have to optimize or when your trying to add or extend a feature that isnt well supported (or documented).

With a little bit of research the functionality of any glut function can be reproduced easily.

thanks

-jonnii

Share this post

Share on other sites
quote:
Original post by Anonymous Poster
a glut application is a console app, so changing it to win32 is not as easy as just changing the code, you have to start a new project. Does anyone know how to make glut work in a win32 app? I remember having trouble with the glutinit in winmain but it was a while ago.

I do know that there is some way you can get rid of the console window that shows up, but I''ve only used GLUT for a short time as I''m more a D3D user.. But I guess you could start it up (glutInit()??) in WinMain, create a GLUT window and then retrive the handle for that window using Win32 GUI functions..

Share this post

Share on other sites
glut is soooo much easier to prototype apps on. I keep a small framework file around which I build off of, and if my project ever grows to need more than that, I''ll rebuild it using win32 and whatever other goodies i need.

In fact, I''ll post my skeleton if anyone wants it.

  #include <iostream>#include <GL/glut.h>int v_height,v_width;void DisplayFunc(){	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();	glutSwapBuffers();	glutPostRedisplay();}void ReshapeFunc(int width, int height){	if(height==0)		height=1;	v_height=height;	v_width=width;	glViewport(0,0,width,height);	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(45,float(width)/float(height),1,1000);	glMatrixMode(GL_MODELVIEW);}void KeyboardFunc(unsigned char key, int x, int y) { 	switch(key) 	{	case ''q'': exit(0);		break;	default:		break;	}}void MouseFunc(int button, int state, int x, int y){	y=v_height-y;			if (state == 0)  //button down	{		if (button == GLUT_LEFT_BUTTON) 		{				}		else if (button == GLUT_MIDDLE_BUTTON) 		{				}		else if (button == GLUT_RIGHT_BUTTON) 		{		}	}	else if (state == 1) //button up	{		if (button == GLUT_LEFT_BUTTON) 		{					}		else if(button==GLUT_MIDDLE_BUTTON)		{		}		else if(button==GLUT_RIGHT_BUTTON)		{				}	}}int main(int argc,char **argv){	glutInit(&argc,argv);	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); // set display mode	glutInitWindowSize(400,300); // set window size	glutInitWindowPosition(0,0); // set window position on screen	glutCreateWindow("Glut Window"); // set window title	glutMouseFunc(MouseFunc); // register the mouse action function	glutKeyboardFunc(KeyboardFunc); // register the keyboard action function	glutDisplayFunc(DisplayFunc); //register the redraw function	glutReshapeFunc(ReshapeFunc);	glutMainLoop();	return 0;}

Share this post

Share on other sites
quote:
Original post by Panayoti
felonius,

It sounds like, from your response, that you usually end up getting rid of GLUT anyway. You don''t feel like you waste time by starting with it in the first place?

...

How does GLUT compare to things like plib and glt?

Thanks again!

P

No, then I sounded wrong. In my case, I would say that approx. 75% of my apps use GLUT, but that might be because I mostly wrote small apps. In general, the larger and the more complex the app the less likely it is that you can use GLUT - but if you just have to put some OpenGL demo together to try of some cool stuff I think it is great and makes you life easier. So it depends on what you are making. I doubt any large commercial games use GLUT - it is just not good enough for them.

Share this post

Share on other sites

• Advertisement
• Advertisement
• Popular Tags

• Advertisement
• Popular Now

• 9
• 10
• 18
• 13
• 10
• Advertisement