Multiple Canvases

BlitzMax Forums/MaxGUI Module/Multiple Canvases

gameshastra(Posted 2007) [#1]
How do I paint to multiple canvases without introducing flicker. In win32 you normally would create a separate thread for each canvas. In blitzmax there is no thread feature that I know of.
How is painting to be done to multiple possibly overlapping canvas objects without disturbing each other.
Currently I am having to do the following before each painting
DisableGadget(previousgadget) EnableGadget(currentgadget) SetGraphics(Canvasgraphics(currentgadget))
'Do the painting here
DisableGadget(CurrentGadget)
EnableGadget(previousgadget)

I am generating timer events for the canvas that needs to be redrawn and calling the above code for the painting

this sequence is introducing flicker
What is the correct sequence of operations ?

Regards,
Ramesh


Brucey(Posted 2007) [#2]
Overlapping canvas objects?

Not a good idea at all, really.


gameshastra(Posted 2007) [#3]
I manage the painting by invoking the correct object at the time. But as long as a gadget is enabled no other gadget recieves messages until the current gadget is disabled and the other gadget is enabled. If I have an overlapping canvas I Plan to grab the overlapping image and redraw the overlapped portion so that painting in one canvas doesn't effect the other canvas.
Is it not possible to make a canvas recieve the mouse
messages when the mouse is on the canvas when there are multiple canvases.
How to get the effect of multithreading with different canvases?
Regards,
D.Ramesh


Dreamora(Posted 2007) [#4]
You won't.

While a canvas is active, the input is mapped to this canvas.

If the canvas is not active, then the mouse events will be generated depending on where the mouse is over (mouse move)

And still: overlapping canvas is a bad idea. Canvas are not meant to be used like that and you can get all sort of funny graphical glitches. Better use 1 canvas and draw the object in there. you can use viewports etc to fake more than 1 canvas within.


computercoder(Posted 2007) [#5]
Before you end up struggling with the issue of Refresh flicker as well, make sure you sync the Flip with the refresh rate by Flip True (or 1)

I had a heck of a time with my stuff b/c the refresh was messing with it. After I was enlightened by my buddy, I have no more refresh problems.


gameshastra(Posted 2007) [#6]
Then why are allowed to create multiple canvas objects in the first place ?. I am trying to create a custom controls so I need to handle multiple canvas objects. I guess I will try with a single canvas and assuming no windowing support for the custom controls.

Ramesh


computercoder(Posted 2007) [#7]
Well... you can do multiple canvases in a window. I have three. The deal is you don't want canvases to overlap. Mine are separated from each other. I am working on a 2D Tile Map designer that calls for multiple canvases in the manner I laid it out.

I have no flicker btw. I basically use the waitevents() and look for the EVENT_GADGETPAINT event. There, I call the draw routine for each canvas. The following flo is what I use:

SetGraphics CanvasGraphics(gadget)
SetViewPort
ActivateGadget(gadget)
Draw stuff
Flip True
Cls

Move on to the next one

Hopefully this helps?

Enjoy.