with Gtk.Main; with Gtk.Window; use Gtk.Window; with Glu_H; use Glu_H; with GL_H; use GL_H; with Gtk.Glarea; use Gtk.Glarea; with Gdk.GL; use Gdk.Gl; with Ada.Text_IO; use Ada.Text_IO; with Gdk.Event; use Gdk.Event; with Gtk.Handlers; use Gtk.Handlers; package body OpenGL is function InitGL(Area : access Gtk_GLArea_Record'Class) return Boolean is begin if Make_Current(Area) then Glclearcolor(0.0,0.0,0.0,0.0); Glenable(GL_DEPTH_TEST); Glshademodel(GL_SMOOTH); end if; return True; end InitGL; function Reshape(Area : access Gtk_GLArea_Record'Class; Event : Gdk_Event) return Boolean is begin if Get_Count(Event) > 0 then return True; end if; if Make_Current(Area) then Glviewport(0,0,500,500); Glmatrixmode(GL_PROJECTION); Glloadidentity; Gluperspective(Long_Float (45.0), Long_Float(1.3), 1.0,100.0); Glmatrixmode(GL_MODELVIEW); Glloadidentity; end if; return True; end Reshape; function Display(Area: access Gtk_GLArea_Record'Class; Event : Gdk_Event) return Boolean is begin if Make_Current(Area) then Glclear(GL_COLOR_BUFFER_BIT); Glclear(GL_DEPTH_BUFFER_BIT); Glloadidentity; Gltranslatef(0.0,0.0,-5.0); Glbegin(GL_QUADS); Glvertex3f(-2.0,0.0,0.0); Glvertex3f(-2.0,2.0,0.0); Glvertex3f(2.0,2.0,0.0); Glvertex3f(2.0,0.0,0.0); Glend; Swap_Buffers(Area); end if; return True; end Display; end OpenGL;