Archive Pages Design$type=blogging

How to add menu to your OpenGL Projects

In this tutorial we are going to see how to add menu in OpenGL. Adding menu in you OpenGL Projects not only make the program more user interactive but it make it smother and more usefull

In OpenGL programming there many way to make the user interactive programs. One of the things that is the use of menu, which is like selecting something (off-course with mouse) to change the state of some variable to achieve the desire result with that change. In this tutorial we are going to see how to add menu in OpenGL.



Adding menu in you OpenGL Projects not only make the program more user interactive but it make it smother and more usefull. So let get started with it.

For adding menu in our OpenGL Projects we use the glutCreateMenu, which create the popup menu and return  identifier (small integral value). The code looks like -

glutCreateMenu(menu); // it can be given to variable like mainmenu=glutCreateMenu(menu)

Firstly we create sub-menus then we go for the main menu which became the current menu.

glutAddSubMenu("Operating System", os);

The string "Operating System" represent the name of sub-menu that is to be displayed, while second argument 'os' is the sub-menu that has been created.

To add the entries in the sub menu list we use glutAddMenuEntry, which a menu entry to the bottom of the current menu.

glutAddMenuEntry("Windows", 1);

Here "Windows", is the string or the name that is to be displayed and the number is for the purpose of menu's callback function, when it is selected.
Since menu are mouse driven events in OpenGL, so we can add the interaction to either the left or right mouse button or on both (separate menu's). This is done by calling glutAttachMenu with right or left mouse button as argument.

 glutAttachMenu(GLUT_RIGHT_BUTTON); //for right mouse click
 glutAttachMenu(GLUT_LEFT_BUTTON);  //for left mouse click

This is all! So easy to add menu's to the projects in OpenGL.

Here is sample program that has menu demonstrated.

COMMENTS

Name

3D Bi-Cycle 3D Game 3D Laptop 3D Objects 3D Projects 3D Zoo Algorithm Android Aquarium Bellman-Ford Algorithm Block Breaker Blockshooting Bucket Sort C# Chess Clock Code Blocks Colors Complex Project Complex Projects Crab Pong Cross Zero DSAV Escapa First Come First Serve Fluids Font Demo Games Gear Motion GlutDino Glutplane Graphics Editor iOS iPhone Java Java OpenGL Graphics Programming Light Torus Linked List Ludo Board Game Mancala board games Memory blocks game Memory Game Menu Mickey Mouse Minesweeper Miniature Steam Engine moth Motion Blur MoveLight moving car Moving Ship Multiplex Networking Based Project Nuclear Power Plant Olympic opengl c++ examples OpenGL ES OpenGL Tutorial Origami OS Based Projects Paint Paper Folding Particles Drop Path Finding ping pong Pong Game Project Report Projects Report Puzzles qix like Random Flowing lines Rigid Body Rings Robot sample c++ opengl code Screen Saver Screen Saver Ship Shadow Cube Shadowfun Ship Iceberg Simple Drawing Simple Haloed Lined Wireframe Simple Move Light Simple Project Simulation SNAKE XENZIA GAME Solar system Sorting Sphere Spot Light Swing Stars Taj Mahal The Edge Game Tic Tac Toe Tower of Hanoi Traffic Signal Transformation Triangular Animation Tutorial water ripple effects Whirlpool
false
ltr
item
OpenGL Projects: How to add menu to your OpenGL Projects
How to add menu to your OpenGL Projects
In this tutorial we are going to see how to add menu in OpenGL. Adding menu in you OpenGL Projects not only make the program more user interactive but it make it smother and more usefull
http://1.bp.blogspot.com/-xJvPKG-e18k/UTJiHkoxowI/AAAAAAAAE0Y/-yMTkZbdFtE/s320/glutmenu.png
http://1.bp.blogspot.com/-xJvPKG-e18k/UTJiHkoxowI/AAAAAAAAE0Y/-yMTkZbdFtE/s72-c/glutmenu.png
OpenGL Projects
http://www.openglprojects.in/2013/03/adding-menu-to-opengl-projects.html
http://www.openglprojects.in/
http://www.openglprojects.in/
http://www.openglprojects.in/2013/03/adding-menu-to-opengl-projects.html
true
2020194800836807725
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago