Recent

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

Roland57

  • Full Member
  • ***
  • Posts: 110
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 »

Roland57

  • Full Member
  • ***
  • Posts: 110
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 »

Roland57

  • Full Member
  • ***
  • Posts: 110
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 »

PascalDragon

  • Hero Member
  • *****
  • Posts: 2418
  • 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

  • Full Member
  • ***
  • Posts: 110
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.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2418
  • 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

  • Full Member
  • ***
  • Posts: 110
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

circular

  • Hero Member
  • *****
  • Posts: 3569
    • 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

  • Full Member
  • ***
  • Posts: 110
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.


 

TinyPortal © 2005-2018