graphmodes 
Author Message
 graphmodes

I am new with programming graphics using Pascal and I have a question:
I use this standard code to get into graphical mode [ it's a snip from a
litle program i wrote, but this source i copied ] :

grDriver := Detect;
InitGraph(grDriver, grMode,'c:\tpc7\bgi');
ErrCode := GraphResult;
if ErrCode = grOk then
     begin  { Do graphics }
      circle(x,y,r,c);
     Readln;
     CloseGraph;
end
  else
    Writeln('Graphics error:', GraphErrorMsg(ErrCode));
end.

can anyone PLEASE comment this code for me, so i can see what does what !?
and question #2 .. i placed writeln(grMode); in my source and the result is
2, what does that means?

Derk Eim

The Netherlands



Wed, 18 Jun 1902 08:00:00 GMT  
 graphmodes

Quote:

> I am new with programming graphics using pascal and I have a question:
> I use this standard code to get into graphical mode [ it's a snip from a
> litle program i wrote, but this source i copied ] :

> grDriver := Detect;
> InitGraph(grDriver, grMode,'c:\tpc7\bgi');
> ErrCode := GraphResult;
> if ErrCode = grOk then
>      begin  { Do graphics }
>       circle(x,y,r,c);
>      Readln;
>      CloseGraph;
> end
>   else
>     Writeln('Graphics error:', GraphErrorMsg(ErrCode));
> end.

> can anyone PLEASE comment this code for me, so i can see what does what !?
> and question #2 .. i placed writeln(grMode); in my source and the result is
> 2, what does that means?

> Derk Eim

> The Netherlands

If it works it works 8)
Looks good to me. The value of grmode is the result of hardware-detection. This
is the optimal mode for your system. It'll nearly always be grmode 2 and
grdriver 9 these days, but this was more important in situations where people
would for instance use CGA-monitors and cards.
I have frequently committed to the sin of not detecting but just forcing the
program to this mode (also mode12h, 640x480 in 16 cols), luckily with no fatal
consequences.
If you want a little more on bgi-graphics programming I invite you to have a
look at my webpage: http://www.xs4all.nl/~remcodek/program.html.

Have fun!

Ajeto!

Remco

Pays Bas



Wed, 18 Jun 1902 08:00:00 GMT  
 graphmodes
OK, the commented parts are below:

Quote:
> I am new with programming graphics using pascal and I have a question:
> I use this standard code to get into graphical mode [ it's a snip from a
> litle program i wrote, but this source i copied ] :

> grDriver := Detect; {Basically tells the program to try and autodetect the
> graphics driver needed}
> InitGraph(grDriver, grMode,'c:\tpc7\bgi'); {Initialise a graphics mode, based
> on the driver found (grDriver) and the mode wanted (grMode)}
> ErrCode := GraphResult; {Now the result of the above operation is put into
> GraphResult ... the operation is ONLY SUCCESSFUL if GraphResult==0}
> if ErrCode = grOk then {grOK == 0, IIRC.  So this means, IF everything goes
> well THEN}
>      begin  { Do graphics }
>       circle(x,y,r,c);
>      Readln;
>      CloseGraph; {Stops the graphics mode, dumps you back to text}
> end
>   else
>     Writeln('Graphics error:', GraphErrorMsg(ErrCode)); {GraphErrorMsg just
> returns a verbose interpretation of Errcode}
> end.

There, that should answer Question 1.

Quote:
> can anyone PLEASE comment this code for me, so i can see what does what !?
> and question #2 .. i placed writeln(grMode); in my source and the result is
> 2, what does that means?

grMode is the graphics mode you are in.  "2" is the number that Pascal has
assigned to this graphics mode.  To find out what resolution "2" means, try

var1:=GetMaxX;
var2:=GetMaxY;
CloseGraph;
Writeln('X resolution = ',var1,' and Y resolution = ',var2);

which should give you that info.  To see how many colors you have at your
disposal in this mode, try something like

FOR I:=0 TO GetMaxX DO
    PutPixel(i,100,i);

and you should be able to see if you are in a 16 color, 256 color, 65536 color,
etc, mode.

-=Yusuf=-



Wed, 18 Jun 1902 08:00:00 GMT  
 graphmodes



Quote:
>...
> If it works it works 8)
> Looks good to me. The value of grmode is the result of hardware-detection.
This
> is the optimal mode for your system. It'll nearly always be grmode 2 and
> grdriver 9 these days, but this was more important in situations where
people
> would for instance use CGA-monitors and cards.

How does that work? If someone brings out a BGI driver for hardware that did
not exist when BP7 was written, will the hardware detection recognise it as
optimal or will it only try to detect the cards that existed back then? Does
it load all available BGI drivers to see if they are optimal?

Just curious

FP



Wed, 18 Jun 1902 08:00:00 GMT  
 graphmodes

Quote:



> >...
> > If it works it works 8)
> > Looks good to me. The value of grmode is the result of hardware-detection.
> This
> > is the optimal mode for your system. It'll nearly always be grmode 2 and
> > grdriver 9 these days, but this was more important in situations where
> people
> > would for instance use CGA-monitors and cards.

> How does that work? If someone brings out a BGI driver for hardware that did
> not exist when BP7 was written, will the hardware detection recognise it as
> optimal or will it only try to detect the cards that existed back then? Does
> it load all available BGI drivers to see if they are optimal?

> Just curious

> FP

I have no idea how that works and I'm not really interested.
I'm sure there are enough bit-knights here that will love to explain this to you
in detail.

Greetings,

Remco



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. other graphmodes than 13h?

 

 
Powered by phpBB® Forum Software