~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to fpcdocs/graphex/modrange.pp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Program GetModeRange_Example;
 
2
 
 
3
{ This program demonstrates how to find all available graph modes }
 
4
 
 
5
uses graph;
 
6
 
 
7
 
 
8
const
 
9
  { Currently, only 4, 8, 15 and 16 bit modes are supported
 
10
    but this may  change in the future }
 
11
  gdnames: array[D4bit..D16bit] of string[6] =
 
12
    ('4 bit','6 bit','8 bit','12 bit','15 bit','16 bit');
 
13
 
 
14
procedure WriteRes(const depth : integer);
 
15
var
 
16
        tw, th : integer;
 
17
        v, text : String;
 
18
begin
 
19
  text := 'Current resolution is '; str(getmaxx+1, v);
 
20
  text := text + v + 'x'; str(getmaxy+1, v);
 
21
  text := text + v + 'x' + gdnames[depth];
 
22
  setTextStyle(defaultFont,horizDir,1);
 
23
  TW:=TextWidth(text);
 
24
  TH:=TextHeight(text);
 
25
  outTextXY((getMaxX - TW) div 2,
 
26
            (getMaxY - TH) div 2,text);
 
27
end;
 
28
 
 
29
var
 
30
  t: text;
 
31
  line : string;
 
32
  gd, c, low, high, res: integer;
 
33
begin
 
34
  assign(t,'modes.txt');
 
35
  rewrite(t);
 
36
  close(t);
 
37
  for gd := D4bit to D16bit do
 
38
    begin
 
39
    { Get the available mode numbers for this driver }
 
40
    getModeRange(gd,low,high);
 
41
    append(t);
 
42
    write(t,gdnames[gd]);
 
43
    Writeln(t,': low modenr = ',low,', high modenr = ',high);
 
44
    close(t);
 
45
    { If high is -1,
 
46
       no resolutions are supported for this bitdepth }
 
47
    if high = -1 then
 
48
      begin
 
49
      append(t);
 
50
      writeln(t,'  No modes supported!');
 
51
      writeln(t);
 
52
      close(t);
 
53
      end
 
54
    else
 
55
      { Enter all supported resolutions for this bitdepth
 
56
        and write their characteristics to the file }
 
57
      for c := low to high do
 
58
        begin
 
59
        append(t);
 
60
        writeln(t,'  testing mode nr ',c);
 
61
        close(t);
 
62
        initgraph(gd,c,'');
 
63
        res := graphresult;
 
64
        append(t);
 
65
        { An error occurred when entering the mode? }
 
66
        if res <> grok then
 
67
          writeln(t,grapherrormsg(res))
 
68
        else
 
69
          begin
 
70
          write(t,'maxx: ',getmaxx,', maxy: ',getmaxy);
 
71
          Writeln(t,', maxcolor: ',getmaxcolor);
 
72
          closegraph;
 
73
          end;
 
74
        writeln(t);
 
75
          WriteRes(gd);
 
76
        close(t);
 
77
        end;
 
78
    append(t);
 
79
    writeln(t);
 
80
    close(t);
 
81
    end;
 
82
  Writeln('All supported modes are listed in modes.txt files');
 
83
end.