Hi Peter,
I modified your code a little - it contained two TBGL_DrawFrame calls, which negated the effect of drawn text.
I also did few minor tweaks to make it draw faster - cache it first, then draw using single line of code. I hope you will like it.
#MINVERSION 1.8.9.0
Uses "TBGL"
Function TBMain()
' -- Create window
DWord hWnd = TBGL_CreateWindowEx("FERN DEMO - press escape to continue", 800, 600, 32, %TBGL_WS_WINDOWED | %TBGL_WS_DONTSIZE | %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow
' -- Setup rendering coordinates and back color
TBGL_RenderMatrix2D (0, 0, 800, 600)
TBGL_BackColor 0,0,155
DWord hFont= TBGL_FontHandle("Arial", 72)
TBGL_BuildFont(hfont)
TBGL_SetActiveFont(1)
Long wa
Long cachedFern
TBGL_NewListSpace(cachedFern)
' -- Cache the fern
TBGL_NewList cachedFern
For wa=0 To 20000
fern()
Next
TBGL_EndList
TBGL_ResetKeyState()
' -- Begin the rendering loop
While TBGL_IsWindow(hWnd)
' -- Clear the frame
TBGL_ClearFrame
' -- Set white color
TBGL_Color 255,255,255
' -- Enable printing
TBGL_PrintFont "FERN",300,350
' -- Dynamic color for the fern
TBGL_Color 127+Sin(GetTickCount/1000)*128, 127+Sin(GetTickCount/1000+2)*128, 127+Sin(GetTickCount/1000+4)*128
' -- Render the fern in one call
TBGL_CallList cachedFern
TBGL_DrawFrame
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
End Function
Sub Fern()
' -- STATIC variables remember their values between function calls
Static a, b, c, d, e, f, newx, newy As Single
Static r, wa As Long
Static xy(2) As Single
r = Rnd(0,100)
If r <= 10 Then
a = 0
b = 0
c = 0
d = 0.16
e = 0
f = 0
ElseIf r > 1 And r <=86 Then
a = 0.85
b = 0.04
c = -.04
d = 0.85
e = 0
f = 1.60
ElseIf r > 86 And r <=93 Then
a = 0.2
b = -.26
c = 0.23
d = 0.22
e = 0
f = 0.16
Else
a = -.15
b = 0.28
c = 0.26
d = 0.24
e = 0
f = 0.44
End If
newx = ((a * xy(1)) + (b * xy(2)) + e)
newy = ((c * xy(1)) + (d * xy(2)) + f)
xy(1) = newx
xy(2) = newy
TBGL_Point xy(1)*40+200,xy(2)*40+80
End Sub
I attach source and screenshot for you.
The windowed mode should work for you, if in any doubt, try running thinBASIC diagnostic tool to see if you have OpenGL installed correctly.
Petr
Bookmarks