' Empty GUI script created on 06-22-2009 13:32:46 by (ThinAIR)
uses "TBGL" ' thinBASIC OpenGL Library
' Declare Variables here
dim rquad as single ' Quad Rotation
dim frameRate as double ' Timing Variable
' Create Display, Return Handle.
dim hWnd as dword
dim bits as long = 32
hWnd = tbgl_createwindowex(" - Press 'Esc' to Quit", 640, 480, bits, %TBGL_WS_WINDOWED)
tbgl_showwindow ' Show Display
' -- color definition
TYPE SuperBox_RGB
R AS BYTE
G AS BYTE
B AS BYTE
END TYPE
' -- auxiliary names
begin const
%top = 1
%bottom
%front
%back
%left
%right
end const
' -- Array of colors
Dim CustomColor(6) as SuperBox_RGB
with CustomColor(%top)
.R = 255
.G = 255
.B = 255
end with
with CustomColor(%bottom)
.R = 255
.G = 255
.B = 0
end with
with CustomColor(%front)
.R = 255
.G = 0
.B = 0
end with
with CustomColor(%back)
.R = 0
.G = 255
.B = 255
end with
with CustomColor(%left)
.R = 0
.G = 0
.B = 255
end with
with CustomColor(%right)
.R = 255
.G = 0
.B = 255
end with
TBGL_ResetKeyState() ' Reset all Keys
' Start Main Loop
while tbgl_iswindow(hWnd)
frameRate = tbgl_getframerate
tbgl_clearframe ' Clear Display
tbgl_camera 0,0,1,0,0,0 ' Default Camera, View From 0,0,1 To 0,0,0.
TBGL_Translate 0.0, 0.0, -7.0 ' Move Right 1.5 Units, Into the Screen 7 Units.
TBGL_Rotate rquad, 1.0, 1.0, 1.0 ' X,Y & Z Axis Rotations.
' -- Super box takes dimnesions and color array as parameters
SuperBox 2, 1, 1, CustomColor
rquad -= ( 27.0 / frameRate ) ' Increase Quad Rotation
tbgl_drawframe ' Display anything
if tbgl_getWindowkeystate(hWnd, %VK_ESCAPE) then exit while
wend
tbgl_destroywindow ' Closes Display
' ------------------
' SuperBox procedure
' ------------------
SUB SuperBox(a as single, b as single , c as single, Colors() as SuperBox_RGB )
TBGL_BeginPoly %GL_QUADS
' Top Quad
TBGL_Color Colors(1).R, Colors(1).G, Colors(1).B
TBGL_Vertex a, b, -c ' Top Right
TBGL_Vertex -a, b, -c ' Top Left
TBGL_Vertex -a, b, c ' Bottom Left
TBGL_Vertex a, b, c ' Bottom Right
' Bottom Quad
TBGL_Color Colors(2).R, Colors(2).G, Colors(2).B
TBGL_Vertex a, -b, c ' Top Right
TBGL_Vertex -a, -b, c ' Top left
TBGL_Vertex -a, -b, -c ' Bottom Left
TBGL_Vertex a, -b, -c ' Bottom Right
' Front Quad
TBGL_Color Colors(3).R, Colors(3).G, Colors(3).B
TBGL_Vertex a, b, c ' Top Right
TBGL_Vertex -a, b, c ' Top Left
TBGL_Vertex -a, -b, c ' Bottom Left
TBGL_Vertex a, -b, c ' Bottom Right
' Back Quad
TBGL_Color Colors(4).R, Colors(4).G, Colors(4).B
TBGL_Vertex a, -b, -c ' Bottom Left
TBGL_Vertex -a, -b, -c ' Bottom Right
TBGL_Vertex -a, b, -c ' Top Right
TBGL_Vertex a, b, -c ' Top Left
' Left Quad
TBGL_Color Colors(5).R, Colors(5).G, Colors(5).B
TBGL_Vertex -a, b, -c ' Top Right
TBGL_Vertex -a, -b, -c ' Top Left
TBGL_Vertex -a, -b, c ' Bottom Left
TBGL_Vertex -a, b, c ' Bottom Right
' Right Quad
TBGL_Color Colors(6).R, Colors(6).G, Colors(6).B
TBGL_Vertex a, b, -c ' Top Right
TBGL_Vertex a, b, c ' Top Left
TBGL_Vertex a, -b, c ' Bottom Left
TBGL_Vertex a, -b, -c ' Bottom Right
TBGL_EndPoly
END SUB