View Full Version : looking for sphere
largo_winch
12-04-2011, 11:52
hello all. I am quite new here.. found thinbasic by chance but it's perhaps interesting language I could like :)
what I am looking for is stuff about openGL (for example: sphere, cone, cube) and how to move them by left or right mouse to another place. some links or example can help. i've downloaded thinbasic 1.8.0.0 beta (last year). it's an actual issue? do you are producing updates in regularly way? -> thanks for replies, largo
Michael Clease
12-04-2011, 12:18
Welcome to TB watch out it contagious.
I am sure Petr will give you more detail but have you looked in the TBGL samples folder?
The samples are located in the install of thinbasic i.e "C:\thinBasic\SampleScripts\TBGL" , look at demo19 that will give you some ideas.
Look at the help file for TBGL for more information, click on top the word "TBGL_SPHERE" then press F1 and the help for TBGL should popup with the section on primitive objects.
Regards
Mike C.
Petr Schreiber
12-04-2011, 15:06
Hi largo_winch,
welcome! As Mike advised, it is possible to start in SampleScripts/TBGL folder. There are numerous examples going from total basics (creating windows, defining polygon) to more advanced topics.
I recommend downloading the version 1.8.6.0 (http://www.thinbasic.com/community/showthread.php?10672-thinBasic-Beta-1.8.6.0), but for moving sphere 1.8.0.0 should be fine :)
ThinBASIC allows multiple ways to define scene - you can practically use just OpenGL directly, or TBGL low level commands very similar to OpenGL and finally TBGL Scene-Entity system. Of course, all these approaches can be mixed together.
Fastest way to get you started is to create new script from template. To do so:
open ThinAir
click File/New
choose "TBGL" folder
choose "TBGL_EntitySkeleton.taguit"
It will generate for you minimal example of window with 3D box, which can be manipulated using arrow keys.
All TBGL commands are documented in help file, it is enough to move cursor to any TBGL command and then hit F1, it will take you to more info.
More documentation in form of articles is also available here on forum, when you click the "Articles (http://www.thinbasic.com/community/content.php?16-tbgl)" on the main toolbar. Some older articles are available at http://psch.thinbasic.com/ as well.
Last but not least, there is huge package of extras called "Bonus Packs (http://www.thinbasic.com/index.php?option=com_jdownloads&Itemid=95&task=viewcategory&catid=5)". It is collection of graphic oriented scripts from multiple contributors from the forum.
Petr
largo_winch
12-04-2011, 19:10
thank you michael, petr for replies.
a) I wanted to use a window frame (dialog) and openGL inside ( I will check examples)
->possible yes/no?
b) I wanted to have two (three) frames inside (can I "dock a window" inside a dialog?)
or more with two different openGL frames (it's possible with c++, with thinbasic too?) I will include a tab register if possible (my example will come next time)
->possible yes/no?
c) I wanted to "drag & drop" infos (for example from a folder full of property data of a sphere or cube or cone) from one window to another inside the main window frame ( I will check also what I can find of sample script folders)
->possible yes/no?
d) source code is open for openGL with thinbasic like irrlicht engine (freebasic) ?
good bye, more to see next time, largo
Petr Schreiber
12-04-2011, 21:35
Hi,
Ad a) Yes, possible via TBGL canvas technique, use TBGL_InDialog_EntitySkeleton.taguit template
Ad b) Not sure I understand what are you saying, but it is possible to have multiple host controls and switch TBGL_BindCanvas for them. But I would recommend to have split screen inside single TBGL rendering surface for optimal performance and less struggle. You can use TBGL_Viewport to split surface to separated render areas. Browse SampleScripts/TBGL for viewport use example.
Regarding raw OpenGL, yes, possible, as OpenGL is language independent. You just have to switch contexts as in any other language. I personally find the context switches bothering and sharing the resources is tricky with some drivers as I discovered recently, so ... that's why I would suggest you to stick with one surface, with splitscreen.
Ad c) I think possible, but no example by hand at the moment. If you have some code for it in other language, it should be simple to port, as ThinBASIC allows processing standard Win32 messages in dialog callback functions.
Ad d) If you mean TBGL module, no, it is not open source.
One side note which I am not sure I made clear -> TBGL is not OpenGL wrapper for ThinBASIC, it is graphic library based on OpenGL.
For classic OpenGL, use OpenGL headers instead:
#include "thinbasic_gl.inc"
#include "thinbasic_glu.inc"
#include "thinbasic_glext.inc"
(See TBGL_RawOpenGLSkeleton.taguit for purely OpenGL solution)
Petr
largo_winch
13-04-2011, 19:48
yes petr, thank you for further explanations, I need it. here my first little example, but not finished yet. Viewport? I will check this example. there are too many at the moment to proof, but I like this module (graphic library) so far as I have understood ;) there will be more questions I am sure. I hope somebody can help at the board for more understanding. see you, largo
largo_winch
17-04-2011, 14:07
how I can set the "updown" (ui folder with sample) value from for example 40 as shown to a decimal value like 4.1 (up to 4.2 or down to 4.0)? it's possible? thanks, largo
addendum: for petr:
I personally find the context switches bothering and sharing the resources is tricky with some drivers as I discovered recently, so ... that's why I would suggest you to stick with one surface, with splitscreen.
do you're meaning I should use the viewport example with a gui (inDialog) instead of my example? I can use four different surfaces of one object (correct?) and not four "different" objects with one viewport and splitscreen (correct?)? thanks again.
Petr Schreiber
17-04-2011, 19:03
Hi largo_winch,
UpDown control currently works with integer values. But you can workaround it by intercepting text update message + use some wrapper functions to make it more straightforward, see this example (prepaired for single decimal):
uses "UI"
Begin ControlID
%ID_BUDDY
%ID_UPDOWN
End ControlID
FUNCTION TBMAIN() as long
DIM hDlg AS LONG
DIALOG NEW 0, "Up-Down demo", -1, -1, 130, 70, %WS_OVERLAPPED OR %WS_SYSMENU OR %WS_DLGFRAME TO hDlg
DIALOG SHOW MODAL hDlg CALL DlgProc
END FUNCTION
CALLBACK FUNCTION DlgProc() as long
SELECT CASE CBMSG
Case %WM_INITDIALOG
Control Add Textbox, CBHNDL, %ID_BUDDY, "", 5, 12, 66, 12, %ES_AUTOHSCROLL | %ES_LEFT, %WS_EX_CLIENTEDGE
Control Add UPDOWN, CbHndl, %ID_UPDOWN, "", 0, 0, 8, 8, %WS_CHILD | %WS_VISIBLE | %UDS_WRAP | %UDS_ARROWKEYS | %UDS_ALIGNRIGHT | %UDS_SETBUDDYINT | %UDS_NOTHOUSANDS
'---Link the buddy textbox
UpDown_SetBuddy CBHNDL, %ID_UPDOWN, %ID_BUDDY
'---Set the min and max range
Decimal_SetUpDownRange(CBHNDL, %ID_UPDOWN, -1000, 1000)
'---Set starting position
Decimal_SetUpDownValue(CBHNDL, %ID_UPDOWN, %ID_BUDDY, 40.0)
Case %WM_COMMAND
String s
If CBCTL = %ID_BUDDY And CBCTLMSG = %EN_CHANGE Then
s = Control_GetText(CBHNDL, %ID_BUDDY)
If InStr(s, ".") = 0 Then
Control Set Text CBHNDL, %ID_BUDDY, Format$(Val(s)/10, "#.0")
End If
End If
END SELECT
End Function
Function Decimal_SetUpDownValue( hDlg As DWord, idCtlUD As Long, idCtlTB As Long, decimalValue As Number )
UpDown_SetPosition hDlg, idCtlUD, decimalValue*10
Control Set Text hDlg, idCtlTB, Format$(decimalValue, "#.0")
End Function
Function Decimal_SetUpDownRange( hDlg As DWord, idCtlUD As Long, minValue As Number, maxValue As Number )
UpDown_SetRange hDlg, idCtlUD, minValue*10, maxValue*10
End Function
But there is problem when user tries to enter the value manually - it tries to correct it after him as well, which is not very usable.
do you're meaning I should use the viewport example with a gui (inDialog) instead of my example?I am not sure how your example is done, as you provided us with EXE only. It seems working OK to me.
You can have one surface, and virtually split it using Viewports. If you render the same or different object in each of the viewport is up to you of course.
Petr