#include <gl.au3>

Opt("GUIOnEventMode", 1)

Global $gui = GUICreate("OpenGL", 250, 250), $dc, $rc
GUISetOnEvent(-3, "quit")

If Not glinit($gui, $dc, $rc) Then
    MsgBox(48, "Error", "Error bei der Initialisierung von OpenGL-Funktionen" & @CRLF & "Error code: " & @error)
    Exit
EndIf

glMatrixMode($GL_PROJECTION)

GUISetState()


While GUIGetMsg() <> -3

    glClear($GL_COLOR_BUFFER_BIT)

    glBegin($GL_QUADS)

    glColor4f(1, 0, 0, 0)
    glVertex4f(0, .5, 0, 1)
    glColor4f(0, 1, 0, 0)
    glVertex4f( -.5, 0, 0, 1)
	glColor4f(1, 1, 0, 0)
    glVertex4f(0, -.5, 0, 1)
    glColor4f(0, 0, 1, 0)
    glVertex4f( .5, 0, 0, 1)

    glEnd()

    glSwapBuffers($dc)
WEnd

Func quit()
	glTerminate($gui, $dc, $rc)
	Exit
EndFunc