Previous: 4.37.2.11. CloseGraph procedure To the Table of Contents Next: 4.37.2.13. DrawEllipse procedure
4.37.2.11. CloseGraph procedure Table of Contents 4.37.2.13. DrawEllipse procedure

- 4.37.2.12. -
Table of Contents
4. Standard Units
4.37. Graph - Graph unit
4.37.2. Graph Unit Procedures and Functions
4.37.2.12. DetectSVGAMode procedure


4.37.2.12. DetectSVGAMode procedure

Targets: MS-DOS only


Graph Unit

Returns a valid VESA VBE mode number for the requested video mode. If the requested video mode is not supported, returns a zero value.

Declaration:
function DetectSVGAMode(XRes, YRes, BPP, VMode: Word): Word;
Remarks:
This function may be used with the SetGraphMode procedure. The following example tries to set the SVGA mode 640x480 with maximum color depth:
uses
  Crt, Graph;
function SetSVGA640x480: String;
const
  Bps: array [0..4] of Word = (32, 24, 16, 15, 8);
var
  Mode,i: Word;
begin
  for I := 0 to 4 do begin
    Mode:=DetectSVGAMode(640, 480, bps[i], LfbOrBanked);
    if Mode > 0 then begin
      SetGraphMode(Mode);
      if GraphResult = grOk then begin
        Str(bps[i], Result);
        exit;
      end;
    end;
  end;
  RestoreCrtMode;
  Result := '';
end;

// main program
var  S: String;
begin
  S := SetSVGA640x480;
  if S <> '' then begin
    SetTextJustify(CenterText, CenterText);
    OutTextXY(320, 240, 'This is SVGA mode 640x480 ' + S + ' bps');
    OutTextXY(320, 260, 'Press any key...');
    ReadKey;
    RestoreCrtMode;
  end else
    Writeln('SVGA mode 640x480 not supported.');
end.



Previous: 4.37.2.11. CloseGraph procedure To the Table of Contents Next: 4.37.2.13. DrawEllipse procedure
4.37.2.11. CloseGraph procedure Table of Contents 4.37.2.13. DrawEllipse procedure

- 4.37.2.12. -