-
Hi Rene,
thanks for the updates and the music tip as well! I wrote BASICally complete StringBuilder module when listening to:
TRUE
Checkout RDio.com for tons of music...
The addition Eros made in 1.9.13.0 will make incredible things possible...
Petr
-
i'm screwed- the video is not available in germany because the german government wants to have money before i can listen to this - it's a shame and it's only possible in germany .... you still can pay... viva le capitalism...
-
No problem, try to register at rdio.com:
http://www.rdio.com/
It is perfectly legal, no user content, just official releases. Seek for "Avicii - True".
This is somehow not very intelectually challenging album, but it is fantastic for coding...
I have an account there, we can share coding music if you want.
Petr
-
something else :offtopic: here might be an idea...
currently we do this:
Code:
' assume heap hPtrs holds pointers, created alike
Dword hPtrs = Heap_allocbyStr( MKDWD$( ptr1, ptr2, ptr3, ptr4,...) )
' create local pointer-array on this
Local lPtr(Heap_Size(hPtrs)/4) As Dword At hPtrs
'now it comes, lets say all those pointers point some data of type t_myType
Local lData As t_myType At 0
' until this line my function works pretty well without any real local variables.
' ( hPtrs in reality is noded to some other structure )
' now I need to push the lData-mask forward and place it to the pointers in a loop
' like this
Local i As Long
For i = 1 To Ubound(lPtr)
SetAt(lData, lPtr(i) )
' do something with data...
Next
in many cases i don't need the value of "i" and loop through all elements of Array lPtr anyway and thought about something like this:
Code:
For Array lPtr
' from now on lPtr is an overlay at the "current" element of Array lPtr()
SetAt(lData, lPtr)
' do something with data...
Next
... until here still understandeable ... this does it too- without the need of any real variables, assume hPtrs would be read out somewhere and this were inside some function:
Code:
Uses "console"
DWord hPtrs = HEAP_AllocByStr( MKDWD$ ( _
HEAP_AllocByStr("This is a test"), _
HEAP_AllocByStr("only try out"), _
HEAP_AllocByStr("if it were possible"), _
HEAP_AllocByStr("to bind a few different"), _
HEAP_AllocByStr("sized amounts of data"), _
HEAP_AllocByStr("to just one DWord") _
) )
Dim lPtr As DWord At hPtrs ' this only a virtual surfer
While VarPtr(lPtr) <= hPtrs + HEAP_Size(hPtrs) - SizeOf(DWord)
PrintL HEAP_Get(lPtr) ' usually would SetAt( lData, lPtr ) here...
SetAt(lPtr, VarPtr(lPtr) + SizeOf(DWord))
Wend
PrintL $CRLF & Repeat$(42, "*")
PrintL $CRLF & "Any key to end"
WaitKey
still easy, just when it comes to multidimensional storage it becomes hard to read when you try to avoid real variables
check this:
Code:
Uses "console"
' exxagerate a little bit now
' all noded to one dword:
DWord hPtrs = HEAP_AllocByStr( MKDWD$ ( _
HEAP_AllocByStr( MKDWD$( _
HEAP_AllocByStr("Name"), _
HEAP_AllocByStr("Mail"), _
HEAP_AllocByStr("System" & $CRLF ) _
) ), _
HEAP_AllocByStr( MKDWD$( _
HEAP_AllocByStr("Eros"), _
HEAP_AllocByStr("@Olmi"), _
HEAP_AllocByStr("Intel i7 M620") _
) ), _
HEAP_AllocByStr( MKDWD$( _
HEAP_AllocByStr("Petr"), _
HEAP_AllocByStr("@PSch"), _
HEAP_AllocByStr("Intel Core i5-3350P") _
) ), _
HEAP_AllocByStr( MKDWD$( _
HEAP_AllocByStr("Rene"), _
HEAP_AllocByStr("@home"), _
HEAP_AllocByStr("Intel Core i5-3330") _
) ) ) )
' not any real variables used to read out :D
Dim lPtrLine As DWord At hPtrs
Dim lPtrColumn As DWord At lPtrLine
While VarPtr(lPtrLine) <= hPtrs + HEAP_Size(hPtrs) - SizeOf(DWord)
While VarPtr(lPtrColumn) <= lPtrLine + HEAP_Size(lPtrLine) - SizeOf(DWord)
Print HEAP_Get(lPtrColumn) & $TAB
SetAt(lPtrColumn, VarPtr(lPtrColumn) + SizeOf(DWord))
Wend
PrintL
SetAt(lPtrLine, VarPtr(lPtrLine) + SizeOf(DWord))
SetAt(lPtrColumn, lPtrLine)
Wend
PrintL $CRLF & Repeat$(42, "*")
PrintL $CRLF & "Any key to end"
WaitKey
barely readeable in the end. the same in future syntax if the world were a perfect place...
Code:
Dim lPtrLine(Heap_Size(hPtrs)/4) As Dword At hPtrs
Dim lPtrColumn() As Dword At 0
For Array lPtrLine
Redim lPtrColumn(Heap_Size(lPtrLine)/4) At lPtrLine
For Array lPtrColumn
Print Heap_Get( lPtrColumn ) & $TAB
Next
PrintL
Next
Listen to this while thinking about the above...
-
1 Attachment(s)
Back to gui
i ran into some issue regarding negative coordinates when printing TBGL_PrintFont2D.
Attached image shows twice the same TBGL-window and within you see a box captioned "GUI.tBasicu" on the left with some text inside.
On the right image i dragged the box a little left so it starts outside left of the visible TBGL-window-client. Drawing the box from negative coords is no problem as you see but it won't print the text
:(
Now do I have to render the text onto a texture or cumbersome calculate the very left visible char or use some viewport?
Any simple suggest anyone?
-
Dear Rene,
thank you for your question - this is sadly a behavior of the OpenGL implementation when working with this kind of fonts. It is very annoying, but I found no way around it.
But there is a light at the end of tunnel - you may render the text to texture. How?
You just clear the frame, render the text into positive coordinates, copy the graphical output to texture via TBGL_RenderToTexture and then you map this texture to your window.
I hope this will help you, I will investigate options how to avoid this limitation of Windows OpenGL.
Petr
P.S. I am leaving to Slovakia till Sunday, so I might not be able to reply in that time.
-
i was anxious to get an answer like that because it means to re-think about the mechanics of my gui. perhaps in general it could be better to have no window-alike boxes that just get drawn as now - but each box (i.e. "window") just is a textured quad. would use up quite a few texture-slots but will certainly draw faster if the surface-template of a box/window gets only drawn again if it changes and else use the existing texture again...
the final "printed" font would look better too (automatic anti-aliased) due the usage as texture.
...but...
i'm not sure about sizes, imagine we have a box 100 * 200 pixels, i would need to use a texture of 128 * 256 ( the next power of two) for it to be on the safe side ? that would occupy a lot of unused memory on the graphics-hardware if it were this way...
My other idea was that maybe TBGL_PrintFont2d can be changed in behaviour when negative x-value is passed? I planned to create a function alike that:
Code:
TBGL_SetActiveFont 1
PrintFont "Hello", X, Y, Align1, Align2, MaxWidth
Function PrintFont( ByVal sText As String, _
ByVal X As Long, _
ByVal Y As Long, _
Optional ByVal sAlign As Long, _
ByVal aAlign As Long, _
ByVal maxW As Long )
Local i, lW, lH As Long
While X < 0
If i >= StrPtrLen(StrPtr(sText)) Then Exit While
TBGL_GetFontTextSize( Memory_Get(StrPtr(sText)+i,1), lW, lH )
X += lW
' totalTextwidth += lW ' >>> startX for maxWidth-calculation !
i += 1
Wend
Select Case i
Case StrPtrLen(StrPtr(sText))
Exit Function
Case 0
Nop
Case Else
sText = Memory_Get(StrPtr(sText)+i, StrPtrLen(StrPtr(sText))-i)
End Select
' don't bother actual alignement nor passing maxWidth for this example
' this approach only works for left-aligned, else much more complicated
TBGL_PrintFont2D sText, X, Y, sAlign, aAlign, maxW ' - totalTextwidth
End Function
-
Stay tuned Rene,
I am investigating ;)
Petr
-
Haha! I think I got it!
Let me know, if tbgl_PrintFont and tbgl_PrintFont2D works for you as expected now :dance1:
If yes, I will update help file and binaries for next ThinBASIC...
Petr
Attachement removed.
-
1 Attachment(s)
sadly does not print any text at all now :(
attached latest version - Attention, needs thinCore.dll from other thread, use version of september 10th !