i played a little around- somehow i fear if i set up different fov/aspect the GBuffer-Entity is not affected by the setting as i know it from 3d-fonts - not tried out yet...
But anyway I wrapped a little -all hidden at heap-memory, be surprised what's possible in thinBasic - and the code reads now like that:
Uses "TBGL"
#INCLUDE "t_Entity.tBasicU"
Begin Const
' -- Scene IDs
%sScene = 1
End Const
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
' -- Create and show window
hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit", _
640, 480, 32, _
%TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX )
TBGL_ShowWindow
' -- Create scene
TBGL_SceneCreate(%sScene)
' create entities from 0 - don't have even a real local variable
Local Entity As t_Entity At 0
SetAt( Entity, Entity.Create(%sScene, %TBGL_CAMERA) )
Entity.SetPos(0, 10, 20)
Entity.SetTargetPos( 0, 0, 0)
%hCamera = GetAt( Entity ) As DWord ' if want to store it...
' -- Create directional light, don't need its ptr...
SetAt( Entity, Entity.Create(%sScene, %TBGL_LIGHT, %TBGL_LIGHTTYPE_DIRECTIONAL) )
Entity.SetPos(0, 25, 20) ' above camera
Entity.SetTargetPos( 0, 0, 0)
Entity.SetParent( %hCamera )
' -- Define data for mesh
' -- Vertices
Dim VertexA(3) As TBGL_TVECTOR3F At HEAP_Alloc( 3 * SizeOf(TBGL_TVECTOR3F) )
VertexA(1).x = -2
VertexA(1).y = -2
VertexA(1).z = 0
VertexA(2).x = 2
VertexA(2).y = -2
VertexA(2).z = 0
VertexA(3).x = 0
VertexA(3).y = 2
VertexA(3).z = 0
' -- Colors
Dim ColorA(3) As TBGL_TRGB At HEAP_Alloc( 3 * SizeOf(TBGL_TRGB) )
ColorA(1).r = 255
ColorA(1).g = 128
ColorA(1).b = 64
ColorA(2).r = 0
ColorA(2).g = 255
ColorA(2).b = 0
ColorA(3).r = 0
ColorA(3).g = 0
ColorA(3).b = 255
' -- Entity
%hTriangle = Entity.Create(%sScene, _
%TBGL_GBufferStatic, _
%TBGL_TRIANGLES, _
GetAt(VertexA), _
GetAt(ColorA) )
TBGL_ResetKeyState()
' -- Main loop
While TBGL_IsWindow(hWnd)
FrameRate = TBGL_GetFrameRate
TBGL_ClearFrame
TBGL_SceneRender(%sScene)
TBGL_DrawFrame
' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then
SetAt( Entity, %hTriangle )
Entity.Turn( 0,-90/FrameRate, 0)
ElseIf TBGL_GetWindowKeyState(hWnd, %VK_RIGHT) Then
SetAt( Entity, %hTriangle )
Entity.Turn( 0, 90/FrameRate, 0)
ElseIf TBGL_GetWindowKeyState(hWnd, %VK_UP) Then
SetAt( Entity, %hCamera )
Entity.Move( 0, 16/FrameRate, 0 )
Entity.SetTarget( %hTriangle )
ElseIf TBGL_GetWindowKeyState(hWnd, %VK_DOWN) Then
SetAt( Entity, %hCamera )
Entity.Move( 0, -16/FrameRate, 0 )
Entity.SetTarget( %hTriangle )
EndIf
Wend
TBGL_DestroyWindow
End Function
just a raw sketch, the entity does not have a texture yet, neither is the DisplayList-creation done...
As you probably see- it's all arranged to have a future Mesh-udt that's single entities (groups) can have different types of data.
Bookmarks