View Full Version : TBGL question - not sure if im in the right area
chubs1646
17-11-2009, 01:07
Hello all,
This is my first post so please be semi-understanding. Im not sure if this is the right venue to ask this question but im gonna go for it. I am in the process of attempting to write a script that shows text in a circular pattern using tbgl. I started with the polygon example in thinair as my template and have modded heavily since to attempt to get the desired results. the issue that I am having is that although it will draw the polygon in the center of the window, assuming the center of the windows coordinates as 0,0,0 assuming these same coordinates but with text (both through print and bmp) it generates the text in a circular pattern but in the upper left hand corner, I assumed that it was resetting its points to that location and so I attempted to set the Translate function to try to get it centered on the screen but to no avail. the weird thing is I know the circle renders fine because I have done it with just pixels, why would it not work the same with text? does anyone have any examples that they have that worked? im probably missing something really simple but this is honestly racking my brain as I have tried many things and it doesnt seem to change. if need be I can post the code.
ErosOlmi
17-11-2009, 01:24
Hi there and welcome to thinBasic community forum.
I hope you will enjoy your stay with us.
I've moved your post into TBGL guru area. I'm sure someone will help you soon.
In the meanwhile if you have a piece of source code that shows the problem you are facing, I'm sure this will help to reply to you more quickly.
Ciao
Eros
chubs1646
17-11-2009, 04:04
thank you very much. for both moving it and for the welcoming. I have been nothing but impressed with everything here and not to toot my own horn but have been programming for more than 10 years now. normally I would have never posted in fear of flammage or RTFM people, but after reading some of the posts drew the courage to ask and was very pleased with the results. thank you again, oh and I will post the code in that thread, usually that helps resolve the issue when people can see what your lookin at lol just another set of eyes is all I need :)
ErosOlmi
17-11-2009, 08:54
"RTFM" acronym is something you will rarely (if never) see here :)
Every question/problem is for us an occasion to test and consolidate thinBasic material (help, modules, ...).
Petr Schreiber
17-11-2009, 10:10
Hi Chubs1646,
welcome!
Would it be possible to post here code? I will be happy to help.
Petr
Michael Hartlef
17-11-2009, 10:12
Hello and welcome to our community.
Like Eros said, never be afraid to ask. There are no stupid questions, just stupid answers. :)
And regarding your code problem. Yes, please post a script so we can see what you ment and help you as fast as real life allows it.
Petr Schreiber created the TBGL module so he is the TBGL-GURU :D , I am helping him a little with it (Sprite functions).
So if you need a new command or extended behaviour or have other questions. Just ask.
Best wishes
Michael
Michael Hartlef
17-11-2009, 10:14
"RTFM" acronym is something you will rarely (if never) see here :)
Every question/problem is for us an occasion to test and consolidate thinBasic material (help, modules, ...).
Well said. If someone ever comes up here with that phrase, I personally will guide him/her to the door :mrgreen:
chubs1646
18-11-2009, 07:28
LOL as always in true coding form, while looking at the code before I posted it I tested something and it worked just fine LOL im sorry to have wasted all your time, if anyone is interested in the code still id be happy to post it. I was born open source lol. thanks again guys.
Michael Hartlef
18-11-2009, 08:52
Yes, that is great that you made it running. And yes, still post your script so others can learn from it.
chubs1646
19-11-2009, 01:00
' Empty GUI script created on 11-17-2009 23:16:45 by (ThinAIR)
' Modification of Example code for:
' The triangle rotation preserving axes
' Petr Schreiber for Zak, started on 01-18-2009
'
Uses "TBGL"
' -- Scene-Entity constants
BEGIN CONST
' -- Scene IDs
%sScene = 1
' -- Entity IDs
%eCamera = 1
%eCircle
END CONST
' -- Display list constants
BEGIN CONST
%lCircle = 1
%lStartAng = 0 'Most commonly needs to be 0, change this and endang for arcs
%lEndAng = 360
%lRadius = 3
END CONST
FUNCTION TBMAIN()
LOCAL hWnd As DWORD
LOCAL FrameRate AS DOUBLE
Local Counter1 as DOUBLE 'Variable used for circle generation
Local Xval as DOUBLE
Local Yval as DOUBLE
Counter1 = 0
' -- 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
dim hFont as dword = tbgl_FontHandle("lucida console", 12)
TBGL_BuildFont hFont
' -- Create scene
TBGL_SceneCreate(%sScene)
' -- Create basic entities
' -- Create camera to look from 0, 0, 5 to 0, 0, 0
TBGL_EntityCreateCamera(%sScene, %eCamera)
TBGL_EntitySetPos(%sScene, %eCamera, 0, 0, 10)
TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0)
' -- Cache triangle to display list
TBGL_NewList %lCircle
TBGL_PointSize 6
tbgl_Color 0, 128, 255 ' -- color
while Counter1< %lEndAng 'loop that generates points on a circle
Xval = (%lRadius * (cos((%lStartAng + Counter1) * (3.14/180))))
Yval = (%lRadius * (sin((%lStartAng + Counter1) * (3.14/180))))
TBGL_PrintFont counter1,Xval,Yval,0 'Prints the value of the counter
Counter1 += 10
wend
TBGL_EndList
' -- Create something to look at
TBGL_EntityCreateDLSlot(%sScene, %eCircle, 0, %lCircle)
TBGL_EntitySetPos(%sScene, %eCircle, 0, 0, 0)
' -- Resets status of all keys
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
' -- Entity turn has parameters for rotation in x, y and z axis
If TBGL_GetWindowKeyState(hWnd, %vk_UP) then TBGL_EntityTurn(%sScene, %eCircle, -1, 0, 0)
If TBGL_GetWindowKeyState(hWnd, %vk_Down) then TBGL_EntityTurn(%sScene, %eCircle, 1, 0, 0)
If TBGL_GetWindowKeyState(hWnd, %vk_right) then TBGL_EntityTurn(%sScene, %eCircle, 0, 1, 0)
If TBGL_GetWindowKeyState(hWnd, %vk_left) then TBGL_EntityTurn(%sScene, %eCircle, 0,-1, 0)
If TBGL_GetWindowKeyState(hWnd, %vk_pgdn) then TBGL_EntityTurn(%sScene, %eCircle, 0, 0, 1)
If TBGL_GetWindowKeyState(hWnd, %vk_pgup) then TBGL_EntityTurn(%sScene, %eCircle, 0, 0,-1)
Wend
TBGL_DestroyWindow
END FUNCTION
Michael Clease
19-11-2009, 01:33
Very nice, it would make a good sample.
Petr Schreiber
19-11-2009, 11:08
Such a nice example,
thanks for sharing!