Hi Zak,
I must say I still like the prefix way - and I think it will work in future better for stuff like code completion this way... (you first specify module, which quickly differentiates TBGL_IsWindow from UI module IsWindow) but that does not mean there is no solution to this problem
As thinBASIC supports ALIAS keyword, you can redefine all the function names to suit your preference. Even better, such a keyword mod can be done in automated way using thinBasic itself
Just run this script once, it will generate new, complete alias include file for you:
Uses "File"
uses "TBGL"
Dim sListOfKeywords As String
Dim Keyword() As String
Dim nKeywords As Long
Dim i As Long
Dim sFileContent As String
sListOfKeywords = APP_ListKeywords
'---Parse string into an array
nKeywords = Parse(sListOfKeywords, Keyword, $TAB)
'---Creates output buffer
sFileContent = "' This is include file of Zak's custom names for TBGL" + $CRLF(2)
For i = 1 To nKeywords
If StartsWith(Keyword(i), "TBGL_") Then
sFileContent += "ALIAS " + Keyword(i) + " AS " + PetrsTBGLNameToZaksTBGLName(Keyword(i))+ $CRLF
End If
NEXT
'---Save buffer into .INC file
FILE_Save(APP_Path + "\Inc\" + "CustomTBGLFunctionNames.inc", sFileContent)
Function PetrsTBGLNameToZaksTBGLName( sNameIn As String ) As String
sNameIn = Remove$(sNameIn, "TBGL_")
sNameIn += "_GL"
Return sNameIn
End Function
... and then, in your programs, just use:
#INCLUDE "CustomTBGLFunctionNames.inc"
... like in this example:
Uses "TBGL"
#INCLUDE "CustomTBGLFunctionNames.inc"
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
' -- Create and show window
hWnd = CreateWindowEx_GL("TBGL script - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
ShowWindow_GL
' -- Initialize lighting
UseLighting_GL(%TRUE)
UseLightSource_GL(%GL_LIGHT0, %TRUE)
SetLightParameter_GL(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1)
' -- Resets status of all keys
ResetKeyState_GL()
' -- Main loop
While IsWindow_GL(hWnd)
FrameRate = GetFrameRate_GL
ClearFrame_GL
Camera_GL(15, 15, 15, 0, 0, 0)
Color_GL(255, 128, 0)
Box_GL(1, 1, 1)
DrawFrame_GL
' -- ESCAPE key to exit application
If GetWindowKeyState_GL(hWnd, %VK_ESCAPE) Then Exit While
Wend
DestroyWindow_GL
End Function
I know the TBGL_ prefix can be annoying, maybe in future when some dark magic like namespaces will be supported, you will be able to do something like:
USING TBGL
CreateWindowEx(...)
ShowWindow
ResetKeyState()
END USING
and so on. But that would need major change in the parser and also the IDE (to still provide context sensitive help), so I guess this is not comming that soon. But I hope the include file way is acceptable for you at the moment.
Petr