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

« back to all changes in this revision

Viewing changes to docs/graphex/inigraph2.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 inigraph2;
2
 
 
3
 
{ Program to demonstrate dynamic graphics mode selection }
4
 
 
5
 
uses graph;
6
 
 
7
 
const
8
 
  TheLine = 'We are now in 640 x 480 x 256 colors!'+
9
 
            ' (press <Return> to continue)';
10
 
 
11
 
var
12
 
  th,tw,gd, gm, lo, hi, error: integer;
13
 
  found: boolean;
14
 
 
15
 
begin
16
 
  { We want an 8 bit mode }
17
 
  gd := D8bit;
18
 
  { Get all available resolutions for this bitdepth }
19
 
  getmoderange(gd,lo,hi);
20
 
  { If the highest available mode number is -1,
21
 
    no resolutions are supported for this bitdepth  }
22
 
  if hi = -1 then
23
 
    begin
24
 
    writeln('no 8 bit modes supported!');
25
 
    halt
26
 
    end;
27
 
  found := false;
28
 
  { Search all resolutions for 640x480 }
29
 
  for gm := lo to hi do
30
 
    begin
31
 
    initgraph(gd,gm,'');
32
 
    { Make sure you always check graphresult! }
33
 
    error := graphResult;
34
 
    if (error = grOk) and
35
 
       (getmaxx = 639) and (getmaxy = 479) then
36
 
      begin
37
 
      found := true;
38
 
      break;
39
 
      end;
40
 
    end;
41
 
  if not found then
42
 
      CloseGraph();
43
 
    begin
44
 
    writeln('640x480x256 is not supported!');
45
 
    halt(1)
46
 
    end;
47
 
  { We are now in 640x480x256 }
48
 
  setColor(cyan);
49
 
  rectangle(0,0,getmaxx,getmaxy);
50
 
  { Write a nice message in the center of the screen }
51
 
  setTextStyle(defaultFont,horizDir,1);
52
 
  TW:=TextWidth(TheLine);
53
 
  TH:=TextHeight(TheLine);
54
 
  outTextXY((getMaxX - TW) div 2,
55
 
            (getMaxY - TH) div 2,TheLine);
56
 
  { Wait for return }
57
 
  readln;
58
 
  { Back to text mode }
59
 
  closegraph;
60
 
end.