[fpc-pascal] PTC Graph - Custom window sizes
Nikolay Nikolov
nickysn at gmail.com
Thu Nov 19 23:05:34 CET 2020
On 11/19/20 11:40 PM, James Richters wrote:
> So far it's working great! But now I have another question... Since I can now have a small little PTCGraph window... is there any possibility of having more than one in the same program? Perhaps running each window in a different thread? Or is there something fundamental that prevents this?
That would require rewriting the entire graph unit interface, which is a
legacy from Turbo Pascal and is designed with full screen graphics on a
single display in mind. In other words, it would be a new library, and
not ptcgraph anymore. The problem is, there is currently no concept for
a graphics or window context. When you call a graphics function, it
draws to the screen. If you have multiple windows, then each window is
like a separate screen, and then how can each function know which window
it should draw into? This means a major API change is required (adding
extra parameters, or redesigning the API entirely, using classes), which
would break backward compatibility. And at this point, if you need
multiple windows, you can probably switch to using the Lazarus LCL and
create a proper GUI app, since your app will need to be rewritten anyway
as a multi-window app.
Nikolay
>
> James
>
> -----Original Message-----
> From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of James Richters via fpc-pascal
> Sent: Thursday, November 19, 2020 1:49 PM
> To: 'FPC-Pascal users discussions' <fpc-pascal at lists.freepascal.org>
> Cc: James Richters <james.richters at productionautomation.net>; 'Nikolay Nikolov' <nickysn at gmail.com>
> Subject: Re: [fpc-pascal] PTC Graph - Custom window sizes
>
> Thank you very much Nikolay! I will test it and let you know the results.
>
> James
>
>
> -----Original Message-----
> From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Nikolay Nikolov via fpc-pascal
> Sent: Thursday, November 19, 2020 1:07 PM
> To: fpc-pascal at lists.freepascal.org
> Cc: Nikolay Nikolov <nickysn at gmail.com>
> Subject: Re: [fpc-pascal] PTC Graph - Custom window sizes
>
>
> On 11/19/20 7:37 PM, Nikolay Nikolov wrote:
>> On 11/19/20 3:44 PM, James Richters via fpc-pascal wrote:
>>> I've been using PTCGraph from PTCPas and so far I can only use
>>> windows sizes that there happens to be a display driver for, even if
>>> they are in a window.. so I can make a 640x480 or 1024x768 window,
>>> but if I have a screen in a vertical configuration now I can't get a
>>> 640x480 window, I can only get a 480x640 window because with the
>>> screen vertical, only vertical orientation graphics drivers are
>>> available. There are times I want a totally custom size window as
>>> well, like a 100x50. I see a lot of procedure like
>>> ptc_Init640x480x32bpp with all kinds of configurations of screen
>>> resolutions and color densities, but there is also some named
>>> ptc_InitNonStandard32k.. with other color densities.. but I don't
>>> know how to initialize PTCGraph into my own custom window size.
>>> Does anyone know how I could make my PTCGraph windows a custom weird
>>> size that doesn't necessarily match the available video drivers?
>> It's not possible with the current implementation, but right now I'm
>> working on a patch that would make this possible. I'll post here when
>> it's ready for testing.
> Implemented and committed in ptcpas and fpc trunk. The new function is called InstallUserMode:
>
> function InstallUserMode(Width, Height: SmallInt; Colors: LongInt;
> HardwarePages: SmallInt; XAspect, YAspect: Word): smallint;
>
> Example use:
>
> uses
> {$ifdef UNIX}cthreads,{$endif} ptcgraph, ptccrt; var
> gd, gm: SmallInt;
> begin
> gd := VESA;
> gm := InstallUserMode(100, 160, 16, 1, 10000, 10000);
> if gm < 0 then
> begin
> Writeln(ErrOutput, 'Error installing user mode: ', GraphErrorMsg(gm));
> Halt(1);
> end;
> InitGraph(gd, gm, '');
> OutText('Hello!');
> ReadKey;
> CloseGraph;
> end.
>
> It supports adding modes with 16, 256, 32768, 65536 and 16777216 colors with a custom X and Y resolution, custom number of hardware pages (for use with SetActivePage and SetVisualPage) and a custom pixel aspect ratio (used for drawing circles instead of ellipses on displays without square pixels - for square pixels, use "10000, 10000").
>
> Please test. :)
>
> Best regards,
>
> Nikolay
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list