OpenGL GUI anyone? Updated on 11/17/05

Started by
206 comments, last by Alpha_ProgDes 17 years, 9 months ago
W00t, thanks Phantom my man :D
Now I am trying to remove the GUI dependance from my own engine, I would like one of you fellas to provide me with a simple GLUT application with a mouse and keyboard listener as well as a main loop [smile]

[Edited by - JavaCoolDude on June 15, 2005 9:21:41 PM]
Advertisement
Very nice, hope to make one this good myself.

~270 FPS
CPU: 2.8GHz Celeron
GPU: 128MB ATI Radeon 9250 Xtasy Series
RAM: 1GB PC3200

Quote:Original post by JavaCoolDude
Now I would like one of you fellas to provide me with a simple GLUT application with a mouse and keyboard listener and a main loop; I'm trying to remove the GUI dependance from my own engine :)


#include "glut.h"void changeSize( int w, int h ){	// Prevent a divide by zero, when window is too short	// (you cant make a window of zero width).	if(h == 0)		h = 1;	float ratio = 1.0f * w / h;	// Reset the coordinate system before modifying	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	// Set the viewport to be the entire window	glViewport(0, 0, w, h);	// Set the clipping volume	gluPerspective( 45, ratio, 1, 1000 );	glMatrixMode( GL_MODELVIEW );	glLoadIdentity();}void initScene() {	glEnable(GL_DEPTH_TEST);}void renderScene(void) {	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	glutSwapBuffers();}void processNormalKeys(unsigned char key, int x, int y) {	if (key == 27) 		exit(0);}void inputKey(int key, int x, int y) {	switch (key) 	{		case GLUT_KEY_LEFT : 			break;		case GLUT_KEY_RIGHT : 			break;		case GLUT_KEY_UP : 			break;		case GLUT_KEY_DOWN : 			break;	}}void processMouse(int button, int state, int x, int y) {	int specialKey = glutGetModifiers();	// if both a mouse button, and the ALT key, are pressed  then	if ((state == GLUT_DOWN) && (specialKey == GLUT_ACTIVE_ALT)) 	{		// set the color to pure red for the left button		// if (button == GLUT_LEFT_BUTTON) 		// set the color to pure green for the middle button		//else if (button == GLUT_MIDDLE_BUTTON) 				// set the color to pure blue for the right button		// else	}}void processMouseActiveMotion(int x, int y) {	//if (specialKey == GLUT_ACTIVE_SHIFT) 	//else if (specialKey == GLUT_ACTIVE_CTRL)	//else if (specialKey == GLUT_ACTIVE_ALT)	//else}void processMousePassiveMotion(int x, int y) {	//if (specialKey == GLUT_ACTIVE_SHIFT) 	//else if (specialKey == GLUT_ACTIVE_CTRL)	//else if (specialKey == GLUT_ACTIVE_ALT)	//else}void processMouseEntry(int state) {	//if ( state == GLUT_LEFT )	//if( state == GLUT_ENTERED )}int main(int argc, char **argv){	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);	glutInitWindowPosition(100,100);	glutInitWindowSize(640,360);	glutCreateWindow("GLUT");	initScene();		// Keyboard	glutKeyboardFunc(processNormalKeys);	glutSpecialFunc(inputKey);	// Display and Idle	glutDisplayFunc(renderScene);	glutIdleFunc(renderScene);	glutReshapeFunc(changeSize);	// Mouse stuff	glutMouseFunc(processMouse);	glutMotionFunc(processMouseActiveMotion);	glutPassiveMotionFunc(processMousePassiveMotion);	glutEntryFunc(processMouseEntry);	glutMainLoop();	return(0);}


Ok here is something put together from a lot of the LightHouse3D Glut tutorials. If you take a look at the tutorials under the 'Input' category, it shows the mouse and keyboard stuff in more detail as to what you can use.

For more information on stuff that you can use, right click on a define'd expression and 'Go to declaration' to see more of it's kind. Good luck!
WOW! it ran steady at 1000fps.

athlon 3200 (32bit)
1gb pc3200
9800pro

btw dude ive seen your work, absolutely awesome!!! u seem to be a god of graphic programming. i hope to be as good as you someday...
Quote:Original post by Drew_Benton
Ok here is something put together from a lot of the LightHouse3D Glut tutorials. If you take a look at the tutorials under the 'Input' category, it shows the mouse and keyboard stuff in more detail as to what you can use.

For more information on stuff that you can use, right click on a define'd expression and 'Go to declaration' to see more of it's kind. Good luck!


Thanks dude, the code you posted helped me out a lot.

Ok ladies and gentlemen, announcing SXML GUI 0.5 for WIN users, grab it right here while it's still hot.
Here's a list of what you get:
Buttons, TextBoxes, vertical and horizontal sliders, Radio Buttons, CheckBoxes, Panels, Separators, Labels.
A TextureLoader and manager, no image would be loaded twice ;)
A MediaPathManager.
A lousy XML loader [pig]
Some other cool stuff.

I haven't used Linux that much therefore I have no clue on how to go about implementing a robust timer in the said environment. If anyone out there can look at the code and modify Tools/FPSCounter and Tools/Benchmark to whatever Linux uses you'll be my hero...well for a day or two :D
Oh wow, that's great! I just tried it in the GLUT example and I must say, quite impressive! When I get my dev computer up and running in a week or so, I will definitly start messing with this library [wink] Thanks for all the hard work!
yeah nice work mate, the demo run's just fine ...haven't had a chance yet to play around with it but will do in the next few days

okay, i think you kinda misunderstood me ;)
the fade i was talking about wasn't the hover-fade, but rather the selection-change-fade. another note is that in the 0.5-release, moving the cursor in textboxes with the arrow-keys seems to be broken. as a user, i would also like to be able to select a chunk of text with both shift+arrow-keys and the mouse-cursor if possible. other than that, this seems like a really nice gui-library, by the way :)
Going to give this a try, I'll need some form of GUI for my 4E4 entry ;)
how would you make this GUI in pure openGL/glut style mode..kinda like what JavaDude was asking about? i mean yeah you have your textures and your font etc etc but i guess how do you make them react to each other.. i guess by checking mouse over or something, i concur that someone would get some major props for writing a tut on this :)
heh

This topic is closed to new replies.

Advertisement