Thank you for the explanation.  For now I can live without the windows API 
calls,  It does work to manually switch back and forth to the text console 
window, and I'm really the only one who does that as I sometimes perform some 
diagnostic functions in there.  The performance gains are worth it.   

Is there a way to just turn off the windows title bar when the window is 
created, or change the initial name of the window?

I'll just stick with my BGI fonts for now, if I want to move into true type 
fonts I'll look into doing something as  you suggest with the buffer.

I did figure out what my 217 error was,  it just happened to be the only time I 
right justified something, but it was actually in a unit where I neglected to 
change graph to ptcgraph, and that caused the error.

Thanks again for the help, this is a great quick fix and huge performance gain.

James

-----Original Message-----
From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of 
Nikolay Nikolov
Sent: Monday, May 15, 2017 8:46 PM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] FPC Graphics options?



On 05/16/2017 01:37 AM, James Richters wrote:
> I have managed to get ptcgraph and ptccrt to work with my program and I can 
> report that there is an AMAZING increase in graphics performance!   It is 
> pretty much a drop in replacement and I did not change any compiler settings. 
>  I did have to make a few minor changes to get it to work, not enough to 
> change the speed of anything.
>
> I am getting an error 217 access violation when I try to use outtextXY after 
> a  SetTextJustify(2,2);  (Top, Right justify)  but with the graph unit my 
> text was in the correct place and not off the screen.
Can you send me a small program that demonstrates the problem, so I can try to 
reproduce it and fix it?
>
> I also no longer have the 'graphwindow' handle variable so I had to 
> comment out anything that was using it like
>
> SetWindowTextA(graphicwindow,graphwindowtext);
> And
> ShowWindow(graphwindow, SW_SHOW);
> So I just commented them out for now.    I'm hoping there is a way to get 
> around the graphwindow variable because I was using the above 2 functions and 
> I don't know how else to determine the graphic window handle... but the 
> performance gain and ease of implementation will make working out any other 
> issues worth the effort.  Any advice on how I can capture the graph window 
> handle would be appreciated
Unfortunately, you can't do that and it's actually the main reason why ptcgraph 
is fast. Even if you modify the ptcgraph source, so that you get the window 
handle, it would do you no good, because the window is created in a different 
thread and this means that you cannot draw to the window from your program's 
thread. In fact, all the ptcgraph drawing routines actually render to an 
internal software buffer and issue no winapi drawing calls at all. That's the 
reason ptcgraph is fast and the regular graph unit is slow - the winapi drawing 
routines are really the bottleneck in this case and not the speed of the code, 
generated by FPC.

I know this is not ideal, but probably the easiest option is to find a suitable 
bgi .chr font pack or try a ttf to .chr conversion tool. If you own a copy of 
Turbo Pascal (or Turbo C/C++), you can use the .chr fonts that came with it. 
Unfortunately, other solutions are hard - they involve e.g. linking the 
freetype library, using it to render to a software buffer, and then blitting 
this buffer to the ptcgraph canvas with PutImage. Or doing a similar thing with 
winapi functions, but by drawing the text on a DIB (device independent bitmap, 
basically a memory buffer, holding an image) that you created, instead of on 
the window directly, then reading from the DIB and blitting it with PutImage 
once again.

Best regards,
Nikolay
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to