Welcome, Guest.
Please login or register.
Overloading WinX draw functions
Forum Login
Login Name: Create a new account
Password:     Forgot password

XBLite Forum    General Boards    XBLite Programming  ›  Overloading WinX draw functions
Users Browsing Forum
No Members and 1 Guests

Overloading WinX draw functions  This thread currently has 12,427 views. Print Print Thread
2 Pages 1 2 All Recommend Thread
Carry
March 19, 2013, 11:49am Report to Moderator Report to Moderator
Baby Member
Posts: 36
I'm writing a charting program that displays a fair amount of line/rectangle/text graphics using WinX. I'm finding a problem that when I have a lot of graphics repeatedly refreshing, my program crashes out.

Here is what I have figured out about WinX drawing objects:

1) There is a limit of 4,194,304 drawing objects that a window can create - WinXClear() doesn't seem to reset the drawing object id counter to 0. This number is not that much when you have a lot of refreshing graphics. I think this really needs to be fixed and there probably is an easy solution. Anyone know how?

2) There is a limit of about 10,000 drawing objects a window can display at once. For me, I don't have any problem with this.


Regards,

Gary
Logged Offline
Private Message Private message
Carry
March 19, 2013, 10:55pm Report to Moderator Report to Moderator
Baby Member
Posts: 36
To prove my point I have made a test program. It takes a minute to run before drawing failure (at return id=4194304).

Gary



This post contains attachments; to download them you must login.

Logged Offline
Private Message Private message Reply: 1 - 17
Carry
April 10, 2013, 1:46am Report to Moderator Report to Moderator
Baby Member
Posts: 36
In the end I made my own drawing functions from scratch. Couldn't live with the WinX draw function limit.

WinX gracefully has an onPaint callback, so you can draw your own graphics.

I'm quite happy with the way my code turned out. Maybe someone else will find it of use also.

(Note that the text in window 2 is a bit misleading. What I meant is that an object record has been modified and each object is updated separately.)



This post contains attachments; to download them you must login.

Logged Offline
Private Message Private message Reply: 2 - 17
ChandraMDE
April 10, 2013, 2:57am Report to Moderator Report to Moderator
Baby Member
Posts: 7
Hi,
I've tried both of your attachment. Both are resulting the same error:
> Executing: C:\xblite\bin\xblite.exe "C:\xblite\chandra\Graphics.x" -conoff
WinX.dec(5): Duplicate Definition(1)
WinX.dec(6): Duplicate Definition(1)
WinX.dec(7): Duplicate Definition(1)
WinX.dec(: Duplicate Definition(1)
WinX.dec(9): Duplicate Definition(1)
WinX.dec(10): Duplicate Type(6)
> Done. Compiled file in 62 msec
***** ERRORS =  6 *****
> Execution finished.

What is wrong with my WinX.dec ?

I have never been using WinX...
Logged Offline
Private Message Private message Reply: 3 - 17
Carry
April 10, 2013, 4:00am Report to Moderator Report to Moderator
Baby Member
Posts: 36
Download the latest WinX from here:

https://code.google.com/p/xbl-winx/downloads/detail?name=WinX_0_6_0_15_setup.zip&can=2&q=
or
https://code.google.com/p/xbl-winx/downloads/list


I really like WinX because it hugely simplifies coding XBlite. Having said that, my demo only uses WinX for setting up the window and push buttons. Otherwise the drawing functions don't need WinX to run.
Logged Offline
Private Message Private message Reply: 4 - 17
ChandraMDE
April 10, 2013, 5:04am Report to Moderator Report to Moderator
Baby Member
Posts: 7
Yes, now it's working.
I think those are great codes for me to learn.
Thanks.
Logged Offline
Private Message Private message Reply: 5 - 17
Carry
April 11, 2013, 10:47pm Report to Moderator Report to Moderator
Baby Member
Posts: 36
I have improved the old accessors.m4 file as it was causing linked lists to just keep growing and growing until they run out of memory. It also solves all the original problems I had at the start of this thread.

I think this new version is working really efficiently and nicely. It uses a stack to keep track of where there are empty record spaces available.

The only difference to the end user is that with various clears and deletes, the object id's may not list consecutively 1,2,3,4.. but can be in any order as the functions re-use available spaces. Should not be any problem, you could even come up with a function, something like WinX_DrawIdNext() to allow object id walk-throughs of the linked list.

To use the attachment, you need the source code to rebuild adt.dll and WinX.dll with accessors.m4.

So Guy, if you are reading this, what do you think of this in the next WinX revision?



This post contains attachments; to download them you must login.

Logged Offline
Private Message Private message Reply: 6 - 17
Carry
April 12, 2013, 1:56am Report to Moderator Report to Moderator
Baby Member
Posts: 36
FUNCTION WinXDrawIdNext (hWnd, idCtr)
     LINKEDLIST list
     BINDING binding
     RECT rect

     IFF BINDING_Ov_Get (hWnd, @idBinding, @binding) THEN RETURN
     LINKEDLIST_Get (binding.autoDrawInfo, @list)
     hWalk = LinkedList_StartWalk (list)
     DO WHILE LinkedList_Walk (hWalk, @iData)
          IF iData=idCtr THEN EXIT DO
     LOOP
     IF LinkedList_Walk (hWalk, @iData) RETURN XLONG(iData)
     RETURN $$FALSE
END FUNCTION
Logged Offline
Private Message Private message Reply: 7 - 17
Carry
April 12, 2013, 2:34am Report to Moderator Report to Moderator
Baby Member
Posts: 36
This is the original accessors.m4 with just the necessary fixes to keep the linked lists under control.

I have added a new $1_idMin variable and an extra line in the Delete() function which broadens the FOR loop search for an empty space.

To be fair I can't see a huge speed difference between this and my rewrite. You be the judge. If speed is critical to your app, then I have found my graphics functions with WinX onPaint() to be by far the fastest option.



This post contains attachments; to download them you must login.

Logged Offline
Private Message Private message Reply: 8 - 17
teslaXB
April 18, 2013, 7:22pm Report to Moderator Report to Moderator

Baby Member
Posts: 22
Carry.
if I understand your code correctly ..
you create Linked List with array using almost standard BASIC coding style.
I have a question ,,,what you mean how tuff should be translate your code to other basic -like
compilers ???
thanks ...
Logged Offline
Private Message Private message Reply: 9 - 17
Carry
April 19, 2013, 12:43am Report to Moderator Report to Moderator
Baby Member
Posts: 36
Hi teslaXB,

Yes, my code creates linked lists within a data array. Should be no problem at all to translate XBLite code to other basic-like languages. You just need a fairly good knowledge of both languages.
Logged Offline
Private Message Private message Reply: 10 - 17
teslaXB
April 19, 2013, 12:12pm Report to Moderator Report to Moderator

Baby Member
Posts: 22
Hi Carry..
is this variables with SHARED are global or local variables ?
I think that are GLOBAL ?
Logged Offline
Private Message Private message Reply: 11 - 17
Carry
April 20, 2013, 1:26am Report to Moderator Report to Moderator
Baby Member
Posts: 36
Using the "#" symbol in front of a variable makes the variable global.

With the SHARED statement, variables are accessible by other functions so long as they also have a similar SHARED statement.
Logged Offline
Private Message Private message Reply: 12 - 17
Carry
April 25, 2013, 10:54pm Report to Moderator Report to Moderator
Baby Member
Posts: 36
This is a library I have been working on to draw simple 2D lines, text & images in OpenGL. I'm finding that while OpenGL runs very fast, it takes a lot of effort to program even the most basic stuff like text & images.
My demo uses WinX to set up windows and push buttons. Extra function calls make the child windows run OpenGL.



This post contains attachments; to download them you must login.

Logged Offline
Private Message Private message Reply: 13 - 17
Guy1954
May 26, 2013, 4:18pm Report to Moderator Report to Moderator

Medium Member
Posts: 187
Quoted from Carry
(...)
To use the attachment, you need the source code to rebuild adt.dll and WinX.dll with accessors.m4.
So Guy, if you are reading this, what do you think of this in the next WinX revision?


Hi Gary,

Sorry for e-mailing you so late but I've been working lately on XBLite Unicode compilation.
I'll have a look at your accessors.m4, thank you for your contribution.

Happy xbliting!
Guy
Logged Offline
Site Site Private Message Private message Reply: 14 - 17
Guy1954
May 31, 2013, 11:49am Report to Moderator Report to Moderator

Medium Member
Posts: 187
Quoted from Carry
To prove my point I have made a test program. It takes a minute to run before drawing failure (at return id=4194304).

Gary


Hi Gary,

You definitely made your point here: there is no good reason for WinX.dll to set such a limit.
I re-worked assessor.m4 to re-used deleted spots.
Would you believe it? I got it right only after messing Callum's library quite a lot.
(What is wrong with my right brain?)
Good thing that I tested it in real use.

Well, as far as I know, your drawtest2.x does not crash anymore. Maybe can you confirm this yourself?
Anyway, thank you for your bug report.

Bye! Guy

Logged Offline
Site Site Private Message Private message Reply: 15 - 17
Carry
June 4, 2013, 10:29am Report to Moderator Report to Moderator
Baby Member
Posts: 36
Yes, this is very good. It doesn't crash now and that's the main thing.

I just want to mention that I believe it is possible to make the accessors functions even more efficient, but there are pros and cons with every method. It depends on how you manage the usage map as long FOR loop searches for empty slots tends to slow things down.

For example, the accessors.m4 that I posted earlier makes use of a stack to directly keep track of empty slots (no long FOR loop searches). Of course there is the overhead of an extra array.

Another method could be, instead of starting a usage map search from 0, you could keep track of the lowest empty slot and start all searches from this point (keeping track of the lowest empty slot whenever a Delete occurs).

I'm sure there are many methods, but what you have now is straight forward and error free. Usually that's the best approach.

Gary
Logged Offline
Private Message Private message Reply: 16 - 17
Guy1954
June 5, 2013, 1:15pm Report to Moderator Report to Moderator

Medium Member
Posts: 187
Quoted from Carry
(...)

Another method could be, instead of starting a usage map search from 0, you could keep track of the lowest empty slot and start all searches from this point (keeping track of the lowest empty slot whenever a Delete occurs).

I'm sure there are many methods, but what you have now is straight forward and error free. Usually that's the best approach.

Gary

Hi Gary,

Would you believe it? I implemented your last suggestion.
Why?
1. As you mention it, it requires only to start the search loop to index zero,
2. Small change but full payback.

Small change?
I thought of it only after WinX.dll went berserk on me several rounds of unsuccessful attemps.

Morale is: changes are never small when the source is big...

Bye! Guy
Logged Offline
Site Site Private Message Private message Reply: 17 - 17
2 Pages 1 2 All Recommend Thread
Print Print Thread

XBLite Forum    General Boards    XBLite Programming  ›  Overloading WinX draw functions

Thread Rating
There is currently no rating for this thread