comp.lang.ada
 help / color / mirror / Atom feed
* problems with GLUT
@ 1998-11-06  0:00 Knut Wannheden
  1998-11-07  0:00 ` Jerry van Dijk
  0 siblings, 1 reply; 2+ messages in thread
From: Knut Wannheden @ 1998-11-06  0:00 UTC (permalink / raw)



-- 
I have problems with GLUT and the menu callback function. I have written a program with ObjectAda 7.1.1 and GLUT 3.6. For some reason the program always crashes when I select an entry in a pop-up menu that I have added to the program's window.
There seems to be something strange with the menu callback function; I register the callback with glutCreateMenu(). The callback function is supposed to take one argument (Integer). If I register a callback function that takes no arguments then the program doesn't crash. Of course I'd want to do something with the argument ;)
Has anyone else experienced similar problems before?

Knut Wannheden




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problems with GLUT
  1998-11-06  0:00 problems with GLUT Knut Wannheden
@ 1998-11-07  0:00 ` Jerry van Dijk
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry van Dijk @ 1998-11-07  0:00 UTC (permalink / raw)


Knut Wannheden (d96knut@dtek.chalmers.se) wrote:

: I register the callback with glutCreateMenu(). The callback function is 
: supposed to take one argument (Integer).

The argument of glutCreateMenu is a procedure access type.
The procedure accessed takes 1 argument which is an Integer that tells
you which entry was selected.

Example:

Here I create a pop-menu to select a color:

   -----------------------
   -- window color menu --
   -----------------------

   Color_Submenu := Glut.glutCreateMenu (SelectColor'Unrestricted_Access);
   Glut.glutAddMenuEntry (Green_String, 1);
   Glut.glutAddMenuEntry (Red_String, 2);
   Glut.glutAddMenuEntry (White_String, 3);

Activate it as a submenu:

   Glut.glutAttachMenu (Glut.GLUT_RIGHT_BUTTON);

Here is the callback procedure that actually sets the color:

   -----------------------
   -- window color menu --
   -----------------------

   procedure SelectColor (Color : in Integer) is
   begin
      case Color is
         when 1 => Gl.GlColor3f (0.0, 1.0, 0.0);  -- green
         when 2 => Gl.glColor3f (1.0, 0.0, 0.0);  -- red
         when 3 => Gl.glColor3f (1.0, 1.0, 1.0);  -- white
         when others => null; -- no error handling
      end case;
      Glut.glutPostRedisplay;
   end SelectColor;

Jerry.

-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada
-- Ada & Win32: http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-11-07  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-06  0:00 problems with GLUT Knut Wannheden
1998-11-07  0:00 ` Jerry van Dijk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox