[fpc-pascal] Implementing AggPas with PtcGraph

Nikolay Nikolov nickysn at gmail.com
Wed Jun 21 19:19:50 CEST 2017



On 06/21/2017 08:05 PM, James Richters wrote:
> Is there a more direct way of getting aggpas to send its output to ptcgraph?   Currently I'm doing as in the demo programs and defining an array then using putimage() to transfer the array to ptcgraph... this is fairly slow, especially for fullscreen high resolution applications.   I'm trying to follow through some of the demos included with ptcpas and it seems they do something like:
>
> { lock surface pixels }
> pixels := surface.lock;
>
> Then using a pointer defined by pixels, the program makes changes to all the pixels, then
>
> { unlock surface }
> surface.unlock;
> and
> { copy surface to console }
>   surface.copy(console, area, area);
>
> send the changes to the screen.   I'm wondering if I can have aggpas work with the ptcgraph buffer directly, and maybe this would be more efficient than putimage()
>
> Any ideas?
It's more complicated than that, because ptcgraph does all these 
operations in a separate thread. See the sources for ptcgraph and for 
the ptcwrapper unit. However, putimage can be accelerated, although it 
would still have to do a memory copy. This can be done, by implementing 
and adding a PutImage procedure in the TModeInfo record, which is filled 
in, during initialization. See the QueryAdapterInfo function in the 
ptcgraph.pp. It does a series of:

InitMode(graphmode);
with graphmode do
begin
   ...
end;

And inside the 'with' statement, various procedure variables are set. 
There, a PutImage routine can be added as well. Look at e.g. 
ptc_putpixelproc_16bpp to see how the surface is locked and how the 
actual drawing to the surface is done, inside ptcgraph.

Nikolay



More information about the fpc-pascal mailing list