Graphics.h in borland C

I am tryin to use some of the functions in graphics.h header file. i've i have included the file at the beginning of my source code. it can compile, but it doesnt link at all. it wrote " undefined function _setcolor......" sth like, is there any special steps i need to do before i can get it working?? BTW, i tried with the example function too. it still doesnt work either.... any suggestion will be helpful. thank you

Comments

  • try tocompile in dos
    >bcc file.cpp graphics.lib
  • : try tocompile in dos
    : >bcc file.cpp graphics.lib
    :
    it works now, the problem is that i have to enable the graphics linker in the option menu. the program works, but then after i run closegraph(), it wont go back to the original display setting, the screen become much smaller(letters got bigger)......i wsa trying to run CSL after the graphics, does it make any difference, any idea wat might cause this to happen??

    here is the code:

    /* request auto detection */
    int gdriver = DETECT, gmode, errorcode;
    int midx, midy, tempx, tempy;
    int stangle = 0, endangle = 360;
    int xradius = 100;
    int counter = 100;
    int music = 100;
    int cr_line = 9;

    /* initialize graphics, local variables */
    initgraph(&gdriver, &gmode, "");

    /* read result of initialization */
    errorcode = graphresult();
    if (errorcode != grOk)
    /* an error occurred */
    {
    printf("Graphics error: %s
    ", grapherrormsg(errorcode));
    printf("Press any key to halt:");
    getch();
    exit(1);
    /* terminate with an error code */
    }

    midx = getmaxx() / 2;
    midy = getmaxy() / 2;
    /* draw ellipse */
    delay(1500);
    while (counter <= 330)
    {
    setcolor(cr_line);
    sound(music);
    music +=100;
    xradius = counter;
    ellipse(midx, midy, stangle, endangle, xradius, (xradius - 90));
    if (cr_line == 14)
    cr_line = 9;
    delay (10);
    counter +=2;
    cr_line++;
    }

    nosound();
    counter = 5;
    setfillstyle(0, WHITE);
    for(int cr_ctr = 1; cr_ctr <=15; cr_ctr++)
    {
    setcolor (cr_ctr);
    sector (1, 1, 270, 360, counter, counter);
    sector ((midx *2), 1, 180, 270, counter, counter);
    sector (1, (midy *2), 0, 90, counter, counter);
    sector ((midx*2), (midy*2), 90, 180, counter, counter);
    counter +=5;
    delay(10);
    }
    /* draw ellipse */
    counter = 330;
    while ( counter >= 100)
    {
    sound(music);
    music -=100;
    xradius = counter;
    setcolor(BLACK);
    ellipse(midx, midy, stangle, endangle, xradius, (xradius - 90));
    delay (10);
    counter -=2;
    }
    nosound();
    setcolor(2);//Green
    counter = 100;
    counter = 5;
    for(int cr_ctr1 = 1; cr_ctr1 <=15; cr_ctr1++)
    {
    setcolor (cr_ctr1);
    circle(1, midy, counter);
    circle(midx, 1, counter);
    circle(midx, (midy*2), counter);
    circle((midx*2), midy, counter);
    counter +=5;
    delay(10);
    }
    counter = 100;
    while (counter <= 220)
    {
    ellipse(midx, midy, stangle, endangle,counter, counter-90);
    counter += 2;
    setcolor(cr_line);
    cr_line++;
    if(cr_line == 14)
    cr_line = 9;
    }
    setcolor(WHITE);
    ellipse(midx, midy, stangle, endangle,counter-2, counter-88);
    counter = 100;
    setcolor(GREEN);
    while (counter <= 150)
    {
    fillellipse(midx, midy, counter, counter-90);
    counter += 1;
    }
    setfillstyle(8, 9);
    floodfill(80, 80, WHITE);

    char *password;
    gotoxy(33, 13);
    setbkcolor(BLUE);
    settextstyle(GOTHIC_FONT, 0, 5);
    outtextxy(midx-50,midy-50, "SLUGnet LOGIN");

    gotoxy(25, 15);
    printf("USER NAME: ");
    gotoxy(25,16);
    printf("PASSWORD: ");
    gotoxy(36,15);
    scanf("%s",line1);
    gotoxy(25, 16);
    line3 = getpass("PASSWORD: ");

    /* clean up */
    getch();
    closegraph();

    the closegraph() should restore the original setting that initgraph() detected before it changes to graphics mode, n stored into the graphs memoery buffer, but i guess somehow it detects the wrong setting, or i restore wrong....
  • : : try tocompile in dos
    : : >bcc file.cpp graphics.lib
    : :
    : it works now, the problem is that i have to enable the graphics linker in the option menu. the program works, but then after i run closegraph(), it wont go back to the original display setting, the screen become much smaller(letters got bigger)......i wsa trying to run CSL after the graphics, does it make any difference, any idea wat might cause this to happen??
    :
    : here is the code:
    :
    : /* request auto detection */
    : int gdriver = DETECT, gmode, errorcode;
    : int midx, midy, tempx, tempy;
    : int stangle = 0, endangle = 360;
    : int xradius = 100;
    : int counter = 100;
    : int music = 100;
    : int cr_line = 9;
    :
    : /* initialize graphics, local variables */
    : initgraph(&gdriver, &gmode, "");
    :
    : /* read result of initialization */
    : errorcode = graphresult();
    : if (errorcode != grOk)
    : /* an error occurred */
    : {
    : printf("Graphics error: %s
    ", grapherrormsg(errorcode));
    : printf("Press any key to halt:");
    : getch();
    : exit(1);
    : /* terminate with an error code */
    : }
    :
    : midx = getmaxx() / 2;
    : midy = getmaxy() / 2;
    : /* draw ellipse */
    : delay(1500);
    : while (counter <= 330)
    : {
    : setcolor(cr_line);
    : sound(music);
    : music +=100;
    : xradius = counter;
    : ellipse(midx, midy, stangle, endangle, xradius, (xradius - 90));
    : if (cr_line == 14)
    : cr_line = 9;
    : delay (10);
    : counter +=2;
    : cr_line++;
    : }
    :
    : nosound();
    : counter = 5;
    : setfillstyle(0, WHITE);
    : for(int cr_ctr = 1; cr_ctr <=15; cr_ctr++)
    : {
    : setcolor (cr_ctr);
    : sector (1, 1, 270, 360, counter, counter);
    : sector ((midx *2), 1, 180, 270, counter, counter);
    : sector (1, (midy *2), 0, 90, counter, counter);
    : sector ((midx*2), (midy*2), 90, 180, counter, counter);
    : counter +=5;
    : delay(10);
    : }
    : /* draw ellipse */
    : counter = 330;
    : while ( counter >= 100)
    : {
    : sound(music);
    : music -=100;
    : xradius = counter;
    : setcolor(BLACK);
    : ellipse(midx, midy, stangle, endangle, xradius, (xradius - 90));
    : delay (10);
    : counter -=2;
    : }
    : nosound();
    : setcolor(2);//Green
    : counter = 100;
    : counter = 5;
    : for(int cr_ctr1 = 1; cr_ctr1 <=15; cr_ctr1++)
    : {
    : setcolor (cr_ctr1);
    : circle(1, midy, counter);
    : circle(midx, 1, counter);
    : circle(midx, (midy*2), counter);
    : circle((midx*2), midy, counter);
    : counter +=5;
    : delay(10);
    : }
    : counter = 100;
    : while (counter <= 220)
    : {
    : ellipse(midx, midy, stangle, endangle,counter, counter-90);
    : counter += 2;
    : setcolor(cr_line);
    : cr_line++;
    : if(cr_line == 14)
    : cr_line = 9;
    : }
    : setcolor(WHITE);
    : ellipse(midx, midy, stangle, endangle,counter-2, counter-88);
    : counter = 100;
    : setcolor(GREEN);
    : while (counter <= 150)
    : {
    : fillellipse(midx, midy, counter, counter-90);
    : counter += 1;
    : }
    : setfillstyle(8, 9);
    : floodfill(80, 80, WHITE);
    :
    : char *password;
    : gotoxy(33, 13);
    : setbkcolor(BLUE);
    : settextstyle(GOTHIC_FONT, 0, 5);
    : outtextxy(midx-50,midy-50, "SLUGnet LOGIN");
    :
    : gotoxy(25, 15);
    : printf("USER NAME: ");
    : gotoxy(25,16);
    : printf("PASSWORD: ");
    : gotoxy(36,15);
    : scanf("%s",line1);
    : gotoxy(25, 16);
    : line3 = getpass("PASSWORD: ");
    :
    : /* clean up */
    : getch();
    : closegraph();
    :
    : the closegraph() should restore the original setting that initgraph() detected before it changes to graphics mode, n stored into the graphs memoery buffer, but i guess somehow it detects the wrong setting, or i restore wrong....
    :
    [blue]
    Did you know you can include the BGI and CHR files in your program?
    If you're interrested I'll show you.
    [/blue]

    [code][blue][size=5]AddyK[/size] (addyk2004), E-mail: addyk2003@walla.com (I know it should be 2004)[/blue][/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories