Re: Repeat efficiency
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 18, 2003
- 480 views
On Tue, 18 Feb 2003 12:30:21 -0800, xerox_irs at lvcm.com wrote: >"zbuffer=3Drepeat(repeat(0,1024),768)+0.0" --takes a minute but makes =46irst, take a good, long, hard look at not using fractions. If there is any way to do this stuff in integers only (eg instead of working things out in inches with an accuracy of 1/1000th of an inch, just work everything out in 1/1000th's of inches), then everything will be fifty times faster as well. Secondly, especially for something of obviously fixed size like this, seriously consider allocating a block of memory and knocking up a few simple routines to peek and poke it. Not strictly euphoria, but once "black-boxed" you won't care. eg (warning completely untested!): zbuffer=3Dallocate(1024*768*4) type x_coord(integer x) if x<1 or x>1024 then return 0 end if return 1 end type type y_coord(integer y) if y<1 or y>768 then return 0 end if return 1 end procedure procedure setz(x_coord x, y_coord y, integer value) poke4(zbuffer+(x-1)*1024+y-1,value) end procedure function getz(x_coord x, y_coord y) return peek4s(zbuffer+(x-1)*1024+y-1) end function You can quickly validate this sort of code by checking that setz/getz(1,1) stores/gets first four bytes of zbuffer and that setz/getz(1024,768) the last 4 (ie 1024*768*4-4) (declare/pass x and y as normal integers, the types above are for local safety checks only and can be turned off (for speed) by specifying without type_check once it all works). HTH Pete