Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>detectgraph() select graphics driver and mode</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 detectgraph()           Select Graphics Driver and Mode

 #include   <graphics.h>

 void far   detectgraph(gdriver,gmode);
 int far    *gdriver;                        /* graphics driver */
 int far    *gmode;                          /* graphics mode */

    detectgraph() is a graphics system control function which checks the
    system hardware then selects a graphics driver and mode.
    detectgraph() works in two different ways: if initgraph() is called
    with 'gdriver' set to DETECT, initgraph() calls detectgraph() to
    select a graphics driver and mode.  detectgraph() can also be called
    directly to determine the graphics driver and mode.  On successful
    return, 'gdriver' can be set to one of the following constants:

               CONSTANT            NUMERIC VALUE

               DETECT                         0
               CGA                            1
               MCGA                           2
               EGA                            3
               EGA64                          4
               EGAMONO                        5
               IBM8514                        6
               HERCMONO                       7
               ATT400                         8
               VGA                            9
               PC3270                        10


    And 'gmode' will then be set to a value represented by one of the
    'graphics_modes' constants:

    GRAPHICS
    DRIVER   GRAPHICS_MODES  VALUE   RES      PALETTE   PAGES

    CGA        CGAC0          0     320x200    C0          1
               CGAC1          1     320x200    C1          1
               CGAC2          2     320x200    C2          1
               CGAC3          3     320x200    C3          1
               CGAHI          4     640x200    2 color     1

    MCGA       MCGAC0         0     320x200    C0          1
               MCGAC1         1     320x200    C1          1
               MCGAC2         2     320x200    C2          1
               MCGAC3         3     320x200    C3          1
               MCGAMED        4     640x200    2 color     1
               MCGAHI         5     640x480    2 color     1

    EGA        EGALO          0     640x200    16 color    4
               EGAHI          1     640x350    16 color    2

    EGA64      EGA64LO        0     640x200    16 color    1
               EGA64HI        1     640x350    4 color     1

    EGAMONO    EGAMONOHI      3     640x350    2 color     1*
               EGAMONOHI      3     640x350    2 color     4**

    HERCMONO   HERCMONOHI     0     720x348    2 color     2

    ATT400     ATT400C0       0     320x200    C0          1
               ATT400C1       1     320x200    C1          1
               ATT400C2       2     320x200    C2          1
               ATT400C3       3     320x200    C3          1
               ATT400MED      4     640x200    2 color     1
               ATT400HI       5     640x400    2 color     1

    VGA        VGALO          0     640x200    16 color    4
               VGAMED         1     640x350    16 color    2
               VGAHI          2     640x480    16 color    1

    PC3270     PC3270HI       0     720x350     2 color     1

    IBM8514    IBM8514LO      0     640x480    256 color
               IBM8514Hi      1     1024x768   256 color

    *64K EGAMONO card
    **256K EGAMONO card

    Returns:    Nothing.  If a graphics driver is not detected, 'gdriver'
                is set to -2 ("cannot detect a graphics card").

   -------------------------------- Example ---------------------------------

    The following statements detect the system's graphic adapter and
    override the graphic mode setting if needed.


           #include <graphics.h>       /* for graphics functions */
           #include <stdio.h>           /* for printf */
           #include <conio.h>          /* for getch */

           int gdriver, gmode;

           main()
           {
               detectgraph(&gdriver,&gmode);
               printf("detected graphics driver: %d,
                       graphics mode %d\n",gdriver,gmode);
               getch();
               if (gmode == EGAHI)
                   gmode = EGALO;
               initgraph(&gdriver,&gmode,"");
               /* graphic operations */
               closegraph();
           }


See Also: initgraph()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson