#include <gl.au3>

Opt("GUIOnEventMode", 1)

Local $rotation = 0

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)
glEnable($GL_DEPTH_TEST)

GUISetState()


While 1
	glClear($GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT)
	glLoadIdentity()

	glRotatef(45, 1, 0, 1)
	glRotatef($rotation, 0, 1, 0)

	glBegin($GL_QUADS)
		glColor3f(0, 0, 0)
		glVertex3f(-.5, -.5, -.5)
		glColor3f(0, 0, 1)
		glVertex3f(-.5, -.5,  .5)
		glColor3f(0, 1, 1)
		glVertex3f(-.5,  .5,  .5)
		glColor3f(0, 1, 0)
		glVertex3f(-.5,  .5, -.5)

		glColor3f(1, 0, 0)
		glVertex3f( .5, -.5, -.5)
		glColor3f(1, 0, 1)
		glVertex3f( .5, -.5,  .5)
		glColor3f(1, 1, 1)
		glVertex3f( .5,  .5,  .5)
		glColor3f(1, 1, 0)
		glVertex3f( .5,  .5, -.5)

		glColor3f(0, 0, 0)
		glVertex3f(-.5, -.5, -.5)
		glColor3f(0, 0, 1)
		glVertex3f(-.5, -.5,  .5)
		glColor3f(1, 0, 1)
		glVertex3f( .5, -.5,  .5)
		glColor3f(1, 0, 0)
		glVertex3f( .5, -.5, -.5)

		glColor3f(0, 1, 0)
		glVertex3f(-.5,  .5, -.5)
		glColor3f(0, 1, 1)
		glVertex3f(-.5,  .5,  .5)
		glColor3f(1, 1, 1)
		glVertex3f( .5,  .5,  .5)
		glColor3f(1, 1, 0)
		glVertex3f( .5,  .5, -.5)

		glColor3f(0, 0, 0)
		glVertex3f(-.5, -.5, -.5)
		glColor3f(0, 1, 0)
		glVertex3f(-.5,  .5, -.5)
		glColor3f(1, 1, 0)
		glVertex3f( .5,  .5, -.5)
		glColor3f(1, 0, 0)
		glVertex3f( .5, -.5, -.5)

		glColor3f(0, 0, 1)
		glVertex3f(-.5, -.5,  .5)
		glColor3f(0, 1, 1)
		glVertex3f(-.5,  .5,  .5)
		glColor3f(1, 1, 1)
		glVertex3f( .5,  .5,  .5)
		glColor3f(1, 0, 1)
		glVertex3f( .5, -.5,  .5)
	glEnd()

	$rotation = $rotation + 0.5

	glSwapBuffers($dc)
WEnd

Func quit()
	glTerminate($gui, $dc, $rc)
	Exit
EndFunc