Abraxas, glad you are tinkering with tbgl too. I don't know if you checked out the example files in the samples directory.
C:\thinBasic\SampleScripts\TbGl
Also in the tbgl help, there is a nice tbgl skeleton file to use that you can flesh out.
[code=thinbasic]'
' TBGL Script Skeleton
'
Uses "TBGL"
Dim hWnd As Dword
hWnd = TBGL_CreateWindowEx("My Demo - press ESC to quit", 640, 480, 32, 0)
TBGL_ShowWindow
TBGL_GetAsyncKeyState(-1) ' Resets status of all keys
While TBGL_IsWindow(hWnd)
tbgl_ClearFrame
tbgl_DrawFrame
If TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
[/code]
Here is an example with textures from the sample files:
[code=thinbasic]'
' TBGL 0.1.6 Demoscript : Textured and blended square
'
' Petr Schreiber 2006
'
Uses "TBGL"
Uses "UI"
DIM hWnd AS dword
MSGBOX 0, "Welcome to the TBGL module demonstration"+$LF+$LF+"It displays colorful textured rotating square, with some advanced blending", %MB_ICONINFORMATION, "TBGL demo"
hWnd = TBGL_CreateWindow("Textured and blended square - press ESC to quit") ' Creates OpenGL window, it returns handle
TBGL_ShowWindow ' Shows the window
TBGL_LoadTexture App_SourcePath+"Test.bmp",1,%TBGL_TEX_MIPMAP ' Loads texture as #1, with best quality
TBGL_UseTexture 1 ' I want to use textures
TBGL_BindTexture 1 ' I want to use texture #1
GetAsyncKeyState(%VK_ESCAPE) ' Resets ESC key status before checking
While isWindow(hWnd)
TBGL_ClearFrame ' Prepares clear frame
TBGL_Camera 0,0,5,0,0,0 ' Setups camera to look from 0,0,5 to 0,0,0
TBGL_Rotate GetTickCount/10,1,1,1 ' Rotates around all axis ( 1 enables axis, 0 disables )
TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_TexCoord2d 0,0 ' Sets texture coordinate for this vertex
TBGL_Vertex -1,-1,0 ' Adds vertex
TBGL_TexCoord2d 1,0
TBGL_Vertex 1,-1,0
TBGL_TexCoord2d 1,1
TBGL_Vertex 1, 1,0
TBGL_TexCoord2d 0,1
TBGL_Vertex -1, 1,0
TBGL_EndPoly ' Ends polygon definition
TBGL_UseBlend 1 ' Use blending
TBGL_Translate 0,0,1 ' This polygon will be moved by 1 in Z axis
TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4polys
TBGL_Color 255,0,0 ' Sets RGB color
TBGL_TexCoord2d 0,0
TBGL_Vertex -1,-1,0 ' Adds vertex
TBGL_Color 0,255,0
TBGL_TexCoord2d 1,0
TBGL_Vertex 1,-1,0
TBGL_Color 0,0,255
TBGL_TexCoord2d 1,1
TBGL_Vertex 1, 1,0
TBGL_Color 255,255,255
TBGL_TexCoord2d 0,1
TBGL_Vertex -1, 1,0
TBGL_EndPoly ' Ends polygon definition
TBGL_UseBlend 0 ' Don't use blending
TBGL_DrawFrame ' Swaps the buffers - displays rendered image
if GetAsyncKeyState(%VK_ESCAPE) THEN exit while
wend
TBGL_DestroyWindow ' Closes OpenGL window
MSGBOX 0, "Show is over", %MB_ICONINFORMATION or %MB_TOPMOST, "TBGL demo"[/code]
You can only at the moment use bmp and tga files and they need to be in the power of 2's: 32,64,128,256,512,1024 etc.
Bookmarks