PDA

View Full Version : very new and young



christianssen
20-02-2010, 13:38
hello dear mr. eros olmi and all friends of thinbasic programming language!

I am entire new in programming language with a basic interpreter. I was looking for a free application and used at some programming courses at my school in afternoon lessons (for volunteers pupils and to get better qualifications for finding a job by big companies for later professional carreer!) some methods of learning with c++, java and now after studied some more knowledge about basic languages I find "thinbasic" (googling, yahooing ).

I am interested in learning more about 3d graphics and effects. And my wish was last autumn to program little application with a basic interpreter (my teacher told about this is possible with freebasic, powerbasic, darkbasic and more...), I have searched for another application it's free and easy to learn for newbies. I will try and use thinbasic, it's a very good looking application I see and a vital community.

I like to speak in friendly kind and have a lot of questions and problems at the beginning, but I am very eager to learn. I like robots and special effects and movies like avatar, star wars, independent days, enterprise, ai, I robot, babylon, such things. I am 17 years old and started with programming six month ago with a little group of friends at school. We used to learn with programming with a free of choice programming language like c++, delphi and my teacher gave directions to basic languages too, I was wondering why ? But now I understood more and see what's possible (I see examples with tbgl, ui, tbdi, openGL features I like) and want to learn more about these exciting stuff. sorry for my bad english, but I will start with easy exercises and build my own ones by starting with little idea to realize working on tbgl or gui application. It's a lot to see and download here, that's horrible :) but great!

thanks to all guys here they have made such a float of good examples to learn. thank you. I suppose it's a really friendly and engaged forum. that's I loved. wish all good times with me, see you, denis christianssen

Petr Schreiber
20-02-2010, 14:04
Hi Denis,

welcome here!

I think you could like ThinBASIC, as it provides multiple resources for game and graphics creation - TBGL(3D graphics, 2D sprites, basic input), TBDI(advanced handling of input devices), TBAI(ready to be used path finding), TBEM(event handling), TBASS(sound - EAX, 3D)

In case you are eager to study TBGL and graphic techniques related to ThinBasic, there are multiple resources:


TBGL Bonus Packs (http://www.thinbasic.com/index.php?option=com_jdownloads&Itemid=95&task=viewcategory&catid=5) - big set of examples, both elemental and advanced, divided into categories.

ThinBasic Journal (http://community.thinbasic.com/index.php?board=160.0) - magazine related to ThinBasic
ThinBasic TBGL Subforum (http://community.thinbasic.com/index.php?board=39.0)

... and of course examples in SampleScripts.

If I may ask, could you tell us where do you study? It is very unusual to give students freedom in choosing the programming language, so I applaud this approach.

Maybe one last advice - make sure to download latest thinBasic BETA (http://community.thinbasic.com/index.php?topic=3214.msg24069#msg24069). They bring the latest fixes and features as soon as possible, and the IDE is most comfortable there.


Have fun here, and feel free to ask!,
Petr

Michael Hartlef
20-02-2010, 14:53
Hi Dennis,

I also welcome you here and encourage you to ask your questions, share your ideas and scripts and also request new functions if a thinbasic module doesn't fit your needs. We are all here to help each other.

Which country are you from?

Best wishes
Michael

kryton9
21-02-2010, 03:20
Hi Dennis,

Welcome to the thinBasic. thinBasic does many things well, so you and your friends will have fun programming for sure.
The community here is very friendly and willing to help so have fun!

ErosOlmi
21-02-2010, 10:31
Ciao Denis and welcome to thinBasic community forum.

I'm too curious about your school and the indication to explore some Basic dialect. Here in Italy at school you can get C, C++, Java, C# and very very hardly other languages unless there are specific projects.

Anyway, remember thinBasic is an interpreted language and not compiled one.

You can use thinBasic for learning because it is quite easy to start with.

You can use thinBasic for User Interface and OpenGL programming (TBGL) and your time will not be wasted because the techniques you will use are not esoteric but quite standard (callbacks).

You can take advantages of the many modules already developed that have encapsulated many programming aspects. As Petr suggested: TBGL (3D graphics, 2D sprites, basic input), TBDI (advanced handling of input devices), TBAI (path finding), TBEM (events handling), TBASS (sound - EAX, 3D), ...

You can ask for new commands if you have an idea of a general keyword that can be used also by other programmers. We will be happy to try to develop it and have native into the language.

That said, have fun.
Ciao
Eros

christianssen
22-02-2010, 20:35
thanks to all for friendly replies! :)

1) ok: I am from goettingen (university town, south region of "niedersachsen", about 200 km south from hannover), father from sweden, mother german woman
we learned at school first of all c++ (basic knowledge), then java and at the afternoon for about 8 students for free a "free of choice" programming language. our young teacher came from university and made suggestion (recommended) to use and learn a basic language, so I found "thinbasic" amoung 10 other apps, but this one has a serious community so far I can say at this moment :) my friends using other basic languages, our project should be to start and fulfill application we are writing next three month. I am with my friend rudger, where I can use internet.

2) my first cut: special theme Fog!
I have used an example from mr. peter schreiber, made a new subroom you have to find and there are two spheres and a cube. it`s a start, not more. I`ve taken tbgl fog example from sample folder of thinbasic.

code example:

'=============================================================================
'= Fog effect =
'= =
'= Petr Schreiber, 2007 =
'=============================================================================

Uses "TBGL"

Dim hWnd As Dword
Dim i, j As Long

type tCamera
DeltaMove as double
DeltaAngle as double
AngleLR as double
AngleUD as double
PointToX as double
PointToY as double
PointToZ as double
PosX as double
PosY as double
PosZ as double
end type
dim Cam as tCamera

' Creates OpenGL window, it returns handle
hWnd = TBGL_CreateWindowEx("City + Blue fog effect + subroom, use arrows to move - press ESC to quit", 800, 600, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow ' Shows the window

MsgBox 0, "use up, down, left, right, pageup, pagedown arrows for moving scene by hand", %MB_OK, "test for city+fog"

TBGL_LoadTexture APP_SourcePath+"Stevenson.bmp", 2, %TBGL_TEX_MIPMAP
TBGL_LoadTexture APP_SourcePath+"Treasure.bmp", 1, %TBGL_TEX_MIPMAP

'=============================================================================
'= The most imortant 3 lines of code in whole program :) :
'=============================================================================
TBGL_SetupFog 0,0,168,168,4 ' Sets attributes of fog: R, G, B, Alpha, and density in percents
TBGL_BackColor 0,0,168
TBGL_BackColor 0,0,168 '+Sin(GetTickCount/500)*200 ' It's good idea to use same color for fog and background
tbgl_UseFog %TRUE ' "Turn on" the fog


Cam.PosY = 18.75 '-10.75
Cam.PosX = -4 '-5

' Now we will create complex 3D model, we will need just one pass,
' then it will be displayed directly from 3D card memory !
%DRAWCITY = 1 ' Designing equate is handy in case of more objects
%BUILDHOUSES = 2
%FLOOR = 3

tbgl_NewList %DRAWCITY
BuildCity()
tbgl_EndList

TBGL_NewList %FLOOR
BuildFLOOR()
TBGL_EndList

TBGL_NewList %BUILDHOUSES
BuildHouses()
TBGL_EndList

dim FrameRate as double

' Resets key status before checking
TBGL_ResetKeyState()

WHILE tbgl_IsWindow(hWnd)

'---Script will run on different PCs so we must assure
'---constant speed of movement by scaling movement relative to framerate
FrameRate = tbgl_GetFrameRate

TBGL_ClearFrame ' Prepares clear frame
TBGL_Camera Cam.PosX,Cam.PosY,Cam.PosZ,Cam.PosX+Cam.PointToX,Cam.PosY,Cam.PosZ+Cam.PointToZ ' Setups Camera
TBGL_Rotate -0.35+Sin(GetTickCount/5000+i+j)*20, 0, 1, 0

TBGL_CallList %DRAWCITY ' Instead of neverending calling to BuildCity and struggling
TBGL_CallList %BUILDHOUSES ' with loops we can use this to speed it up!

TBGL_DrawFrame ' Swaps the buffers - displays rendered image

if TBGL_GetWindowKeyState( hWnd, %VK_UP) then Cam.DeltaMove += 5/FrameRate
if TBGL_GetWindowKeyState( hWnd, %VK_DOWN) then Cam.DeltaMove -= 5/FrameRate

if TBGL_GetWindowKeyState( hWnd, %VK_PGUP) then Cam.PosY += 5/FrameRate
if TBGL_GetWindowKeyState( hWnd, %VK_PGDN) then Cam.PosY -= 5/FrameRate

if TBGL_GetWindowKeyState( hWnd, %VK_RIGHT) then Cam.DeltaAngle += 1/FrameRate

if TBGL_GetWindowKeyState( hWnd, %VK_LEFT) then Cam.DeltaAngle -= 1/FrameRate

if TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE) then EXIT WHILE


' Some math to calculate the next position
Cam.AngleLR = Cam.AngleLR + Cam.DeltaAngle
Cam.PointToX = SIN(Cam.AngleLR)
Cam.PointToZ = -COS(Cam.AngleLR)


Cam.PosX = Cam.PosX + Cam.DeltaMove * Cam.PointToX
Cam.PosZ = Cam.PosZ + Cam.DeltaMove * Cam.PointToZ

Cam.DeltaMove = 0
Cam.DeltaAngle = 0

WEND

TBGL_DestroyWindow ' Closes OpenGL window


' Here we create the city of thinBASIC :)
' All this stuff should be processed every frame
' ... but thanks to "DisplayLists" it's not needed
Function BuildCity() As Long

Local i, j, height, width As Long

tbgl_UseTexturing %TRUE
tbgl_BindTexture 1

For i = -50 To 50 Step 10
For j = -30 To 30 Step 10
height = Rnd(5, 25)

tbgl_BeginPoly %GL_QUADS
tbgl_Color RND(128,255),RND(128,255),RND(128,255)

tbgl_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-1.5+j

tbgl_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,-1.5+j

tbgl_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,-1.5+j

tbgl_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-1.5+j

tbgl_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,1.5+j

tbgl_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,1.5+j

tbgl_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,1.5+j

tbgl_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,1.5+j

tbgl_TexCoord2D 0,0
TBGL_Vertex 2.5+i,0,-1.5+j

tbgl_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,1.5+j

tbgl_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,1.5+j

tbgl_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-1.5+j

tbgl_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-1.5+j

tbgl_TexCoord2D 0,1
TBGL_Vertex -2.5+i,0,1.5+j

tbgl_TexCoord2D 1,1
TBGL_Vertex -2.5+i,height,1.5+j

tbgl_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-1.5+j

tbgl_TexCoord2D 0,0
TBGL_Vertex -2.5+i,height,-1.5+j

tbgl_TexCoord2D 0,1
TBGL_Vertex -2.5+i,height,1.5+j

tbgl_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,1.5+j

tbgl_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-1.5+j

tbgl_EndPoly
Next
Next

tbgl_UseTexturing %FALSE

End Function

' ... but thanks to "DisplayLists" it's not needed
Function BuildHouses() As Long

Local i, j, width As Long

TBGL_UseTexturing %TRUE
TBGL_BindTexture 2

For i = -40 To 40 Step 6
For j = -20 To 20 Step 6
width = Rnd(8, 16)

TBGL_BeginPoly %GL_QUADS
TBGL_Color Rnd(128,255),Rnd(128,255),Rnd(128,255)

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.75+i,0,-1.75+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.75+i,0,-1.75+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.75+i,width,-1.75+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.75+i,width,-1.75+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.75+i,0,1.75+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.75+i,0,1.75+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.75+i,width,1.75+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.75+i,width,1.75+j

TBGL_TexCoord2D 0,0
TBGL_Vertex 2.75+i,0,-1.75+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.75+i,0,1.75+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.75+i,width,1.75+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.75+i,width,-1.75+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.75+i,0,-1.75+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.75+i,0,1.75+j

TBGL_TexCoord2D 1,1
TBGL_Vertex -2.75+i,width,1.75+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.75+i,width,-1.75+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.75+i,width,-1.75+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.75+i,width,1.75+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.75+i,width,1.75+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.75+i,width,-1.75+j
tbgl_EndPoly
Next

Next

'simple Floor
TBGL_Translate 1,-3,0
TBGL_Box(50,-5.75,50)
TBGL_Translate -2,-1,0

TBGL_Sphere 2
TBGL_Translate 12,0,5
TBGL_Rotate 1+Sin(GetTickCount/100)*126,1+Sin(GetTickCount/100)*126,0
TBGL_Sphere 1.75
TBGL_Translate -4,-4.25,6
TBGL_Box 2,4,2.5

TBGL_UseTexturing %FALSE

End Function

Function buildfloor() As Long
TBGL_Box(40,-5.75,40)
End Function


project with three different thinbasic files as zip file. better to start with three examples!

it`s very nice to create such cities and subrooms with tbgl for finding secrets or hiding artefacts! I will do that! I like dungeons with angry monsters and beasts !

perhaps somebody can check the code example, I am sure its not perfect.

good evening, denis

Petr Schreiber
22-02-2010, 20:58
Hi Denis,

thanks for the info!

nice example, I can only suggest one thing - for codes where you move camera, you can use the:
SampleScripts/TBGL/TBGL_Demo6_MovingIn3D_UsingEntitySystem.tbasic

It shows how to use entity system. This way you do not have to calculate camera position yourself, but entity system will do it for you. Entity system is very powerful system to organise your scene, if I may, I suggest you to learn it. You will see the scripts will get more simple and very fast.

When modifying this your example, you can create display list entity (TBGL_EntityCreateDLSlot) to plug your display lists in.


Thanks,
Petr

Michael Hartlef
22-02-2010, 23:27
Hi Dennis,

Petr said it all. And creatings from Leverkusen ;-)

Michael

Lionheart008
24-02-2010, 20:36
hello denis :)

here a little example I have made at my start with tbgl learning. I hope this can help to understand more entity and create TBGL_EntityCreateDLSlot. feel free to ask or making some modifications with this example. nice time here and good luck for learning.


'---------- open gl example with thinbasic by Frank Brübach(Lionheart008), 08.-16.09.2008, with a big help from Petr :-)

'---Load needed modules
Uses "TBGL"
uses "UI"

'------------- message before open the open gl view
DIM RetCode AS LONG
DIM tOut1 AS LONG = 10
DIM tOut2 AS LONG = 5
DIM Msg AS STRING

'--- message possible?

MsgBox (0, "Lionhearts TBGL ActionExample with pyramids, boxes, torus, cruising spheres by lionheart\n
push cursur up, left, right, down to move in 3d space, enjoy it!"+$CRLF(2)+"Press simple Escape to quit window", %MB_ICONINFORMATION, "Colored, floated pyramids, spheres, torus & boxes vol. 6a")


' Rotation Variable
dim angle as single
dim Sheeps as long

' Timing Variables
dim FrameRate as number

'-------- window spezielles

Dim hWnd As Dword

'---Creates OpenGL window and returns handle
hWnd = TBGL_CreateWindowex("Lionhearts LearningEntity with colored pyramid, box, cruising sphere vol. 6a - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED )
'---Shows TBGL window
TBGL_ShowWindow

' -- Create TBGL font
TBGL_BuildFont (TBGL_FontHandle("Arial", 12, %TBGL_BOLD))

' -- First we will create world as place to contain entities
%MY_WORLD = 1
tbgl_SceneCreate(%MY_WORLD)

' -- Our world will have following
BEGIN CONST
%ENT_CAMERA = 1
%ENT_GRIDLIST
%ENT_PYRAMIDLIST1
%ENT_SPHERELIST
%ENT_PYRAMIDLIST2
%ENT_PYRAMIDLIST3

%ENT_AXISFORK
%ENT_BOXLIST1
END CONST

' -- Display lists
BEGIN CONST
%LST_GRID = 1
%LST_PYRAMID
%LST_AXISFORK
%LST_BOX
%LST_SPHERE

END CONST

' .. Camera
tbgl_EntityCreateCamera( %MY_WORLD, %ENT_CAMERA)
tbgl_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 0.0, 1.7, 10.0 )
tbgl_EntitySetTargetPos( %MY_WORLD, %ENT_CAMERA, 0.0, 1.7, 0.0 )

CreateAxisForkAsList()
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_AXISFORK, 0, %LST_AXISFORK )

' .. Grid
' -- Create grid geometry
CreateGridAsDList()
' -- Place it in scene
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST, 0, %LST_GRID )

' -- Create pyramid geometry

CreatePyramidAsList()
' -- Place it in scene ... twice under different names
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_PYRAMIDLIST1, 0, %LST_PYRAMID )
tbgl_EntitySetPos ( %MY_WORLD, %ENT_PYRAMIDLIST1, 0.0, 0.0, 0.0 )

tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_PYRAMIDLIST2, 0, %LST_PYRAMID )
tbgl_EntitySetPos ( %MY_WORLD, %ENT_PYRAMIDLIST2, 1.0, 0.0, -4.0 )

tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_PYRAMIDLIST3, 0, %LST_PYRAMID )
tbgl_EntitySetPos ( %MY_WORLD, %ENT_PYRAMIDLIST3, 0.5, 0.0, -8.0 )

CreateSphereAsList()

tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_SPHERELIST, 0, %LST_SPHERE )
tbgl_EntitySetPos ( %MY_WORLD, %ENT_SPHERELIST, 0.75, 0.0, -6.0 )



' -- Create box geometry
CreateBoxAsList()

tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_BOXLIST1, 0, %LST_BOX )
tbgl_EntitySetPos ( %MY_WORLD, %ENT_BOXLIST1, 1.5, 0.0, -12.0 )


'---Resets key status before checking
TBGL_ResetKeyState()

'---Main script loop
WHILE TBGL_IsWindow(hWnd)

'---Script will run on different PCs so we must assure
'---constant speed of movement by scaling movements relative to frame rate
FrameRate = TBGL_getFrameRate

'---Prepares clear frame
TBGL_ClearFrame

' --Rotate pyramids
TBGL_EntityTurn(%MY_WORLD, %ENT_PYRAMIDLIST1, 0, 90/FrameRate, 0) ' = 90° per second
TBGL_EntityTurn(%MY_WORLD, %ENT_PYRAMIDLIST2, 0,-90/FrameRate, 0) ' =-90° per second
TBGL_EntityTurn(%MY_WORLD, %ENT_PYRAMIDLIST3, 0,-90/FrameRate, 0) ' =-90° per second
TBGL_EntityTurn(%MY_WORLD, %ENT_BOXLIST1, 0,-90/FrameRate, 0) ' =-90° per second
TBGL_EntityTurn(%MY_WORLD, %ENT_SPHERELIST, 0,-90/FrameRate, 0) ' =-90° per second

tbgl_SceneRender(%MY_WORLD)

TBGL_DrawFrame ' Swaps the buffers - displays rendered image

if TBGL_GetwindowKeyState( hWnd, %VK_UP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, 5/FrameRate) ' 5 meters/second
if TBGL_GetwindowKeyState( hWnd, %VK_DOWN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, -5/FrameRate)

if TBGL_GetwindowKeyState( hWnd, %VK_PGUP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 5/FrameRate, 0 )
if TBGL_GetwindowKeyState( hWnd, %VK_PGDN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, -5/FrameRate, 0 )

if TBGL_GetwindowKeyState( hWnd, %VK_LEFT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, 60/FrameRate, 0)
if TBGL_GetwindowKeyState( hWnd, %VK_RIGHT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, -60/FrameRate, 0) ' 60°/second

if TBGL_GetwindowKeyState( hWnd, %VK_F1) then MSGBOX hWnd, "What I did wrong:"+$CRLF+IIF$(len(TBGL_GetLastGLError), TBGL_GetLastGLError, "All ok")

if TBGL_GetwindowKeyState( hWnd, %VK_ESCAPE) then EXIT WHILE

WEND

'---Closes OpenGL window
TBGL_DestroyWindow

function CreateGridAsDList() as long ' Returns to which display list we save
local i, j as long

tbgl_NewList %LST_GRID
'---Let's build a grid
TBGL_BeginPoly %GL_LINES ' Starts polygon definition based on 2 vertex lines
TBGL_Color 0,200,0 ' Defines color

For i = -20 To 20
For j = -20 To 20
TBGL_Vertex -20, 0, j ' Adds vertex
TBGL_Vertex 20, 0, j ' Adds vertex

TBGL_Vertex i, 0, -20 ' Adds vertex
TBGL_Vertex i, 0, 20 ' Adds vertex
Next
Next

TBGL_EndPoly
tbgl_EndList

function = %LST_GRID

END FUNCTION

FUNCTION CreatePyramidAsList() AS LONG
TBGL_NewList %LST_PYRAMID
tbgl_beginpoly %GL_TRIANGLE_FAN
tbgl_color 0, 128, 255 : tbgl_vertex 0.0, 1.0, 0.0
tbgl_color 255, 0, 0 : tbgl_vertex -1.0, -1.0, 1.0
tbgl_color 255, 255, 255 : tbgl_vertex 1.0, -1.0, 1.0
tbgl_color 0, 0, 255 : tbgl_vertex 1.0, -1.0, -1.0
tbgl_color 0, 255, 0 : tbgl_vertex -1.0, -1.0, -1.0
tbgl_color 255, 0, 0 : tbgl_vertex -1.0, -1.0, 1.0
tbgl_endpoly
TBGL_EndList

FUNCTION = %LST_PYRAMID

end FUNCTION

FUNCTION CreateAxisForkAsList() AS LONG
TBGL_NewList %LST_AXISFORK
TBGL_LineWidth 3
tbgl_beginpoly %GL_LINES
' -- X
TBGL_Color 255, 0, 0
TBGL_Vertex 0, 0, 0
TBGL_Vertex 2, 0, 0

' -- Y
TBGL_Color 0, 255, 0
TBGL_Vertex 0, 0, 0
TBGL_Vertex 0, 2, 0

' -- Z
TBGL_Color 0, 0, 255
TBGL_Vertex 0, 0, 0
TBGL_Vertex 0, 0, 2
tbgl_endpoly
TBGL_LineWidth 1

' -- +X
TBGL_Color 255, 0, 0
TBGL_PrintFont "+X", 2.2, 0, 0

' -- +Y
TBGL_Color 0, 255, 0
TBGL_PrintFont "+Y", 0, 2.2, 0

' -- +Z
TBGL_Color 0, 0, 255
TBGL_PrintFont "+Z", 0, 0, 2.2

TBGL_EndList

FUNCTION = %LST_AXISFORK

end FUNCTION


' create new, second Box by lionheart

FUNCTION CreateBoxAsList() AS LONG
TBGL_NewList %LST_BOX

tbgl_PushMatrix
TBGL_Translate 2, 0, 0
tbgl_Color 128+SIN(TIMER)*127, 0, 0
tbgl_Box 1,1,1
TBGL_PopMatrix

tbgl_PushMatrix
TBGL_Translate -2, 0, 0
tbgl_Color 40, 128+SIN(TIMER)*127, 0
tbgl_Box 2,1,1
TBGL_PopMatrix

tbgl_PushMatrix
TBGL_Translate 0, 2, 0
tbgl_Color 40, 80, 128+SIN(TIMER)*127
tbgl_Box 1,2,1
TBGL_PopMatrix

tbgl_PushMatrix
TBGL_Translate 0, -2, 0
tbgl_Color 128+SIN(TIMER)*127, 20, 0
tbgl_Box 1,1,2
TBGL_PopMatrix

tbgl_PushMatrix
TBGL_Translate 1, 1, 0
tbgl_Color 0, 20, 128+SIN(TIMER)*127
tbgl_Box 2,1,1
TBGL_PopMatrix

tbgl_PushMatrix
TBGL_Translate -1, -1.5, 0
tbgl_Color 60, 0, 128+SIN(TIMER)*127
tbgl_Box 2,2,2
TBGL_PopMatrix

TBGL_EndList

FUNCTION = %LST_BOX

end FUNCTION

'------ new sphere

FUNCTION CreateSphereAsList() AS LONG

tbgl_NewList %LST_SPHERE

' Sphere
tbgl_PushMatrix

tbgl_Rotate GetTickCount/10, 0, 0, 1
tbgl_Color 1,0,128+SIN(TIMER)*127
tbgl_Translate -3, 2, 0
tbgl_Color 50,128+SIN(TIMER)*127,255
tbgl_Sphere 0.5
tbgl_PopMatrix


tbgl_PushMatrix
tbgl_Rotate GetTickCount/6, 0, 0, 1
tbgl_Translate 3, 0, -1
tbgl_Color 128+SIN(TIMER)*127,0,255
tbgl_Sphere 0.3
tbgl_PopMatrix

tbgl_PushMatrix
tbgl_Rotate GetTickCount/8, 0, 0, 1
tbgl_Translate 1.5, 1, -1.5
tbgl_Color 0,0,255+SIN(TIMER)*127
tbgl_Sphere 0.45
tbgl_PopMatrix

tbgl_PushMatrix
tbgl_Translate -2, 1, 1.5
tbgl_Color 128+SIN(TIMER)*127,0,10
tbgl_Sphere 0.3
tbgl_PopMatrix

'------ rotating fun object

' Simple torus scene added
tbgl_PushMatrix

tbgl_Translate 0,0,-10
tbgl_Rotate 90,1,0,0

tbgl_Color 0,128,20
tbgl_Torus 0.45, 2.5
tbgl_Color 0,20,255
tbgl_Torus 0.15, 1.5

tbgl_Color 128,20,0
tbgl_Sphere 0.55

tbgl_PopMatrix


TBGL_EndList

FUNCTION = %LST_SPHERE


end FUNCTION

'------------ neuer Input zuletzt mit torus !



servus, frank (about 40 km southwards distance to you!) ;)

christianssen
25-02-2010, 09:30
many thanks, mr. lionheart. need this help, oh yes! looks very pretty with primitives they are moving around. so simple and good! thanks to petr for giving hint for examples too. I will check all examples with entity and the for me still unknown TBGL_EntityCreateDLSlot. will take time to understand all techniques. I see the example and think it's important to use new technique. It's important for me to get a clear overview of tbgl features for game development or simple scenes with animations. camera movements are always interesting for me so the scene gets more dynamics.


TBGL_Demo6_MovingIn3D_UsingEntitySystem.tbasic


but for newbies like me would be better to make new tbgl examples with entities and dlslot in thinbasic sample folder to avoid errors in understanding. my personal opinion.


feel free to ask or making some modifications with this example. nice time here and good luck for learning.


I will ask, be sure, it's no problem. there are one hundred questions ;)

denis

Petr Schreiber
25-02-2010, 09:49
Hi Denis,

TBGL allows multiple ways to define the final graphics, to allow maximum flexibility. This is why not all examples use entity system.

There are of course many examples on DLSlot already in the SampleScripts/TBGL, here I list them for you:

TBGL_Demo6_1_MovingIn3D_UsingEntitySystem.tbasic
TBGL_Demo6_MovingIn3D_UsingEntitySystem.tbasic
AI\AI_ISAWHIM.tbasic
AI\TrackAITest.tbasic
TBGL_0220_Samples\ControlTargettingAndInfo\TBGL022_Control_Targeting_GettingInfo.tbasic
TBGL_0220_Samples\EntityUserData\TBGL022_UserDataStorage.tbasic
TBGL_0220_Samples\RedBlueGlasses\TBGL022_RedBlueGlasses.tbasic


The best approach to examine new things with entities is to create new code from template TBGL_EntitySkeleton.


Petr

Michael Hartlef
25-02-2010, 11:57
but for newbies like me would be better to make new tbgl examples with entities and dlslot in thinbasic sample folder to avoid errors in understanding. my personal opinion.

denis


Hi Dennis,

this is also our oppinion but as you can imagine, it is simply a time problem. A few weeks ago Petr and I were talking about that we need to rework our examples and our documentation to make it easier for the people to understand the power of the TBGL module. This is definately something that is on our ToDo list and personally I will work on these things next.

Michael

Petr Schreiber
25-02-2010, 12:08
Yes,

another problem is that different people have different view on the things.
Some would like to have samples sorted by technology they use (immediate mode, models, entities), some by purpose of the examples (game, visualisation, physics), some by dimensions (2D, 3D).

This is hard to achieve using static directory structure.

If I will have time, and if Mike agrees, we might create application similar to one ATi and NVIDIA delivers with developer examples.
They call it "SDK browser", and you can filter examples there by various criteria.
This will need some sort of database of information to be created, which will take some time. So stay tuned :)

Denis, it would also help if you could say to us what kind of examples you need and what they should do. I also saw you do some experiments with console, so I would be interested in your vision of what do you want to use TBGL for (visualisation, game, charts, ...).

I presume your teacher publishes some tasks on e-learning for you, so this could be the clue.


Petr

Lionheart008
25-02-2010, 18:54
hi denis, mike, petr :)

to think about learning stuff for beginners. -> my ideas:

1) when I have started with learning the tbgl module, there was an idea to create a simple adviser book for beginners "how to learn TBGL in 30 days" how I know this kind of teaching books from learning languages (spanish, italian, french, english, dutch, turkish and so on.) this enterprise isn't easy because there are many ways to translate ideas in tbgl or ui modus, I know.

2) perhaps it's possible to make a "wishlist" what beginners for "TBGL" wanted to know and so you can start with 30 easy lessons (beginner level (for example: chapter 1-10: "primitives handling, entity, lights, camera moving and so on...), advanced (chapter 11-20: how to make a good tbgl scene and move scene objects and animate them) and profi level (21-30: here you can develop a real little game for example from "A-Z") ). At the end it's possible to make a little game with TBGL for 3d graphic scenes. same way should be possible for 2D games with module created from mike hartlef.

A learning "treeview" for TBGL would be ideal like a flip chart where you can see what's your position of knowledge and what's possible to learn the next lessons and find your way to the aim to program a game or making a simple TBGL scene with roting objects with primitives, lights, camera moving or particle explosion :)

3) I would suggest to make an poll and give thinbasic users time to make this "wishlist" for collecting ideas and special wishes about different "tbgl topics" like petr has done with both "TBGL bonus packs".

4) for me would be important to go step by step to next knowledge level to understand TBGL features. I don't know, but there are at least more than 100 or 200 commands I suggest. How to learn these commands for beginners ?

5) important for beginners: success with every lesson you're making! :) It's a linear learning curve with success and the user will feel satisfaction to show his results friends or for oneself. after doing first steps there will be some "frustrations" too, because it's nearly a daily adventure to make new exercises and searching for right solution and you have always to study TBGL help manual to get self concious to build new scenes without help.

6) I could help for making PDF book or making the editor, no problem. I know until today there are such many ways to get a solution with TBGL or combination TBGL/UI module or even with Canvas Mode. What's the advantage of this combinations? What's the disadvantages of different modi, there are more than dozen question for beginners and for game programming still more ;) I love TBGL, that's the way I like it.

servus, frank lionhead

Petr Schreiber
25-02-2010, 19:14
Thank you Frank,

very nice post, and lot of nice ideas! :occasion:

I like the idea of treeview of TBGL master :)

I will start new wishlist post once the ideas for Mikes 2D publication will be collected, to not ride 2 horses at the same time.

If you have seen the book by Stan, that is approach I like -> explanation of the topic + excercises for the students.
It would be ideal if more new commers to TBGL could start together, so we could discuss their solutions then.

Maybe we could organize some kind of "Summer of TBGL code" course, where you could really learn from the start up to some level. I will think about it.

Very nice ideas Frank, really!


Thank you,
Petr

christianssen
26-02-2010, 10:17
good morning. thanks for lot of answers and help!

I have not enough time at moment to make wishlist, but this will very important for me too:) very good ideas from mr. lionheart. I will support this idea. there are many ideas from lionhearts post I know from my profs and teacher to approach project files and get basically knowledge about learning books. it's great that this forum is very active and engaged, I didn't see this daily pushing and positively forward coming at other forums from my friend sides ;) this big sympathy bonus will get to thinbasic community ! many thanks for taken posts serious even for beginners / newbies !

- yes, petr, that's a problem to say what's I am needing for my projects before creating my 3d world and little game I will build and start next weeks. "karol the robot" we have at school as project too some weeks ago, I've installed karol yesterday and will see what I can use for my plans. it's faster way to create 2d game I suggest. But I will do 3d games with labyrinth, fighters and aliens ;) more to come next week I am full with other important things these days. but after have erased all unimportant things next weeks I can say more about my plans and ideas for TBGL.

healthy greetings, denis

christianssen
01-03-2010, 10:31
hello.

camera question: somebody can proof my camera position for my example ? Everything is ok with my entity positions and commands ? I am not sure. better to ask before I work on. I wanted to have a camera position for my scene from top like postion from a tower view down diagonale to city. that's need to change y and z-coordinate, I did it, but nothing changed ? I send zip file with picture and tbgl example.

old:
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 0.0, 3.0, -10.0 )

new and better:
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 4.0, 12.0, -20.0 )

/ question solved ;) stop: found solution!


'-denis tbgl learning edition ;)

'---Load needed modules
Uses "TBGL"

Dim hWnd As Dword

'---Creates OpenGL window and returns handle
hWnd = TBGL_CreateWindowEx("Moving in 3D, entity optimized - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
'---Shows TBGL window
TBGL_ShowWindow

TBGL_LoadTexture APP_SourcePath+"stevenson2.bmp", 1, %TBGL_TEX_MIPMAP
'=============================================================================
'= The most imortant 3 lines of code in whole program :) :
'=============================================================================
TBGL_SetupFog 0,0,128,128,5 ' Sets attributes of fog: R, G, B, Alpha, and density in percents
TBGL_BackColor 0,0,128 ' It's good idea to use same color for fog and background
TBGL_UseFog %TRUE ' "Turn on" the fog

' -- First we will create world as place to contain entities
%MY_WORLD = 1
tbgl_SceneCreate(%MY_WORLD)

' -- Our world will have two entities
%ENT_CAMERA = 1
%ENT_GRIDLIST = 2
%ENT_CreateCity = 3

TBGL_NewList %ENT_CreateCity
CreateCityAsDList()
TBGL_EndList

' .. Camera
tbgl_EntityCreateCamera( %MY_WORLD, %ENT_CAMERA)
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 4.0, 12.0, -20.0 )

' .. Grid
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST, 0, CreateGridAsDList() )

' .. City
TBGL_EntityCreateDLSlot( %MY_WORLD, %ENT_CreateCity, 0, CreateCityAsDList() )
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CreateCity, 0.0, -0.25, 0.0 )

dim FrameRate as double
dim Sheeps as long

'---Resets key status before checking
TBGL_ResetKeyState()

'---Main script loop
WHILE TBGL_IsWindow(hWnd)

'---Script will run on different PCs so we must assure
'---constant speed of movement by scaling movements relative to frame rate
FrameRate = TBGL_getFrameRate

'---Prepares clear frame
TBGL_ClearFrame

tbgl_SceneRender(%MY_WORLD)
TBGL_CallList %ENT_CreateCity

TBGL_DrawFrame ' Swaps the buffers - displays rendered image

if TBGL_GetwindowKeyState( hWnd, %VK_UP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, 5/FrameRate) ' 5 meters/second
if TBGL_GetwindowKeyState( hWnd, %VK_DOWN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, -5/FrameRate)

If TBGL_GetWindowKeyState( hWnd, %VK_UP) Then TBGL_EntityPush(%MY_WORLD, %ENT_CREATECITY, 0, 0, 5/FrameRate) ' 5 meters/second
If TBGL_GetWindowKeyState( hWnd, %VK_DOWN) Then TBGL_EntityPush(%MY_WORLD, %ENT_CREATECITY, 0, 0, -5/FrameRate)

if TBGL_GetwindowKeyState( hWnd, %VK_PGUP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 5/FrameRate, 0 )
if TBGL_GetwindowKeyState( hWnd, %VK_PGDN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, -5/FrameRate, 0 )

if TBGL_GetwindowKeyState( hWnd, %VK_LEFT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, 60/FrameRate, 0)
if TBGL_GetwindowKeyState( hWnd, %VK_RIGHT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, -60/FrameRate, 0) ' 60°/second

if TBGL_GetwindowKeyState( hWnd, %VK_ESCAPE) then EXIT WHILE

WEND

'---Closes OpenGL window
TBGL_DestroyWindow

Function CreateGridAsDList() As Long ' Returns to which display list we save
local i, j as long

tbgl_NewList 1
'---Let's build a grid
TBGL_BeginPoly %GL_LINES ' Starts polygon definition based on 2 vertex lines
TBGL_Color 0,255,255 ' Defines color

For i = -20 To 20
For j = -20 To 20
TBGL_Vertex -20, 0, j ' Adds vertex
TBGL_Vertex 20, 0, j ' Adds vertex

TBGL_Vertex i, 0, -20 ' Adds vertex
TBGL_Vertex i, 0, 20 ' Adds vertex

Next
Next

TBGL_EndPoly
tbgl_EndList

function = 1
End Function

Function CreateCityAsDList() As Long ' Returns to which display list we save

Local i, j, height As Long

TBGL_NewList 2
TBGL_UseTexturing %TRUE
TBGL_BindTexture 1

For i = -40 To 40 Step 8
For j = -30 To 30 Step 6
height = Rnd(6, 24)

TBGL_BeginPoly %GL_QUADS
TBGL_Color Rnd(128,255),Rnd(128,255),Rnd(128,255)

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,-2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex 2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_EndPoly
Next
Next

TBGL_UseTexturing %FALSE

End Function

End Function


new corrected zip file sent.

best regards, denis

ps: all ok here, found my solution! see above ;)
pps: thanks frank for important advice!

Lionheart008
01-03-2010, 18:53
hi denis, your second cut was good, but not perfect ;) doesn't matter. you will get it, I am sure :) I have optimized your code with entity and display List. perhaps you take time and see different between your last example and my correction. I hope this help.

corrected code:

'-denis tbgl learning edition ;)

'---Load needed modules
Uses "TBGL"

Begin Const
' -- Our world will have three entities
%ENT_CAMERA = 1
%ENT_GRIDLIST
%ENT_CreateCity
End Const

' -- Display lists
Begin Const
%LST_GRID = 1
%LST_BOX
%LST_CITY
End Const


Dim hWnd As Dword

'---Creates OpenGL window and returns handle
hWnd = TBGL_CreateWindowEx("CityFog: Moving in 3D, City entity optimized - press ESC to quit", 680, 520, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
'---Shows TBGL window
TBGL_ShowWindow

TBGL_LoadTexture APP_SourcePath+"stevenson2.bmp", 1, %TBGL_TEX_MIPMAP
'=============================================================================
'= The most imortant 3 lines of code in whole program :) :
'=============================================================================
TBGL_SetupFog 0,0,128,128,5 ' Sets attributes of fog: R, G, B, Alpha, and density in percents
TBGL_BackColor 0,0,128 ' It's good idea to use same color for fog and background
TBGL_UseFog %TRUE ' "Turn on" the fog

' -- First we will create world as place to contain entities
%MY_WORLD = 1
tbgl_SceneCreate(%MY_WORLD)


'TBGL_NewList %ENT_CreateCity
' CreateCityAsDList()
'TBGL_EndList

' .. Camera
tbgl_EntityCreateCamera( %MY_WORLD, %ENT_CAMERA)
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CAMERA, 4.0, 12.0, -20.0 )


' .. Grid
tbgl_EntityCreateDLSlot( %MY_WORLD, %ENT_GRIDLIST, 0, CreateGridAsDList() )


CreateCityAsDList()
' .. City
TBGL_EntityCreateDLSlot( %MY_WORLD, %ENT_CreateCity, 0, %LST_CITY)
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CreateCity, 0.0, -0.25, 0.0 )

dim FrameRate as double
dim Sheeps as long

'---Resets key status before checking
TBGL_ResetKeyState()

'---Main script loop
WHILE TBGL_IsWindow(hWnd)

'---Script will run on different PCs so we must assure
'---constant speed of movement by scaling movements relative to frame rate
FrameRate = TBGL_getFrameRate

'---Prepares clear frame
TBGL_ClearFrame

tbgl_SceneRender(%MY_WORLD)
'TBGL_CallList %ENT_CreateCity

TBGL_DrawFrame ' Swaps the buffers - displays rendered image

if TBGL_GetwindowKeyState( hWnd, %VK_UP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, 5/FrameRate) ' 5 meters/second
if TBGL_GetwindowKeyState( hWnd, %VK_DOWN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 0, -5/FrameRate)

If TBGL_GetWindowKeyState( hWnd, %VK_UP) Then TBGL_EntityPush(%MY_WORLD, %ENT_CREATECITY, 0, 0, 5/FrameRate) ' 5 meters/second
If TBGL_GetWindowKeyState( hWnd, %VK_DOWN) Then TBGL_EntityPush(%MY_WORLD, %ENT_CREATECITY, 0, 0, -5/FrameRate)

if TBGL_GetwindowKeyState( hWnd, %VK_PGUP) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, 5/FrameRate, 0 )
if TBGL_GetwindowKeyState( hWnd, %VK_PGDN) then tbgl_EntityPush(%MY_WORLD, %ENT_CAMERA, 0, -5/FrameRate, 0 )

if TBGL_GetwindowKeyState( hWnd, %VK_LEFT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, 60/FrameRate, 0)
if TBGL_GetwindowKeyState( hWnd, %VK_RIGHT) then tbgl_EntityTurn(%MY_WORLD, %ENT_CAMERA, 0, -60/FrameRate, 0) ' 60°/second

if TBGL_GetwindowKeyState( hWnd, %VK_ESCAPE) then EXIT WHILE

WEND

'---Closes OpenGL window
TBGL_DestroyWindow

Function CreateGridAsDList() As Long ' Returns to which display list we save
local i, j as long

TBGL_NewList %LST_GRID
'---Let's build a grid
TBGL_BeginPoly %GL_LINES ' Starts polygon definition based on 2 vertex lines
TBGL_Color 0,255,255 ' Defines color

For i = -20 To 20
For j = -20 To 20
TBGL_Vertex -20, 0, j ' Adds vertex
TBGL_Vertex 20, 0, j ' Adds vertex

TBGL_Vertex i, 0, -20 ' Adds vertex
TBGL_Vertex i, 0, 20 ' Adds vertex

Next
Next

TBGL_EndPoly
tbgl_EndList

function = 1
End Function

Function CreateCityAsDList() As Long ' Returns to which display list we save

Local i, j, height As Long

TBGL_NewList %LST_CITY
TBGL_UseTexturing %TRUE
TBGL_BindTexture 1

For i = -40 To 40 Step 8
For j = -30 To 30 Step 6
height = Rnd(6, 24)

TBGL_BeginPoly %GL_QUADS
TBGL_Color Rnd(128,255),Rnd(128,255),Rnd(128,255)

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,-2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex 2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex 2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,0,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.5+i,0,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,0
TBGL_Vertex -2.5+i,height,-2.5+j

TBGL_TexCoord2D 0,1
TBGL_Vertex -2.5+i,height,2.5+j

TBGL_TexCoord2D 1,1
TBGL_Vertex 2.5+i,height,2.5+j

TBGL_TexCoord2D 1,0
TBGL_Vertex 2.5+i,height,-2.5+j

TBGL_EndPoly

Next
Next

TBGL_EndList

TBGL_UseTexturing %FALSE
Function = 1

End Function


2) important notice:
at the end of your example...


Function CreateCityAsDList() As Long

here you must use some lines below:


TBGL_NewList %LST_CITY

...code stuff

and not forget to close this list with


TBGL_EndList


3) you can delete this :

'TBGL_NewList %ENT_CreateCity
' CreateCityAsDList()
'TBGL_EndList


and make it comfortabler with:

4)
CreateCityAsDList()
' .. City
TBGL_EntityCreateDLSlot( %MY_WORLD, %ENT_CreateCity, 0, %LST_CITY)
TBGL_EntitySetPos ( %MY_WORLD, %ENT_CreateCity, 0.0, -0.25, 0.0 )

no problem, you will see the advantages if you are working with more entitys and objects.
good luck! ask if you have any problems.

5) you can add your new examples for topics to the TBGL thread ("TBGL_General"), for example here:

http://community.thinbasic.com/index.php?board=18.0

best regards, frank
ps: I know "treasure island" by r.l. stevenson ;) I have both editions, english and german

Petr Schreiber
01-03-2010, 20:15
Frank,

thanks for providing the help.

Denis - there is a way to simplify the code by using TBGL_Box primitive, instead of complex TBGL_BeginPoly/TBGL_EndPoly.


Petr