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>initgraph() initialize the graphics system</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 initgraph()             Initialize the Graphics System

 #include   <graphics.h>

 void       far initgraph(gdriver,gmode,dpath);
 int far    *gdriver;         /* graphics driver */
 int far    *gmode;           /* graphics mode */
 char far   *dpath;           /* directory path of driver*/

    initgraph() is a graphics system control function.  It is used to
    initialize the graphics system.  It should be the first graphics
    function called.  initgraph() loads the graphics driver, after
    allocating memory for it, then puts the system in graphics mode.
    initgraph() can be used in either of two ways: 'gdriver' must be set
    to one of the 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

    If 'gdriver' is set to DETECT (autodetection), it calls detectgraph()
    and automatically selects the highest resolution graphics mode for
    'gmode'.  To override this selection, 'gdriver' can be set to one of
    the other 10 constants in the above chart.  'gmode' can then be set
    to one of the following constants (defined in <graphics.h>):

    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    IBM8514HI      0     640x480    256 colors
               IBM8514LO      1     1024x768   256 colors

    *64K EGAMONO card
    **256K EGAMONO card

    'dpath' names the directory path where the graphic driver files are
    located.  If they are not found in 'dpath' or 'dpath' is NULL, the
    current directory is searched.

    When initgraph() is called, all graphic settings (current position,
    palette, color, etc) are reset to their defaults.  graphresult()
    (which returns graphic error code) is reset to 0.

    Returns:    Nothing. initgraph() always sets the internal error code.
                On success, graphresult() returns 0. On error,
                graphresult() (and 'gdriver') returns:

                    -2   Cannot find a graphics card
                    -3   Cannot find a driver file
                    -4   Invalid driver
                    -5   Insufficient memory to load driver

      Notes:    closegraph() should be called to shut down the graphics
                system.  A call to closegraph() restores the screen to
                the mode it was in before initgraph() was called.


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

    The following statements open and close a graphic system. 'gdriver'
    is set to the constant DETECT and therefore 'gmode' is set to the
    highest resolution available for the detected driver.

           #include <graphics.h>

           int gdriver = DETECT;
           int gmode;

           main()
           {
               initgraph(&gdriver,&gmode,"");
               .
               .
               /* graphic operations */
               .
               .
               closegraph();
           }


See Also: closegraph() getgraphmode() setgraphbufsize()

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