View Full Version : some feedback, resume
ReneMiner
30-01-2013, 16:46
For me TBGL seems to be the easiest way to get 3d onto the screen - I really searched the web, there's no other.
Purebasic might be close and has some features that TB(GL) does not have yet but I don't like to use purebasic for personal reasons which won't fit into this thread.
What disturbs me about TBGL and makes me fear using it, is the 2D-stuff:
-positioning of sprites (centered and not top-left-cornered) which makes it a hassle to use them as "GUI-Boxes" in the TBGL-window since they are treated different as a regular 2d-Box
-the experience of TBGL_Sprite-methods being unstable on my system
-TBGL_GetFontTextSize does not return correct results when using more than one font so fonts can just be aligned left
The callback-stuff is for me an unsolved riddle: if I read code from other users it seems to be that logic and easy: if I try- it ends up in rage and almost formatting hard-drives using a sledge hammer.
So for GUI and especially Visual Designer I have the following points and suggestions:
VD creates some *.thinVD-file which I cannot read nor change and which seems to allow just one Main-Form currently.
I would appreciate if VD would additional/optional create some *.tBasicu-include-file which a user can read and edit also or even copy & paste it to the main-code later. Surely VD cannot read in these files - but it could write them as they are needed.
Furthermore it would be great if I could set at the "Control Properties" the required Callbacks for each control already.
Either choose an existing subs name or enter a new one so the little secret workers behind the curtain create the thinBasic-code-skeleton as a regular *.tBasic or *tBasicu-file from all those settings.
If no subs name is entered/chosen = no callback of that kind is needed nor generated. Keeps footprint small too but speeds up creating GUIs.
It would probably be necessary to have to declare one dialog as projects "mainwindow" and to allow a few "usernamed" child-windows and/or arrays of some similar child-windows per project. For the child-windows there should be some "Modal"-property then.
The generated code should enumerate the forms and controls, include the subs to setup + draw the dialogs with their controls and of course the skeleton-callbacks for the whole projects GUI (=all dialogs) in one file. So VD might handle "Project-GUI-Files" which consist of all forms that belong to the current project.
Another little complain: when drawing controls onto the form in VD the mousepointer inside drawing area should be changed from "arrow" to "haircross"
Enhanced: VD could have a TBGL_Canvas-Control to draw onto ONE form per project and create the Uses "TBGL" and TBGL_BindCanvas -stuff inside the code. Not necessarily on the main-form since the main-form can just contain menu or toolbar in a MDI-project with SDI-appearance (where the child dialogs are not displayed within an MDI-form).
PS. Downloaded 1.9.2.0 - didn't thinAir have some Toolbar-Buttons previously?
Petr Schreiber
30-01-2013, 17:16
Hi Rene,
thank you for your feedback.
The unstability reported for TBGL_SpriteExists was examined, but I could not confirm it (http://www.thinbasic.com/community/project.php?issueid=374)
TBGL_GetFontTextSize - I can confirm that and opened issue here (http://www.thinbasic.com/community/project.php?issueid=379)
sprites centered - it is a feature and common behavior in game engines, I think Mike did it okay. You can build custom visual element using the lower level commands to suit your needs better.
To make the chances of something being implemented/fixed higher, it is good to place suggestions/bug reports for each single item in the support (http://www.thinbasic.com/community/project.php) section.
Petr
Petr Schreiber
30-01-2013, 17:39
TBGL_GetFontTextSize issue fixed in latest TBGL (http://www.thinbasic.com/community/showthread.php?10909-The-latest-TBGL-version).
Petr
ErosOlmi
30-01-2013, 19:10
Hi Rene,
thinBasic Visual Designer is just at its early stage. A lot of work is missing.
It actually creates no code on disk but some code you can just copy/paste into a script to test it. The disk file VD project is actually created using a binary file, more for quick developing than for other reasons. In my mind one of the next version will have an XML file as support file.
Yes, generated code is actually quite basic. But I will work on it in future versions.
Ciao
Eros
http://www.thinbasic.com/community/showthread.php?11765-thinBasic-Visual-Designer-Code-Generator&highlight=visual+designer
ReneMiner
31-01-2013, 04:10
Hi Petr,
I tried last thinBasic version without and also with new TBGL-files. If I run this script (http://www.thinbasic.com/community/showthread.php?11930-Ordering-2D-Drawing-curious) it still looks the old way. Fonts not aligned right.
Hi Eros,
I didn't see that video before, but it looks promising and I hope that the finished VD-tool can be used as fast and easy as shown - would be really great. Certainly I'm gonna use the GUI-stuff with pleasure when it's done :)
PS: 1.9.2.0 toolbar is fine again
Petr Schreiber
31-01-2013, 10:23
Hi Rene,
I attach screenshot with TBGL 1.9.3 from here (are you sure you applied latest TBGL (http://www.thinbasic.com/community/showthread.php?10909-The-latest-TBGL-version) after reinstalling TB 1.9.2?).
Petr
ErosOlmi
31-01-2013, 13:08
Maybe we are creating some confusion because Petr and I are developing at the same time new releases and, like in this case, we do not have time to pack all the latest versions into the same thinBasic release.
Petr develop TBGL and release into thinBasic SVN server. When I have to release a new thinBasic I get latest TBGL from SVN server and pack it into thinBasic.
In this moment we are out of sync ... for a bit ...
ReneMiner
31-01-2013, 13:37
Yes I'm sure. I downloaded 744kB "LatestTBGLPackage.zip" yesterday night after I read this.
I uninstalled tB 1.9.1.0, installed 1.9.2.0, pasted the content of the TBGL-package (lib/inc) to my thinBasic-Folder, did run the CreateSyntaxIni before and restarted thinAir then to try.
I even unzipped the package a second time and pasted the stuff into tb-folder again to make sure it didn't slip anywhere else and I compared file-size & date. They are in the right place.
I think I did it all right
To make sure I changed the scripts variables so there I use lW1,LH1 for the first line and lW2 and lH2 for the second line because I thought the Function TBGL_GetFontTextSize might use them byRef when it comes to TBGL_DrawFrame)
but still looks like this:
btw. you might consider including a file-version or a date in the zip-folders name
Petr Schreiber
31-01-2013, 15:29
Hi Rene,
you can see the file versions simply using thinAIR:
Click Help/About thinAir
Click the File info tab
Locate ThinBASIC_TBGL.DLL
Description field contains the day of the build
Version field contains version information
I tested the TBGL on Windows XP/Vista and 7 right now, I attach screenshot from XPs. It seems to work as it should.
Petr
ReneMiner
31-01-2013, 16:29
did as you described, it says January 30. 2013 , 1.9.3.0 - so this must be the right one I think.
Visual result still remains: see above. :confused:
So there must be something running different on 32Bit. Urges me to get a new computer - so I won't be bothering you to solve this puzzle
Petr Schreiber
31-01-2013, 17:37
Hi Rene,
I will try to do test on more PCs, but I am unable to replicate it.
It should not be GPU specific, it is simple Win32 function call...
Petr
Petr Schreiber
31-01-2013, 17:52
Could you try this code if it reports different values for you?:
Uses "Console", "UI"
Type SizeL DWord
cx As Long
cy As Long
End Type
Declare Function ReleaseDC Lib "User32.dll" Alias "ReleaseDC" (ByVal hWnd As DWord, ByVal hDC As DWord) As Long
Declare Function GetDC Lib "User32.dll" Alias "GetDC" ( ByVal hWnd As DWord) As DWord
Declare Function SelectObject Import "GDI32.DLL" Alias "SelectObject" ( ByVal hdc As DWord, ByVal h As DWord ) As DWord
Declare Function GetTextExtentPoint32 Import "GDI32.DLL" Alias "GetTextExtentPoint32A" ( ByVal hdc As DWord, ByRef lpString As Asciiz, ByVal c As Long, ByRef psizl As SizeL) As Long
Function TBMain()
DWord f1 = Font_Create("Courier", 14)
DWord f2 = Font_Create("Courier", 20)
Long w, h
MeasureString(f1, "TEST STRING", w, h)
PrintL w, h
MeasureString(f2, "TEST STRING", w, h)
PrintL w, h
PrintL "Press any key to continue..."
WaitKey
End Function
Function MeasureString(fHandle As DWord, sText As Asciiz, ByRef nWidth As Long, ByRef nHeight As Long)
Local dims As SizeL
Local hDC As DWord
hDC = GetDC(%HWND_DESKTOP)
SelectObject(hDC, fHandle)
GetTextExtentPoint32(hDC, sText, Len(sText), dims)
ReleaseDC(%HWND_DESKTOP, hDC)
nWidth = dims.cx
nHeight = dims.cy
End Function
Petr
ReneMiner
31-01-2013, 18:13
I get a console output
99 16
176 26
Press any key to continiue...
Petr Schreiber
31-01-2013, 18:16
That is good, now please try this modification of your code:
Uses "TBGL", "Console"
%SmallFont = 1 'these are my two fonts
%LargeFont = 2
Type SizeL DWord
cx As Long
cy As Long
End Type
Declare Function ReleaseDC Lib "User32.dll" Alias "ReleaseDC" (ByVal hWnd As DWord, ByVal hDC As DWord) As Long
Declare Function GetDC Lib "User32.dll" Alias "GetDC" ( ByVal hWnd As DWord) As DWord
Declare Function SelectObject Import "GDI32.DLL" Alias "SelectObject" ( ByVal hdc As DWord, ByVal h As DWord ) As DWord
Declare Function GetTextExtentPoint32 Import "GDI32.DLL" Alias "GetTextExtentPoint32A" ( ByVal hdc As DWord, ByRef lpString As Asciiz, ByVal c As Long, ByRef psizl As SizeL) As Long
Function TBMain()
Local hWnd As DWord
Local FrameRate As Double
Local width, height As Long
Local i,lW,lH As Long
' -- 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
TBGL_GetWindowClient( hWnd, width, height )
' create fonts...
TBGL_BuildFont TBGL_FontHandle("Courier", 14), %SmallFont
TBGL_BuildFont TBGL_FontHandle("Courier", 20), %LargeFont
' -- Resets status of all keys
TBGL_ResetKeyState()
' -- Main loop
While TBGL_IsWindow(hWnd)
' -- Read the current frame rate.
FrameRate = TBGL_GetFrameRate
' -- As we don't draw a full background, we need to clear the framebuffer
TBGL_ClearFrame
' -- Set the resolution and the coordinate system
TBGL_RenderMatrix2D (0,height,width,0)
' now draw the small font aligned on the right:
TBGL_Color 0, 255, 128
TBGL_SetActiveFont %SmallFont
TBGL_GetFontTextSize( "TESTSTRING", lW, lH )
TBGL_PrintFont "TESTSTRING", width - lW, 24
PrintL lw, lh
MeasureString(0, "TESTSTRING", lw, lh)
PrintL lw, lh
' and the large font, also aligned on the right:
PrintL "---"
TBGL_Color 0, 128, 255
TBGL_SetActiveFont %LargeFont
TBGL_GetFontTextSize( "TESTSTRING", lW, lH )
TBGL_PrintFont "TESTSTRING", width - lW, 72
PrintL lw, lh
MeasureString(0, "TESTSTRING", lw, lh)
PrintL lw, lh
PrintL
' -- now draw a framed rectangle
' left, top width height Red Green Blue
drawFramedRect2D( 100, 100, 100, 100, 123, 123 , 60)
'Show the rendered stuff
TBGL_DrawFrame
' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
End Function
' ------------------------------------------------------------------------------------
Sub DrawFramedRect2D(ByVal X As Long, ByVal Y As Long, ByVal W As Long, ByVal H As Long, _
ByVal R As Byte, ByVal G As Byte, ByVal B As Byte)
Local lR,lG,lB As Long
TBGL_Color R,G,B ' the given color
TBGL_Rect( X, Y, X + W , Y + H )
' now lighten the color
lR = R + 32 : If lR > 255 Then lR = 255
lG = G + 32 : If lG > 255 Then lG = 255
lB = B + 32 : If lB > 255 Then lB = 255
TBGL_Color lR, LG, lB
TBGL_Rect( X - 2, Y - 2, X + W - 2, Y + H - 2 )
' darken the color
lR = R - 32 : If lR < 0 Then lR = 0
lG = G - 32 : If lG < 0 Then lG = 0
lB = B - 32 : If lB < 0 Then lB = 0
TBGL_Color lR, lG, lB
TBGL_Rect( X + 2, Y + 2, X + W + 2 , Y + H + 2 )
' usually the last drawn stuff has to be on top of all that
' has been drawn before, but try to comment the first TBGL_Rect out
' and enable the following
'TBGL_Color 255,0,0 ' bright red just to see...
'TBGL_Rect( X, Y, X + W , Y + H )
End Sub
Function MeasureString(fHandle As DWord, sText As Asciiz, ByRef nWidth As Long, ByRef nHeight As Long)
Local dims As SizeL
If fHandle Then
SelectObject(TBGL_oglDeviceContext, fHandle)
End If
GetTextExtentPoint32(TBGL_oglDeviceContext, sText, Len(sText), dims)
nWidth = dims.cx
nHeight = dims.cy
End Function
Petr
ReneMiner
31-01-2013, 18:21
thats weird:
console output
160 26
160 26
-------
160 26
160 26
...
visual result:
Petr Schreiber
31-01-2013, 18:22
Thanks for your test, strange indeed :) I will think about what could be the cause...
Petr
ReneMiner
31-01-2013, 18:27
I think the measurement (TBGL_GetFontTextSize) is working correctly but could it be possible the TBGL_PrintFont stores a wrong position in X before it gets to TBGL_DrawFrame?
Petr Schreiber
31-01-2013, 21:24
Hi Rene,
I thought it might be something with ATi cards, but now I tested it on PC with Radeon + Windows Vista... and it worked correctly.
I have nobody around with Windows XP + Radeon card for tests. At the moment I have no idea what could be the problem on your PC :(
Petr
ReneMiner
02-02-2013, 13:32
OK, I'm gonna buy a new computer on monday with nVidia-Card then.
But in the meantime I have a small request because I'm already going mad about those callbacks and more than just the TBGL-Window.
I need some template/skeleton to study and learn how to do it right. (I won't post my script here since it does not work at all and just consists of TBGL_Entity-Skeleton and lots of unstructured, unreadable, always crashing callback-mess.)
Can anybody please do me a favour and create some skeleton that should open a TBGL-Window (I use TBGL_Entity), one separate, always persistent and visible Dialog which holds just a menu-bar (File, Help etc.) where I might add a toolbar and a statusbar later and one demonstration-Dialog that shall be just a template for any settings that the user might apply (somewhat like Help\About-Dialog maybe for the template). So user could later enter some values and close or cancel the dialog. I want to create a few different of those Settings-Dialogs later, if I learned how to keep them alive without blocking program flue or crashing the tB-Compiler.
TBGL-Window and Menu-Dialog shall not be close-able separately, so they both shall be always visible until application ends. TBGL-Window won't need a close-box nor system-menu since the End-Program-Command will be given from Menu-Dialog (File\End) and all F-Keys (especially F10) are supposed to work within TBGL-Window.
Since this is already totally off-Topic it might be a good idea to post it in some discussion-free Skeleton-Thread in the Template Section (http://www.thinbasic.com/community/forumdisplay.php?324-Templates)
Thanks in advance