View Full Version : UI & TBGL -- active window
Hi all,
A slight problem ...
Started the reverse life3D , building the stable cells > 3 and upwards.
The SUBs are controled by the main UI window , the show is under TBGL -- but at this moment it is not the active window any more -- it does not receive the keyboard interrupts .. is there a simple trick to make it the main event/and receiving window during these loops ?? (this would be handy).
The other difficulty is I have to interrupt uncompleted iterations (which is done by boolean flags), maybe there's a cleaner way -- timers/multi-taksing ? ?
thanks in advance
Rob
Petr Schreiber
12-11-2013, 11:02
Hi Rob,
I would recommend to use the way proposed by template TBGL/TBGL_InDialog_BasicSkeleton.taguit - it shows how to use label in dialog as rendering surface for TBGL.
The rendering is timer based then.
Petr
ReneMiner
12-11-2013, 12:43
Hi, I tampered around a little and made some - I don't know - multiple windows-example trying to put your code in but I'm not really awake yet, somehow I did not get your graphical stuff to run as desired- but you might have a look to check for multiple dialogs, canvas, global keyboard-input, timer & stuff. :)
Edit: I think I've found a reason for my problems this morning... seems you dimensioned a few counter-variables (i,j,k) globally.
I'd suggest to make local statics for probably often called functions - the advantage is - there's no dimensioning time needed after the first call any more, but needs a few bytes...
Now there's some strange behaviour when accessing O2 - it says "The linked function has no address" ? so I commented this line in TBMain and I can not use start-button
Thanks Petr, Reneminer -
I think I'll start it all over again.
it says "The linked function has no address" -- that's odd .. any idea what's happening ??
best , Rob
Hi all,
FWIIW (I hope you don't mind showing non-TB code) - how it is done under GFA.
It's a rather clean way -- the source is in *.g32.
(The manifest file to switch to XP layout -- I think GFA GmbH went bankrupt before XP was on the market).
The output is directed by "Set Me = " the OpenGL window which is just enclosed on another form.
The compiler has the status of "abandonware" - but there is some excellent documentation (in German) except everything related with OpenGL.
best, Rob (for those who collect programming languages ;-)
As Petr adviced ..
works great , I have to check my own code .. the expand is rather iffy (because one cell can generate 2 (or more) new ones - but it should fall back on a copy of the starting position in a cycle. )
Needs TB 1.9.11.0 (forgot to include this in the program).
There's something else to take notice about when working between O2 and TB , it seems O2 can address array(0) too , while TB not.
best Rob
(oops , yes ... eXpand means, keep the current configuration and start over with this one - next means , find the next cell in the loop )
.-- the problem escaping out of 3 loops was solved by using a number as if it were a flat array , the reason is not the exit itself, but initiating the loops again - this works except when one (or 2 or 3) reach their maximum number and will be read from extern variables. (from there the sub ix2ijk )
Petr Schreiber
15-11-2013, 10:50
Hi Rob,
I am happy it works for you, example ran great on my PC.
You are right ThinBASIC arrays cannot index cell zero, all arrays are 1 based by design.
Possible improvements:
Change current minsize to:
Dialog Set Minsize hDlg, %MAIN_WIDTH, %MAIN_HEIGHT
Add following to tune the resizing:
Control Set Resize hDlg, %nxt, 0, 1, 0, 1
Control Set Resize hDlg, %expand, 0, 1, 0, 1
Control Set Resize hDlg, %edbox, 1, 0, 0, 1
Control Set Resize hDlg, %check1, 1, 0, 0, 1
Control Set Resize hDlg, %check2, 1, 0, 0, 1
To fill array with zeros, you don't need to iterate over each single member, try:
ARRAY FILL gen0 WITH 0
... but please note numeric arrays are always filled with zeros after declaration, so it might not be needed at all.
You can speed up the assignment in case you copy one array to another, presuming they have the same number of dimensions, cells share the same data type.
This is why instead of callin fromCopy, which is iteration based, you can perform memory block copy:
' -- MemoryCopy( sourceAddress, destinationAddress, sizeOfMemoryBlock )
Memory_Copy(VarPtr(genCopy(1,1,1)),
VarPtr(gen0(1,1,1)),
SizeOf(gen0(1,1,1)) * UBound(gen0, 1) * UBound(gen0, 2) * UBound(gen0, 3))
Petr
Thanks Petr, I'll study your suggestions.
... Resize .. ah, ok -- I'll read the documentation.
Array Fill -- I was unaware it also worked for non flat arrays.
"always filled with zeros after declaration" .. yep, it's on old habbit after some traumatic experience with very early primitive compilers, which allocated memory inside the program's image - as some of them just made a program counter's jump during compile time and leave an address on the stack during run time, there were some disasters .. These languages were so primitive, you could program the language compile and (!) run-time behaviour for a certain definition. I do not think much of them survived up till today, maybe FACTOR is an exception. (on the other hand, they were lightning fast ).
Memory_Copy .. I was looking for something like this .. should speed up things a very lot ! thanks again !
best Rob
Hi all,
It starts looking like something now.
(includes Petr's tuning and calls the O2 function 5x now, also prevented to add a cell at an occupied place).
Still very iffy , the problem is the determination of a stable form (because some a reach periodic state).
However, it seems by adding cells on a stable form nothing generates the "nothingness" ...
best Rob (just "Spielerei" this program - mainly to get comfortable with TB )
Ah, yes, Petr -- your _UseVsynch is that windows only ? when running your module under Linux , it seems neglected ... just curious
Petr Schreiber
16-11-2013, 16:37
Hi Rob,
the VSync manipulation is done via valid OpenGL call, it is not a hack.
I don't know why it shouldn't work on Linux, but according to internet discussions you could try one of the following steps:
http://stackoverflow.com/questions/17196117/disable-vertical-sync-for-glxgears
Petr