[code=thinbasic]
' Example: Section 6.6 (page 14, Predator-prey Relationships
' From Stan Blank's Book:
' "Python Programming in OpenGL
' "A Graphical Approach to Programming
' Converted by Michael Clease
' Last modified: February 26, 2010
' thinBasic does not use GLUT, we use instead tbgl
Uses "TBGL"
' Handle for our window
Local hWnd As DWord
Local Width As Long
Local Height As Long
Local x,y As Double
Local a,b,c As Double
Local e,dt As Double
Local v, n As Double
'# Initial values of width And height
width = 400
height = 400
'
' Create and show window
hWnd = TBGL_CreateWindowEx("Predator-prey Relationships", Width, Height, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' Set Foreground from default White to Green
TBGL_Color(76,152,51)
' Set background from default black to white
TBGL_BackColor(255,255,255)
' Init OpenGl, like gluOrtho2D in example code
TBGL_RenderMatrix2D( 0, 0, 10, 6 )
' Resets status of all keys
TBGL_ResetKeyState()
TBGL_PointSize 1
dt = 0.001
' Main loop
While TBGL_IsWindow(hWnd)
a = 0.7
b = 0.5
c = 0.3
e = 0.2
x = 0.5
y = 0.5
TBGL_ClearFrame
For n = 0 To 10 Step 0.0001
'# predator-prey equations
x = x + (a*x - b*x*y)*dt
y = y + (-c*y + e*x*y)*dt
TBGL_BeginPoly(%GL_POINTS)
TBGL_Color(255,0,0)
TBGL_Vertex(n,x)
TBGL_Color(0,0,255)
TBGL_Vertex(n,y)
TBGL_Color(0,0,0)
TBGL_Vertex(x,y)
TBGL_EndPoly
Next
TBGL_DrawFrame
dt += 0.0001
If dt > 0.005 Then dt = 0.001
' ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
[/code]
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
This is a neat one in that you get quite a complex looking sequence with short easy to follow code. I like the name of the example too.
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Bookmarks