Frank Heckenbach wrote:
Rick Engebretson wrote:
Here is a draft of a draw routine. It is intended to set up linked lists for draw primitives such as circles and squares. While not a working draft, it compiles and runs the little test. And the logic is readable in Pascal.
I don't know what your design goals are, but allocating a linked list node for each pixel is a bit of overhead. It may be fine for some applications, but maximum speed probably isn't one of them. (At least it's an interesting contrast to the numerous postings in c.l.p.b -- at least some years ago when I read it -- with hand-written assembler putpixel routines ;-).
TYPE pPixel = ^TPixel; TPixel = Record x, y, color : longint; end; { TPixel }
pListElement = ^PixelListElement; { The List Handle } PixelListElement = Record ListIndex : longint; Pixel : TPixel; NextPixel : pListElement; end;
BTW, why LongInt? This it 64 bit on most targets. For the coordinates surely 32 or even 16 bit are sufficient, i.e. plain `Integer' should do. For the colors you may need 32 bits, so `Integer' may be too small on a few 16 bit platforms, but you may want to use a separate type (e.g. `TColor') as e.g. GRX does which could be declared as `Integer attribute (Size = 32)' or so.
Anyway, I suggest to avoid the overhead of extra-large integers (which can be considerable) unless really needed. Perhaps your application is entirely time-uncritical, but for graphics applications that's not always so.
Frank
Actually, the linked list is the design goal and is standard pascal and is exceedingly efficient for working with pixel sets. Check out the Bresenham C routines in SVGAlib.
The longint is certainly inappropriate and is irrelevant to the design. It just works on both GPC and FPC. Also, the color is not right for the same reason, as you say.
I've looked over tons of assembler and want pure pascal. This is only part of the rewrite of SVGA lib. The elegance of pascal is clear. My design goal is to create a stable, readable alternative to SVGAlib. The circle is actually simpler than the line using Bresenham's methods with pascal. Again, this is not a working draft and does not include the framebuffer screen array.