Uses "TBGL"
Global hWnd As Long, ax, ay As Single
hWnd = TBGL_CreateWindowEx("ESC to exit; arrow keys to rotate", 1024, 768, 32, _
%TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
Do While TBGL_IsWindow(hWnd) And _
Not TBGL_GetWindowKeyOnce(hWnd, %VK_ESCAPE)
If TBGL_GetWindowKeyState(hWnd, %VK_DOWN) Then ax+= 1.44 ' 10sec/rev
If TBGL_GetWindowKeyState(hWnd, %VK_UP) Then ax-= 1.44
If TBGL_GetWindowKeyState(hWnd, %VK_RIGHT) Then ay+= 1.44
If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then ay-= 1.44
TBGL_ClearFrame
TBGL_Camera 1,1,4, 0,0,0
TBGL_RotateXYZ ax, ay, 0
TBGL_Color 255,255,255
TBGL_Line 0,0,0, 1,0,0 ' axes
TBGL_Line 0,0,0, 0,1,0
TBGL_Line 0,0,0, 0,0,1
TBGL_Color 255,0,0
zrect .1,.1,.1, .1,.2,.2 ' in yz plane
TBGL_Rect .1,.1,.1, .1,.2,.2
TBGL_Color 0,255,0
zrect .3,.3,.3, .4,.3,.4 ' in zx plane
TBGL_Rect .3,.3,.3, .4,.3,.4 ' where is this rectangle?
TBGL_Color 0,0,255
zrect .5,.5,.5, .6,.6,.5 ' in xy plane
TBGL_Rect .5,.5,.5, .6,.6,.5
TBGL_DrawFrame
Sleep 40
Loop
' this sub draws outline only
Sub zRect(x1 As Single, y1 As Single, z1 As Single, _
x2 As Single, y2 As Single, z2 As Single)
If x1=x2 Then ' in yz plane
TBGL_BeginPoly %GL_LINE_LOOP
TBGL_Vertex x1,y1,z1
TBGL_Vertex x1,y2,z1
TBGL_Vertex x1,y2,z2
TBGL_Vertex x1,y1,z2
TBGL_EndPoly
ElseIf y1=y2 Then ' in zx plane
TBGL_BeginPoly %GL_LINE_LOOP
TBGL_Vertex x1,y1,z1
TBGL_Vertex x1,y1,z2
TBGL_Vertex x2,y1,z2
TBGL_Vertex x2,y1,z1
TBGL_EndPoly
ElseIf z1=z2 Then ' in xy plane
TBGL_BeginPoly %GL_LINE_LOOP
TBGL_Vertex x1,y1,z1
TBGL_Vertex x2,y1,z1
TBGL_Vertex x2,y2,z1
TBGL_Vertex x1,y2,z1
TBGL_EndPoly
Else
TBGL_Line x1,y1,z1, x2,y2,z2
End If
End Sub