[fpc-devel] sdlgraph, pre-alpha

Evgeniy Ivanov lolkaantimat at gmail.com
Wed Aug 22 20:59:56 CEST 2007


2007/8/22, Jonas Maebe <jonas.maebe at elis.ugent.be>:
>
>
> On 22 Aug 2007, at 18:24, Evgeniy Ivanov wrote:
>
> > 2007/8/22, Jonas Maebe <jonas.maebe at elis.ugent.be>:
> >>
> >>
> >> It is because you do not redirect the line drawing directly to SDL,
> >> but instead use the default line drawing routines. Those are indeed
> >> very slow, because they call a procedural variable (directputpixel)
> >> for each pixel which has to be drawn). And directputpixel then calls
> >> through to SDL, which every time must recalculate the pixel position
> >> on the screen (instead of just adding 1 to the horizontal or vertical
> >> coordinate in case of horizontal/vertical line drawing).
> >
> >  Hm... I really forgot to hook Line (but wrote the routine). But
> > HLine and
> > VLine are hooked and the speed problem is in the Bar function, it
> > has such
> > code:
> >            for y:=y1 to y2 do
> >               Hline(x1,x2,y);
> > HLine is hooked and works quickly. But it locks the screen every
> > time it is
> > executed (but calls DirectPutPixel without locking (that's why it
> > is fast):
> > procedure sdlgraph_HLine(x,x2,y: smallint);
> > var
> > temp:DefPixelProc;
> > begin
> >  temp:=DirectPutPixel;
> >  DirectPutPixel:=@nonBuf_DirectPutPixel;   // It doesn't lock the
> > screen as
> > sdlgraph_DirectPutPixel. It's quick.
>
> No, it is still slow. You indeed do not have locking overhead, but
> you are still calling nonBuf_DirectPutPixel via a procvar for each
> pixel which has to be drawn (from hlinedefault). That is still very
> slow.


Hm... I've tried  such  thing:
procedure sdlgraph_HLine(x,x2,y: smallint);
begin
 SDL_DrawLine(screen,X,y,x2,y,255);
 SDL_Flip(screen);
end;

The same. I will try to find the true way, but I'm not sure that it can be
without locking overhead. I reimplement Bar3d with adding locking - very
quick. I think it is the fastest HLine implementation

Bar3D's speed is fine if you have a fast hline implementation (like
> for e.g. go32v2 in most modes).


 It's asm, it should be faster than pascal code.




-- 
E.I.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20070822/1b65aaa5/attachment.html>


More information about the fpc-devel mailing list