' Empty GUI script created on 11-16-2010 20:15:22 by (ThinAIR)
Uses "TBGL"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_gl.inc"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_glu.inc"
Global angle As Double
Global dx, dy, theta, Alpha, n0, n1, n2,a,b As Double
Global wd, ht, i, th, ta As Long
Global mouseX, mouseY As Single
wd = 600
ht = 600
Global hWnd As DWord
Global x, y As DWord
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
' -- Create and show window
hWnd = TBGL_CreateWindowEx("Parametric Plots - press ESC to quit", wd, ht, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' -- Initialize lighting
TBGL_UseLighting(%TRUE)
TBGL_UseLightSource(%GL_LIGHT0, %TRUE)
While TBGL_IsWindow(hWnd)
TBGL_ResetKeyState()
mouseX = TBGL_MouseGetPosX
mouseY = TBGL_MouseGetPosY
dx=mouseX: dy=mouseY
funRender()
'dx += 10
'dy += 10
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
End Function
' -- Do any calculations here
Function funIdle( hWnd As DWord, frameRate As Double )
dx += 10
dy += 10
End Function
' -- Handle input here
Function funInput( hWnd As DWord, frameRate As Double )
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then
TBGL_UnBindPeriodicFunction(hWnd)
Exit Function
End If
End Function
Function drawtor()
glBegin(%GL_TRIANGLE_STRIP)
For th = 0 To 360 Step 15
For ta = 0 To 360 Step 15
drawvert(th,ta)
drawvert(th+12,ta)
Next
Next
glEnd
End Function
Function drawvert (ByVal th As Integer, ByVal ta As Integer)
theta = th*0.01745
Alpha = ta*0.01745
a = 1.5
n0 = 0.5*a*Sin(alpha)*Sin(2*theta)
n1 = a*Sin(2*alpha)*Sin(theta)*Sin(theta)
n2 = a*Cos(2*alpha)*Sin(theta)*Sin(theta)
glColor3f(n0,Sin(n1),Cos(n2))
glVertex3f(n0,n1,n2)
End Function
Function funRender()
Dim hWnd As DWord = TBGL_CallingWindow
Dim FrameRate As Double
frameRate = TBGL_GetFrameRate
' -- Process input
funIdle( hWnd, FrameRate)
' -- Process calculations
funInput( hWnd, FrameRate )
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_Camera(3, 3, 3, 0, 0, 0)
TBGL_GetWindowClient( hWnd, x, y )
TBGL_Rotate(dx,0.0, 1.0, 0.0)
TBGL_Rotate(dy, 1.0, 0.0, 0.0)
TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 100, 100, 100, 1)
drawtor()
TBGL_DrawFrame
End Function
Bookmarks