Menu

#5 SetGraphMode doesn't work on Windows OS

1.0
open
nobody
None
2022-05-14
2022-05-14
No

When I try to run the function SetGraphMode from PtcGraph, Windows makes weird things. It seems it changes the screen resolution to a lower resolution and then it changes it back to the normal resolution. The graph window disappears and the application seems to freeze.
I tested on Windows 10 and Windows 7 with the same result (using Free Pascal 3.2.2, 32 bit). It works fine on Linux and Mac OS.

Sample code:

program TestGraph;

uses PtcGraph, PtcCrt;

var GraphDriver,GraphMode:integer;
    PathToDriver:string;
    ErrorCode:integer;
begin
    GraphDriver := D8Bit;
    GraphMode := m640x480;

    InitGraph(GraphDriver, GraphMode, PathToDriver);
    ErrorCode := GraphResult;
    if ErrorCode <> GrOK then
    begin
        System.WriteLn('Halted on graphics error: ', GraphErrorMsg(ErrorCode));
        Halt(1);
    end;

    Circle(GetMaxX div 2, GetMaxY div 2, 50);

    ReadKey;

    { The following line makes Windows crazy }
    SetGraphMode(GraphMode);
    Circle(GetMaxX div 2, GetMaxY div 2, 50);

    ReadKey;
end.

Discussion


Log in to post a comment.