Recent

Author Topic: Several questions about ptcGraph  (Read 3719 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Several questions about ptcGraph
« on: October 28, 2020, 07:44:11 am »
Hello!

My first question is about the modification proposed here, in order to fix a small memory leak in ptcGraph. Who should you contact so that the modification is possibly integrated in a future version of Free Pascal?

I have another question, about the third parameter of the InitGraph procedure. As far as I know, this parameter is not used. So, why not use it to set the value of the WindowTitle variable? Like in the WinGraph unit.

Regards.

Roland
 
« Last Edit: October 28, 2020, 09:41:55 am by Roland57 »
My projects are on Gitlab and on Codeberg.

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Re: Several questions about ptcGraph
« Reply #1 on: October 28, 2020, 08:51:08 am »
I have a third question.  :)

Is safe to use the values given by the little program that I posted here?

Is it safe, for example, to do as follows:

Code: Pascal  [Select][+][-]
  1. var
  2.   grDriver, grMode: smallint;
  3.  
  4. begin
  5.   grDriver := VESA; grMode := 258;
  6.   WindowTitle := 'My title';
  7.   InitGraph(grDriver, grMode, '');

Will the value 258 have the same meaning on all systems?

Quote
        10      258    800x600       16     800 x 600 VESA
« Last Edit: October 28, 2020, 09:42:13 am by Roland57 »
My projects are on Gitlab and on Codeberg.

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Re: Several questions about ptcGraph
« Reply #2 on: October 28, 2020, 09:47:21 am »
I try to convert little examples that I had made for the WinGraph unit. I miss two things.

1° The CloseGraphRequest function. How can I know that the user clicked on the close button of the window?

2° The procedure UpdateGraph, which is used as follows:

Code: Pascal  [Select][+][-]
  1.   UpdateGraph(UpdateOff);
  2.   { Drawing operations }
  3.   UpdateGraph(UpdateOn);
  4.   { or }
  5.   UpdateGraph(UpdateNow);

Is there a way to do that with ptcGraph?
« Last Edit: October 28, 2020, 09:50:38 am by Roland57 »
My projects are on Gitlab and on Codeberg.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5815
  • Compiler Developer
Re: Several questions about ptcGraph
« Reply #3 on: October 28, 2020, 10:04:30 am »
My first question is about the modification proposed here, in order to fix a small memory leak in ptcGraph. Who should you contact so that the modification is possibly integrated in a future version of Free Pascal?

Please report on the Bug Tracker.

I have another question, about the third parameter of the InitGraph procedure. As far as I know, this parameter is not used. So, why not use it to set the value of the WindowTitle variable? Like in the WinGraph unit.

For FPC's Graph system the third parameter is the path to the BGI fonts and that is used by InitGraph. So no.

Will the value 258 have the same meaning on all systems?

As long as you use the same Graph implementation unit. They might differ between e.g. Graph and PtcGraph. In case of the Graph unit itself they might even differ between systems (cause strictly they are not the same units between systems then).

1° The CloseGraphRequest function. How can I know that the user clicked on the close button of the window?

I don't think that PTC supports such functionality.

2° The procedure UpdateGraph, which is used as follows:

What exactly does that do? What kind of updates are disabled then?

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Re: Several questions about ptcGraph
« Reply #4 on: October 28, 2020, 10:14:00 am »
@PascalDragon

Thank you for this very informative answer.

What exactly does that do? What kind of updates are disabled then?

It's for deciding when the window is repaint.

I don't think that PTC supports such functionality.

I discovered that if I do this:

Code: Pascal  [Select][+][-]
  1. uses
  2. {$IFDEF UNIX}
  3.   CThreads,
  4. {$ENDIF}
  5.   SysUtils, ptcGraph, ptcCrt;
  6.  
  7. var
  8.   d, m: smallint;
  9.  
  10. begin
  11.   d := VGA;
  12.   m := VGAHi;
  13.   WindowTitle := 'Hello';
  14.   InitGraph(d, m, '');
  15.  
  16.   repeat
  17.     Sleep(50);
  18.   until Ord(ReadKey) = 3;
  19.  
  20.   CloseGraph;
  21. end.

the user can close the window. Why 3, I don't know.
My projects are on Gitlab and on Codeberg.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5815
  • Compiler Developer
Re: Several questions about ptcGraph
« Reply #5 on: October 28, 2020, 10:44:41 am »
What exactly does that do? What kind of updates are disabled then?

It's for deciding when the window is repaint.

That's not how the Graph system works. It's geared to be as compatible as the TP Graph unit as possible. Caching draws is explicitly not part of this.

the user can close the window. Why 3, I don't know.

That is in fact the intended behaviour.

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Re: Several questions about ptcGraph
« Reply #6 on: October 28, 2020, 10:51:22 am »
All questions solved. Thank you.

I will make a report to the BugTracker (for the first point).

Regards.

Roland
My projects are on Gitlab and on Codeberg.

circular

  • Hero Member
  • *****
  • Posts: 4369
    • Personal webpage
Re: Several questions about ptcGraph
« Reply #7 on: October 28, 2020, 12:12:14 pm »
I think it is char 3 because it is the value CTRL-C (third letter). In Dos programs, pressing CTRL-C terminates the program, so it makes sense that closing the window would be like sending this key.
Conscience is the debugger of the mind

Roland57

  • Sr. Member
  • ****
  • Posts: 487
    • msegui.net
Re: Several questions about ptcGraph
« Reply #8 on: October 28, 2020, 02:50:28 pm »
I think it is char 3 because it is the value CTRL-C (third letter). In Dos programs, pressing CTRL-C terminates the program, so it makes sense that closing the window would be like sending this key.

It makes sense.

I will make a report to the BugTracker (for the first point).

Done.

My projects are on Gitlab and on Codeberg.

Brizeux

  • New Member
  • *
  • Posts: 27
  • Fond of PASCAL TP7 and UCSD
Re: Several questions about ptcGraph
« Reply #9 on: November 16, 2024, 08:17:34 am »
Dear Roland.
I use ptcgraph, ptccrt, etc... for interoperability (windows, linux, raspbian) purpose and GrDriver = VESA ; GrMode = $107 ; for instance. My programs run more than x40 faster with ptcgraph ... than with old graph unit, thanks to Nicolai Nikolov. For pixels
calculations by Monte-Carlo automata models ( 1 Atom == 1 Pixel ) I shall be interested by a mode m2560x1417x256c under
ptc. Do you know if Nicolai plan to devellop this kind of mode for 4K UHD screen. It would be great  for Pascal works !
(*** PASCAL is the best for Scientific interactive calculations, far from ADA or Fortran ***)

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Several questions about ptcGraph
« Reply #10 on: November 16, 2024, 08:32:16 am »
If I remember correctly ptcGraph allows for user defined graphic modes (installusermode) though I do not know for sure if that is the desired solution for what you ask for.
I do not have to remember anything anymore thanks to total-recall.

Brizeux

  • New Member
  • *
  • Posts: 27
  • Fond of PASCAL TP7 and UCSD
Re: Several questions about ptcGraph
« Reply #11 on: November 16, 2024, 09:34:21 am »
Thanks TRon.
In fact, I should be glad to have huge amount of graphical pixels under Ptc because I put the information on atoms only in the graphical memory by PutPixel and GetPixel, also I doesn't know if Nicolai Nikolov works on PtcGraph for 4K screen but it is not in my possibility to do that, because I am only a physicist. Friendly. Yves.
P.S. But it is essential for Free Pascal to have a good graphical Ptc interactive system alive. For some linux like utilisation, it is necessary to use very old versions of Fpc system...

TRon

  • Hero Member
  • *****
  • Posts: 3791
Re: Several questions about ptcGraph
« Reply #12 on: November 16, 2024, 10:18:07 am »
It is a user function so there is no need to bother the developer   ;D

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$mode objfpc}{$h+}
  4.  
  5. uses
  6.   {$ifdef unix} cthreads, {$endif}
  7.   ptcGraph,
  8.   ptcCrt;
  9.  
  10. var
  11.   myCustomUserGraphMode : smallint;
  12.   grDriver              : smallint;
  13.   grMode                : smallint;
  14.  
  15.  
  16. procedure setup;
  17. begin
  18.   myCustomUserGraphMode := InstallUserMode
  19.   (
  20.     1920,  // width in pixels
  21.     1080,  // height in pixels
  22.     256    // number of colors
  23.   );
  24. end;
  25.  
  26.  
  27. begin
  28.   setup;
  29.  
  30.   grDriver    := VESA;
  31.   grMode      := myCustomUserGraphMode;
  32.   WindowTitle := 'My title';
  33.   InitGraph(grDriver, grMode, '');
  34.  
  35.   SetBkColor(white);
  36.   ClearViewPort;
  37.  
  38.   SetFillStyle(SolidFill, lightgreen);
  39.   Bar(100, 100, 800, 500);
  40.  
  41.   readkey;
  42.   CloseGraph;
  43. end.
  44.  
I do not have to remember anything anymore thanks to total-recall.

Brizeux

  • New Member
  • *
  • Posts: 27
  • Fond of PASCAL TP7 and UCSD
Re: Several questions about ptcGraph
« Reply #13 on: November 16, 2024, 01:57:12 pm »
Merci beaucoup TRon, cela marche !
It is exactly what I need !
Thanks a lot . Yves .

Brizeux

  • New Member
  • *
  • Posts: 27
  • Fond of PASCAL TP7 and UCSD
Re: Several questions about ptcGraph
« Reply #14 on: November 17, 2024, 08:18:28 pm »
My opinion about PtcGraph is now accomplished : Beautiful and completely usefull for maintening FPC alive.
With the help (thak you very much) of TRon   my program is finished for this topic.
Y can use Screen memory to do all my interactive calculations at the Pixel level for
m3840x2160x256c on the 4K UHD screen.
Merci beaucoup. Yves .  :D

 

TinyPortal © 2005-2018