473,804 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question About glut and OpenGL

4 New Member
I have been trying to write a small glut program that uses popup context menus on right clicks to draw objects. However, every time I do this, the area underneath the submenu item I clicked does not refresh.

Here's a helpful test program I've found from Mindf**k's glut tutorial...

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <GL/glut.h>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. void createMenu(void);
  7. void menu(int value);
  8. void disp(void);
  9.  
  10. static int win;
  11. static int menid;
  12. static int submenid;
  13. static int primitive = 0;
  14.  
  15. int main(int argc, char **argv){
  16.  
  17.   // normal initialisation
  18.   glutInit(&argc, argv);
  19.   glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
  20.   glutInitWindowSize(500,500);
  21.   glutInitWindowPosition(100,100);
  22.  
  23.   win = glutCreateWindow("GLUT MENU");
  24.  
  25.   // put all the menu functions in one nice procedure
  26.   createMenu();
  27.  
  28.   // set the clearcolor and the callback
  29.   glClearColor(0.0,0.0,0.0,0.0);
  30.  
  31.   glutDisplayFunc(disp);
  32.  
  33.   // enter the main loop
  34.   glutMainLoop();
  35.  
  36. }
  37.  
  38.  
  39. void createMenu(void){
  40.   //////////
  41.   // MENU //
  42.   //////////
  43.  
  44.   // Create a submenu, this has to be done first.
  45.   submenid = glutCreateMenu(menu);
  46.  
  47.   // Add sub menu entry
  48.   glutAddMenuEntry("Teapot", 2);
  49.   glutAddMenuEntry("Cube", 3);
  50.   glutAddMenuEntry("Torus", 4);
  51.  
  52.   // Create the menu, this menu becomes the current menu
  53.   menid = glutCreateMenu(menu);
  54.  
  55.   // Create an entry
  56.   glutAddMenuEntry("Clear", 1);
  57.  
  58.   glutAddSubMenu("Draw", submenid);
  59.   // Create an entry
  60.   glutAddMenuEntry("Quit", 0);
  61.  
  62.   // Let the menu respond on the right mouse button
  63.   glutAttachMenu(GLUT_RIGHT_BUTTON);
  64.  
  65.  
  66. }
  67.  
  68. void disp(void){
  69.   // Just clean the screen
  70.   glClear(GL_COLOR_BUFFER_BIT);
  71.  
  72.   // draw what the user asked
  73.   if(primitive == 1){
  74.     glutPostRedisplay();
  75.   }else if(primitive == 2){
  76.     glutWireTeapot(0.5);
  77.   }else if(primitive == 3){
  78.     glutWireCube(0.5);
  79.   }else if(primitive == 4){
  80.     glutWireTorus(0.3,0.6,100,100);
  81.   }
  82.   glFlush();
  83. }
  84.  
  85.  
  86. void menu(int value){
  87.   if(value == 0){
  88.     glutDestroyWindow(win);
  89.     exit(0);
  90.   }else{
  91.     primitive=value;
  92.   }
  93.  
  94.   // you would want to redraw now
  95.   glutPostRedisplay();
  96. }
It's a pretty standard program, but here's what it looks like when I try to use it.



Notice that the only part of the window that fails to repaint is underneath the submenu item I clicked. This doesn't happen at all if I click a menu item. This happens with other programs I've written too using double buffering. I'm thinking it might be a problem with my video card drivers or something. Could anyone shed some light on this for me?
Jun 3 '08 #1
0 1737

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1995
by: Fulko van Westrenen | last post by:
Hello, I'm very new to Python and rather unexperienced in OpenGL, and now I try to learn both at the same time. I can find my way around in Perl with Perl/Tk. What I try to do is combining Tk and GLUT. Based on the dots.py code (from the examples) I wrote a working application that reacts fine to my keyboard. Now I would like to add some Tk widgets, like 'Quit' in the texturesurf2.py example. The problem is that texturesurf2.py takes a
5
5511
by: Steven Gutstein | last post by:
I've just managed to get PyOpenGL installed on a Windows NT machine. I've tried testing it using one of the programs supplied with the PyOpenGL download - molehill.py. On my machine, it was placed in the python23\Lib\site-packages\OpenGL\Demo\GLUT\examples directory. When I'm in Windows Explorer and double click on the icon for this program, it runs fine. However, when I try to 'execfile' molehill from the Python command line, I have...
9
4765
by: max(01)* | last post by:
hi there. i installed python2.3-opengl, then i tried one of those demos: ---- #!/usr/bin/python2.3 # This is statement is required by the build system to query build info if __name__ == '__build__':
0
862
by: Brett Baisley | last post by:
Hello At school, we use Emacs to make .cpp files for OpenGL. I got it working at home in windows using VC++.net, but in order to, I have to merge all of the files into one. Is there a way so that I can use the existing files (with minor adjustments) so that when I build the solution, it will run correctly? Right now, there is one main file to run it, say points.cpp. All this file
1
5618
by: Scott Chang | last post by:
Hi All I tried to use the attached OpenGL code to draw a Star-shaped figure on my Microsoft Visual C++ .NET 2002-Windows XP Pro PC. When I did 'Build' in Debug Mode, I got an error C2065: 'RenderScence': undeclared identifier. Please help and tell me (1) what it is wrong with my coding in this program and how to correct the problem, and (2) whether the functions/commands of the OpenGL v1.1 (existing in Microsoft Visual C++ .NET 2002) and GLUT...
5
14296
by: Michael Kipper | last post by:
Hi, I'm having a problem moving from C to C++. In C, I have a function: void display(void) {} that I can register with OpenGL as a callback using: GLUTAPI void glutDisplayFunc( void (GLUTCALLBACK *func)(void) )
1
1632
by: Advait | last post by:
Hello everyone, I am using GCC through DevC++ & Code Block Studio IDEs. I got libraries "gl" & "glu" with these IDEs. Programs based on these two libs gl & glu are executing well. I want to use "glut" library. So I downloaded glut package and copied it to respective folders i.e. to
2
1687
by: Advait | last post by:
Hello everyone, I am using GCC through DevC++ & Code Block Studio IDEs. I got libraries "gl" & "glu" with these IDEs. Programs based on these two libs gl & glu are executing well. I want to use "glut" library. So I downloaded glut package and copied it to respective folders i.e. to include\GL\glut.h
1
2556
Airslash
by: Airslash | last post by:
Hello, I'm trying to make a simpel renderengine that allows me to draw objects and 3D models. To make it cross-platform i'm working with the glut library supplied by OpenGL. This library requires callback methods to be set for rendering and eventhandeling. The header of my engine looks like this : class RenderDevice { public: RenderDevice(int width, int height, char* const caption);
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.