OpenGl and Ada

Hi.
I’m trying to run some example program which I found and it’s not mine but there’s the same problem that I have with my own program.
Here’s the code:
– GlutMain.adb
with Interfaces.C.Strings;
with Win32.Gl; use Win32.Gl;
with Win32.Glu; use Win32.Glu;
with win32.GLUT; use win32.GLUT;

procedure GlutMain is
package ICS renames Interfaces.C.Strings;

use type Interfaces.C.unsigned;

type chars_ptr_ptr is access ICS.chars_ptr;

angle : GLFloat := 0.0;

procedure Display;
pragma Convention (C, Display);

procedure Display is
begin
	-- wyczysc bufor coloru i bufor glebokosci
	glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
	-- resetuj macierz widoku
	glLoadIdentity;

	-- przeksztalc macierz
	glRotatef( angle, 0.0, 0.0, 1.0 );

	-- rozpocznij tryb renderowania
	-- prymitywem: pasy trojkatow
	glBegin( GL_TRIANGLE_STRIP );
		-- ustaw kolor pierwszego wierzcholka
		glColor3f( 1.0, 0.0, 0.0 );
		-- ustaw wspolrzedne wierzcholka
		glVertex3f( -0.6, 0.6, -2.0 );
		-- i podobnie dla pozostalych wierzcholkow:
		glColor3f( 0.0, 1.0, 0.0 );
		glVertex3f( -0.6, -0.6, -2.0 );
		glColor3f( 1.0, 0.0, 1.0 );
		glVertex3f( 0.6, 0.6, -2.0 );
		glColor3f( 0.0, 0.0, 1.0 );
		glVertex3f( 0.6, -0.6, -2.0 );
	glEnd;

	-- zwieksz kat obrotu
	angle := angle + 0.02;

	glFlush;
	glutSwapBuffers;
end Display;

-- importuj wartosci 'argc'
argc : aliased integer;
pragma Import (C, argc, "gnat_argc");

-- importuj wartosci 'argv'
argv : chars_ptr_ptr;
pragma Import (C, argv, "gnat_argv");

-- uchwyt okna GLUT
win : Integer;

begin
– Stworz okno, i ustaw tryb graficzny
glutInit( argc’Access, argv );
glutInitDisplayMode( GLUT_RGBA or GLUT_DEPTH or GLUT_DOUBLE );
glutInitWindowSize( 500, 500 );
glutInitWindowPosition( 200, 400 );
win := glutCreateWindow( “GlutMain” );

-- ustaw macierze oraz obszar obcinania
glViewport( 0, 0, 500, 500 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity;
gluPerspective( 45.0, 1.0, 0.1, 100.0 );
glMatrixMode( GL_MODELVIEW );

-- procedura rysujaca klatke animacji
glutDisplayFunc( Display'Unrestricted_Access );
glutIdleFunc( Display'Unrestricted_Access );
-- petla glowna
glutMainLoop;

end GlutMain;

When I execute it there’s a message: raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION
I know that there is a problem with assignment to variable angle any value inside the Display procedure but I have no idea why it doesn’t work.
Thanks in adavnce.

I have no idea about ADA, but if I was you I’d use GNAT under linux or one of the many BSDs and then gdb. It shows exactly (in the backtrace), where the crash occurs. If you are a power user, you could also try to use GNAT and gdb under cygwin.

Otherwise, your code is very basic and I don’t see anything wrong with it. I am not certain you can simply point the idle func to your rendering func. I usually do it like this:

glutPostRedisplay();

in a separate idling function. Of course, that’s C++. I strongly suggest you stop using ADA and move on to something more common, e.g. Python or just to plain C/C++. The more people use a language, the more help you will get with your problems and the easier they will be to debug.