Bgi Error: Graphics not initialized (use initgraph)

Discussion in 'Graphic cards' started by freak_pkp, Mar 17, 2005.

Thread Status:
Not open for further replies.
  1. freak_pkp

    freak_pkp New Member

    Joined:
    Mar 11, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I have made a program in c++. My program is running fine, but at the
    end of the program there is a error message on the screen:

    Bgi Error: Graphics not initialized (use initgraph)

    My program shows no error message at compile time or at run time.
    What's this bgi error? How can I correct this? I have initialized the graphics hardware by using the initgraph function on the main segment
    of my program. I am using Borland Turbo c++ compiler 3.1.
    [/b]
     
  2. theraven

    theraven New Member

    Joined:
    May 5, 2004
    Messages:
    2,912
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    off to "never ever" land
    Code:
    For some reason initgraph() failed. To find out why, check
    the return value of graphresult(). For example:
    #include 
    int main(void)
    {
        int gerr;   /* graphics error */
        int gdriver = DETECT, gmode;
        /* Initialize graphics using auto-detection and look
        for the .BGI and .CHR files in the C:\TURBOC directory.
        */
        initgraph(&gdriver, &gmode, "C:\\TURBOC");
        if ((gerr = graphresult()) != grOk)
        {
            printf("Error : %s\n", grapherrormsg(gerr));
            exit(1);
        }
        :
    }
    
    source: http://bdn.borland.com/article/0,1410,17916,00.html
     
  3. Techmastro

    Techmastro New Member

    Joined:
    Mar 13, 2005
    Messages:
    218
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Right behind you...
    bgi error usually occur when valid graphics driver are not loaded.
    using initgraph only not solve this problem, you have to give proper path for bgi graphics drivers which are usually find in bgi folder
    use this
    initgraph(&gd,&gm,"");
    where gd=GRAPHICS DRIVER
    gm=GRAPHICS MODE
    ""=path where driver reside
     
  4. knopixd

    knopixd New Member

    Joined:
    Mar 9, 2005
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    bgi error

    hey bgi means borland graphics interface.
    i think u include graphics.h without writting code for graphics mode
    here is the code:
    #include"graphics.h"
    void main()
    {
    int d=DETECT,m;
    initgraph(&d,&m,"c:\tc\bgi");//or mentioned the path of ur turbo c3
    printf("%d",d);//this will display which driver u have (u can check it in graphics.h)
    printf("%d",m);//which mode resolution
    getch();
    }
    try it in c extention.....
    bye
    njoy c man
     
Thread Status:
Not open for further replies.

Share This Page