r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

Maxim
23-Aug-2010
[10150x2]
the system I am using now, is doing double buffering.  the AGG is 
rendered on the raster, and the call to show, tells view to update 
the window's bitmap so it reflects the changes to the raster.
the raster being a pre-allocated image! which I use with the  'draw 
  function.
AdrianS
23-Aug-2010
[10152]
looked flicker-free, so I assumed it was
Maxim
23-Aug-2010
[10153x2]
cool thing is that if we don't blank the bg manually, we actually 
get a persistent buffer, and can do things like winamp visualizers 
easily.
but that means using face effects (and hence going thru view and 
back) which will kill the speed pretty quickly  :-(
AdrianS
23-Aug-2010
[10155x3]
why would this kill speed?
is it view being slow or just doing these kinds of effects in REBOL 
that is not so fast?
I thought I remembered some pretty fast animations (with effects) 
done by cyphre some years ago - he bypassed view effects for those?
Maxim
23-Aug-2010
[10158]
image processing requires a lot of CPU juice.


 we have to render the AGG, use the bitmap in a face, apply an effect 
 on it, and then re-create a new bitmap out of it.  we aren't just 
 drawing/effecting over and over the same image memory area but creating 
 a new image at every refresh.


it would be nice if there was a complement to the 'draw function 
called 'effect.  maybe its in R3, or maybe it should be.
AdrianS
23-Aug-2010
[10159]
sure it's slow - especially at today's fullscreen resolutions - that's 
a lot of pixels to process per second - maybe a view extension for 
offloading some of that on the GPU is in the works
Maxim
24-Aug-2010
[10160x2]
wrt console I/O killing gfx speed.... with my new high-performance 
chrono lib, here are the results for printing... compared to a single 
(average) call to sine. 

[print ""]
0:00:00.000792139

[prin "."]
0:00:00.000168666

[sine 45]
0:00:00.000001014
updated the animated vector projection tests script:

-uses the chrono library for more precise time management.

-now has option to prevent clearing the image at each refresh (feedback), 
press enter

-you can also manually increase and decrease max frame-rate on mouse 
drag using arrows.


http://www.pointillistic.com/open-REBOL/moa/files/ptest-preboled.r

on my system, I can easily go up to a 100fps before feeling lag.
AdrianS
24-Aug-2010
[10162]
I get 32 fps - surprised it's not higher
Sunanda
24-Aug-2010
[10163]
I also see current rate typically of 32fps/ current (max) rate shows 
as 40.00000000001 (plus or minus a zero)
AdrianS
24-Aug-2010
[10164]
hmm, I'm guessing it's not a system dependent limit - hard to believe 
that we have exactly the same specs
Brock
24-Aug-2010
[10165]
Not sure if I am doing something wrong, but I simply get a black 
screen when trying the latest update.  I was able to view the initial 
demo.  Tried view 2.7.6.3.1 and 2.7.7.3.1.
AdrianS
24-Aug-2010
[10166x2]
still works here
with 2.7.7.3.1
Brock
24-Aug-2010
[10168]
worked fine on my work laptop, but not my older desktop PC.
DideC
25-Aug-2010
[10169]
Same as brock : just a black screen. WinXP 32 SP2 / Rebol 2.7.7.3.1
AdrianS
25-Aug-2010
[10170]
interesting - I'm guessing it's the offscreen buffer - maybe can't 
be alocated or flipped to properly - maybe a video card/video driver 
issue. Brock/Didec, are the video cards you're using of the onboard 
type with shared memory?
Brock
25-Aug-2010
[10171]
The desktop is not an on-board graphics card, the laptop would be. 
 In both cases I'm not certain about the memory.
JoshF
28-Aug-2010
[10172x4]
Hi! Hope this is the right place to ask... I'm using 2.7.7.3.1 (not 
that it should matter for this question)...
I would like to use and re-use vid "panel" gui elements. Something 
like: view layout [style gint panel [text "label:" field 100 "0"] 
 x: gint (x) y: gint (y)]
The idea is that somehow (magically?) the panel could specify an 
aggregate UI element so I could reuse just a few styles that have 
their formats baked in. Any ideas? Or should I come up with a better 
example?
Preferably, this would be done at view definition time as shown above.

set-face

 seems to show a way to handle it, but it's clumsier than I would 
 like and doesn't handle the text labels.
Sunanda
29-Aug-2010
[10176]
Does stylize provide what you need?
   http://www.rebol.com/docs/words/wstylize.html
Anton
29-Aug-2010
[10177x4]
Hi JoshF, do you want a style (eg. your 'gint') that is simply replaced 
by two other styles (eg. a TEXT and a FIELD) as if you had simply 
specified them individually yourself, or do you want a panel each 
time (which contains the other faces) ?
A simple approach that might work for you is to build your layout 
spec block before passing to LAYOUT.
make-gint: func [label int][compose [label (label) field 100 (mold 
int)]]

window-spec: compose [title "Food calculator" (make-gint "Elephants 
to invite" 65536)]
append window-spec make-gint "Peanuts/elephant" 5000
view layout window-spec
Check out this doc from 2007 as well.
http://anton.wildit.net.au/rebol/doc/flatten-panel.txt
JoshF
29-Aug-2010
[10181]
Hi! Thanks for the replies!


Sunanda, I am using stylize (as shown in the example below). Anton, 
I don't mind having a panel because I need to keep the data grouped 
to access it generically after the user has set values. Here is a 
better example showing what I'm trying to do. Essentially, I want 
to create an "aggregate" widget using a styled panel, then initialize 
its elements the same way as is done for the built-in VID styles:

    REBOL [Title: "Node Property Sheet" Author: oofoe] 
    ; This example will not actually work as intended.
    
    s: stylize [
    	title: vtext red 256
    	label: text 64
    	gpath: panel [

      across  label "Path:"  field 150 "Unspecified"  button "..." 30]
    	gint: panel [across  label "Integer:"  field 50 "0"]
    	gnumber: panel [across  label "Number:"  field 75 "0.0"]
    ]
    
    view layout/size [
    	styles s
    	
    	title "Project Settings"

     gpath "main" %. ; <-- I want to just specify the label text and value.
    	gint "width" 1024
    	gint "height" 768
    	gnumber "fps" 23.97
    ] 384x256


The nice thing about this (from my perspective) is that I can iterate 
through the property panel fields, find any recongized styles and 
pickup their values (that have been set by the user) using a hacked 
version of get-face. 


Am I making sense? I just feel that there should be a way to set 
relevant panel values when you're using the style. Thanks!
Anton
29-Aug-2010
[10182]
It definitely makes sense, and I wanted to do this many times myself, 
but I just never got around to doing it.
JoshF
29-Aug-2010
[10183x2]
It seems like the "do-facets" section in the "layout" source is the 
key (or close to the key) for doing this. There *is* a generic system 
for handling this, but it's not documented (!) and the layout source 
is far too clever for me to easily figure it out... ; - )
Possibly a style should define a function that is used by layout 
to set it's values. If so, I can do that with "with" and the problem 
is solved...
Anton
29-Aug-2010
[10185x4]
Yep, LAYOUT style-specific sub-dialects are possible by messing with 
the MULTI facet, or with the WORDS facet.
or better, with the FACETS facet.
Try this:
stylize/master [
	gint: panel [across label 200 field] with [
		multi: make multi [
			text: func [face blk][ ; <- strings
				if pick blk 1 [
					print ["Text:" mold blk/1]

     ; Do nothing (prevents the default PANEL/MULTI/TEXT from setting 
     the panel's face text).
					;  print mold get in svv/vid-styles/PANEL/multi 'text
				]
			]
			size: func [face blk][ ; <- pairs and integers
				if pick blk 1 [
					if integer? pick blk 1 [
						print ["Integer:" blk/1]
						; Do nothing.

      ; I was going to set the integer field's text to this number directly, 
      but the panel's

      ; subfaces haven't been created (in its PANE) at the time the MULTI 
      functions are processed.

      ; So then I thought I'd use FACE/DATA to store this value and then 
      set the field's text

      ; later in INIT, but thought better of it, since I found it's easier 
      to parse FACETS,

      ; and I don't feel comfortable using the panel's DATA facet to store 
      a value of only
						; one of its subfaces.
						;face/data: blk/1
					]
				]
			]
		]
		append init [
			;?? texts
			;?? facets
			context [
				lbl: pane/1
				fld: pane/2
				foreach val facets [
					case [
						string? val [lbl/text: val]
						integer? val [fld/text: form val]
					]
				]
			]
		]
	]
]
view window: layout [
	gint "Elephants to invite" 481
	gint "Peanuts / elephant" 5000
	btn "Calc"
]
JoshF
29-Aug-2010
[10189x3]
OK... Hang on, I'm just trying to figure understand all this...

So the "facets" value inside the init/context is just the arguments 
to the style in the original layout?
Thank for the example, Anton! Mind: Blown. I know Kung-f... I mean, 
how VID initialization works!


Here's my cleaned up (and working!) test program. It should be a 
little more generic than your example, since it will set values until 
it runs out of facets or pane items. Label styles are treated specially 
though, as you can see. Maybe now I can fix their set-face method...

    REBOL [Title: "Node Property Sheet" Author: oofoe] 
    ; Special thanks to Anton on altme/Rebol/View! 
    
    s: stylize [
    	title: vtext red 256
    	label: text 64
    	agg: panel with [
    		multi: make multi [
    			text: func [face blk][]
    			size: func [face blk][]
    			decimal: func [face blk][]
    		]
    		append init [
    			context [
    				p: pane  f: facets
    				while [all [not tail? p  not tail? f]] [
    					either 'label = p/1/style [
    						p/1/text: f/1
    					] [
    						set-face p/1 f/1
    					]
    					p: next p  f: next f
    				]
    			]
    		]
    	]
    	gpath: agg [

      across  label "Path:"  field 150 "Unspecified"  button "..." 30]
    	gint: agg [across  label "Integer:"  field 50 "0"]
    	gnumber: agg [across  label "Number:"  field 75 "0.0"]
    ]
    
    view layout [
    	styles s
    	
    	title "Project Settings"
    	gpath "main" %. 
    	w: gint "width" 1024
    	h: gint "height" 768
    	gnumber "fps" 23.97
    ]

This is so cool! I am excited!
Here's the agg style with get-face doing what I want (returning the 
field name with everything else in a list, suitable for dropping 
into a key/value list):

	agg: panel with [
		multi: make multi [
			text: func [face blk][]
			size: func [face blk][]
			decimal: func [face blk][]
		]
		append init [
			context [
				p: pane  f: facets
				while [all [not tail? p  not tail? f]] [
					either 'label = p/1/style [
						p/1/text: f/1
					] [
						set-face p/1 f/1
					]
					p: next p  f: next f
				]
			]
		]
		access/get-face*: func [face /local p label x] [
			p: face/pane
			label: to-word p/1/text  

			p: next p
			x: copy []
			while [not tail? p] [append x get-face p/1  p: next p]

			return reduce [label x]
		]
	]
Anton
30-Aug-2010
[10192]
Well, thankyou for asking the question. It's nice to see your working 
result, too.
Maxim
31-Aug-2010
[10193x5]
shape collisions  :-D
a little milestone  in my rebol game development kit... 

The first version of an SAT-based collisions lib for arbitrary convex 
polygon  is now fully functional:

test it in action in this test script:


do http://www.pointillistic.com/open-REBOL/moa/files/ctest-preboled.r


note that it handles shape rotation which isn't always supported 
in implementations of this algorithm on other platforms.
the SAT (Separating Axis Theorem) algorithm is even optimised so 
it only manages the edges facing each other.

the result will be several times faster since we end up only comparing 
(at a maximum) half the edges of each polygon ( for two boxes this 
ends up being 2^2+2^2 (8) as opposed to 4^2+4^2 (32)comparisons. 
 for a triangle and a box, it could even end up being as little as 
1^2+2^2 (5)  instead of 3^2+4^2 (25).


the advantage of the SAT algorithm is that its reasonably fast and 
is an early opt-out loop, so the moment we find a single comparison 
which is negative, we can positively ignore all the rest.   this 
means that it scales pretty well, when polygons aren't close to each 
other or when they are small.
next step is implementation of the gross-level polygon proximity 
test (a fast algorythm ignoring polygons which are too far away). 
 


this allows many polygons to live in the same scene without requiring 
collision tests for them.


I'll probably use a double linked-list for X and Y sorting of polygons. 
 this allows us to start at our position directly and spread the 
search on each side of the list (in both directions).
has anyone played around with SAT systems before?  or with spatial 
sorting algorithms?
I have questions about the most adapted spatial sort algorithm to 
use in REBOL
Oldes
31-Aug-2010
[10198]
Nice work.. it would be even more interesting if Cyphre's JIT could 
be used to speed up some of your functions one day.
Maxim
31-Aug-2010
[10199]
yes I was thinking about it, especially since most of the CPU intensive 
code is highly compilable.