!/*
! *
! * Olympic Rings program
! *
! * The files in this program include:
! *    Tolympic.f90
! *    Tolympa.f90
! *    Tolympb.f90
! *    Tolympc.f90
! *    Tolympd.f90
! *    Tolympe.f90
! *
! * To compile this program, use the following switches:
! *   df /libs:qwin /fpscomp:logicals
! * Or, if using the IDE to build the project, 
! *  Under SETTINGS, the Fortran Tab, 
! *     Compatibility section, set the "logicals" check box
! *     Libraries section, select QuickWin from the list box
! */


use dfopngl
use olympinc

interface
subroutine DrawScene ()
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_DrawScene@0' :: DrawScene
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'DrawScene' :: DrawScene
!DEC$ ENDIF
end subroutine DrawScene

subroutine ReshapeFunction (width, height)
!DEC$ IF DEFINED(_X86_)
!DEC$  ATTRIBUTES STDCALL, ALIAS : '_ReshapeFunction@8' :: ReshapeFunction
!DEC$ ELSE
!DEC$  ATTRIBUTES STDCALL, ALIAS : 'ReshapeFunction' :: ReshapeFunction
!DEC$ ENDIF
integer(4)  width
integer(4)  height
end subroutine ReshapeFunction

subroutine Key_SPACE ()
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_Key_SPACE@0' :: Key_SPACE
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'Key_SPACE' :: Key_SPACE
!DEC$ ENDIF
end subroutine Key_SPACE

integer(4) function Args (argc)
!DEC$ ATTRIBUTES VALUE :: argc
integer(4)  argc
end function Args

end interface

EXTERNAL Init

integer(4)  argc
integer(4) type

    argc = nargs()
    if (Args (argc) == GL_FALSE) then
      call fauxQuit()
    end if

    call fauxInitPosition(0, 0, 400, 300)

   if (rgbmode) then
      type = AUX_RGB
   else
      type = AUX_INDEX
   end if

   if (doublebuffer) then
      type = IOR(type, AUX_DOUBLE)
   else
      type = IOR(type, AUX_SINGLE)
   end if

   call fauxInitDisplayMode(type)

   if (fauxInitWindow("Olympic"C) == GL_FALSE) then
        call fauxQuit()
   end if

   call Init()

   call fauxExposeFunc(LOC(ReshapeFunction))
   call fauxReshapeFunc(LOC(ReshapeFunction))
   call fauxKeyFunc(AUX_SPACE, LOC(Key_SPACE))
   call fauxIdleFunc(LOC(DrawScene))

   call fauxMainLoop(NULL)
end
