We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi again! I'm still probing the g4p control and now I have problems with showing an extra window. The problem is that I really don't understand how it works and how can I obtain data from that other window, for example use pixels when I click a button in the main sketch.
Answers
http://forum.Processing.org/two/discussions/tagged/gwindow
If you have a GWindow called
gw
then you can access the pixels usingThis can be difficult because the main sketch and
gw
are speate threads so there is a very high risk of concurrent access exceptions if you attempt to modifygw
's pixels from the main sketch. It needs careful program design to avoid this. I suggest that you create a simple sketch with a single GWindow and experiment with that.is it similar if I want to use millis()??
millis ()
returns the time the applet started. I suspect thatgw.papplet.millis ();
will return the time since
gw
was created. You would need to confirm this yourself by experiment.Thank you so much I will probe it :D. I made some tests with pixels and it work really good
you were right, millis() start in the moment the new window is opened :)
I'm trying to copy what is happening in one window into another every x-time. But I don't know if what I am doing is correct. This is my code:
It sometimes works when I make the modulo with values that are less than 40 (millis()%40) but the values are greater it doesn't work, can you help me please?
the draw method is called ~60 per second so the time interval between frames is about 17ms. The chances that
millis() % 40 == 0
is extremely small and is gets worse when you increase the 40. Also this is not a good solution because the main display will flicker because only sometimes the window is copied/The following code is one way to do what you want although you still have a little flicker.
Notice I don't call
window.papplet.updatePixels ();
you only need to do that if the pixels changeok, that is a great program, but i want to copy the window every 2 seconds (more or less), that`s why I was using millis(). How can I do that??
In 2 seconds the
draw()
method would be called 120 times. It means the image will be displayed in 1 frame and not displayed in 119 frames. I suspect that is not what you want but i could be wrong ;)I suspect that you want to see the contents of the 2nd window in the main window all the time but update it every 2 seconds. The following program demonstrates how you might do this.
thank you so much!!! That is what I tried to do :)