Path: chuka.playstation.co.uk!news From: James Shaughnessy Newsgroups: scee.yaroze.beginners Subject: Re: Plotting 2D Boxes in a 3D World (+ faster code hint!) Date: Fri, 15 May 1998 01:05:01 +0100 Organization: Bacardi Ferrari V12 Lines: 48 Message-ID: <355B86AD.3C0@manc.u-net.com> References: <355a3dc2.2999054@news.playstation.co.uk> <355A67EA.137C@mdx.ac.uk> <355B0CD4.2A85@writeme.com> NNTP-Posting-Host: manc.u-net.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0 (Win95; I) James Rutherford wrote: > Robert Swan wrote: > > PS, I think from what James Shaughnessy found out that there is a > > quicker way of drawing one by one dots, and that is to have a 1x1 > > pixel large sprite, and use that instead of boxes. You can alter the > > r,g,b member attributes of the GsSPRITEs to get different hued dots. > > Although, thinking about it now, James was not using boxes in the > > first place, so maybe its worth checking if sprites are faster. > > I'm pretty darned sure that GsSPRITEs (min. size 4x1?) are faster than > GsBOXFs. Also fairly sure that GsLINEs with x0,x1 and y0,y1 I originally was using ClearImages to draw single pixels which was MERDE slow (about 1 HSync just for one single call! NEVER use this for plotting, but as James R says an array[x*y] for a section of screen is a top way for area plotting with a single LoadImage to slap it over). Indeed now I use a 1x1 sprite to plot pixels (and change rgb members as you say Robert to alter the colour -- nice to see you notice my 'technique', oo'er) which I would say would be much faster than a 1x1 BOXF. A 1x1 GsSPRITE is perfectly legal by the way (my Grav bullets are all GsSPRITES), and I think you can re-use the single sprite to draw hundreds of pixels in one go -- just keep reSORTing it into the OT after each manipulation (please correct me if I'm wrong). Just one thing I'd like to say as I've been reminded by the array[x*y] thing. This may be old news but here a little hint that assembly coders will no-doubt know about. Say you have an array for a full screen: array[320*240]; As everyone knows you access a coordinate with the formula: x+y*320 WRONG! It is much quicker to do x+y*256+y*64 (but using BITSHIFTS) to avoid doing a (relatively slow) multiplication, like so: offset = x+(y<<8)+(y<<6); // for a screen 256+64=320 pixels wide Bit-shifts look scary to C newcomers (like when they first see the code for the PadRead function) but THEY ARE THE WAY FORWARD FOLKS! Use and Abuse 'em!! Jim PS I'll do some benchmarks on this soon for those who're interested.. -- ----------------------------------------- James Shaughnessy james@manc.u-net.com http://www.netyaroze-europe.com/~shaughnj -----------------------------------------