User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:graphics.h:detectgraph

detectgraph

Syntax of detectgraph

#include <graphics.h>
void detectgraph(int *graphdriver, int *graphmode);

Description of detectgraph

detectgraph detects your system's graphics adapter and chooses the mode
that provides the highest resolution for that adapter. If no graphics
hardware is detected, *graphdriver is set to grNotDetected (-2), and
graphresult returns grNotDetected (-2).
*graphdriver is an integer that specifies the graphics driver to be used.
You can give it a value using a constant of the graphics_drivers
enumeration type defined in graphics.h and listed as follows:
graphics_drivers constant  Numeric value
DETECT0 (requests autodetect)
CGA   1
MCGA  2
EGA   3
EGA64 4
EGAMONO     5
IBM8514     6
HERCMONO    7
ATT4008
VGA   9
PC327010
*graphmode is an integer that specifies the initial graphics mode (unless
*graphdriver equals DETECT; in which case, *graphmode is set to the
highest resolution available for the detected driver). You can give
*graphmode a value using a constant of the graphics_modes enumeration
type defined in graphics.h and listed as follows.
Graphics        Columns   
Drivergraphics_mode  Value   x Rows   Palette  Pages
CGA   CGAC00  320 x 200  C0   1
CGAC11  320 x 200  C1   1
CGAC22  320 x 200  C2   1
CGAC33  320 x 200  C3   1
CGAHI4  640 x 200  2 color    1
 
MCGA  MCGAC0     0  320 x 200  C0   1
 
MCGAC1     1  320 x 200  C1   1
MCGAC2     2  320 x 200  C2   1
MCGAC3     3  320 x 200  C3   1
MCGAMED    4  640 x 200  2 color    1
MCGAHI     5  640 x 480  2 color    1
 
EGA   EGALO0  640 x 200  16 color   4
 
EGAHI1  640 x 350  16 color   2
 
EGA64 EGA64LO    0  640 x 200  16 color   1
 
EGA64HI    1  640 x 350  4 color    1
 
EGA-MONO    EGAMONOHI  3  640 x 350  2 color    1 w/64K
EGAMONOHI  3  640 x 350  2 color    2 w/256K
 
HERC  HERCMONOHI 0  720 x 348  2 color    2
 
ATT400ATT400C0   0  320 x 200  C0   1
ATT400C1   1  320 x 200  C1   1
ATT400C2   2  320 x 200  C2   1
ATT400C3   3  320 x 200  C3   1
ATT400MED  4  640 x 200  2 color    1
ATT400HI   5  640 x 400  2 color    1
 
VGA   VGALO0  640 x 200  16 color   2
VGAMED     1  640 x 350  16 color   2
VGAHI2  640 x 480  16 color   1
 
PC3270PC3270HI   0  720 x 350  2 color    1
IBM8514     IBM8514HI  0  640 x 480  256 color  ?
IBM8514LO  0  1024 x 768 256 color  ?
Note: The main reason to call detectgraph directly is to override the
graphics mode that detectgraph recommends to initgraph.

Example of detectgraph

/* detectgraph example */
 
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
 
/* the names of the various cards supported */
char *dname[] = { "requests detection",
"a CGA",
"an MCGA",
"an EGA",
"a 64K EGA",
"a monochrome EGA",
"an IBM 8514",
"a Hercules monochrome",
"an AT&T 6300 PC",
"a VGA",
 
"an IBM 3270 PC"
    };
 
int main(void)
{
   /* used to return detected hardware info. */
   int gdriver, gmode, errorcode;
 
   /* detect the graphics hardware available */
   detectgraph(&gdriver, &gmode);
 
   /* read result of detectgraph call */
   errorcode = graphresult();
   if (errorcode != grOk) {  /* an error occurred */
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
 
getch();
exit(1);   /* terminate with an error code */
   }
 
   /* display the information detected */
   clrscr();
   printf("You have %s video display card.\n", dname[gdriver]);
   printf("Press any key to halt:");
   getch();
   return 0;
}

See also

output of detectgraph example

  no output of example at the moment
  do not hesitate and add it...  
advertising
c/graphics.h/detectgraph.txt · Last modified: 2015/05/06 23:06 (external edit)

Impressum Datenschutz