Graphics not initialised..??

knoughtyd

Skilled
Me facing problems with Graphics related programs...:(
Even though I have everything properly installed,it shows the error that Graphics not initialized ..:mad:
here is a sample program DDA Line Algo...:p

Code:
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
float x,y,x1,y1,x2,y2,dx,dy,length;
int i,gd=DETECT,gm;
clrscr();

printf("Enter the value of x1,y1: ");
scanf("%f %f",&x1,&y1);
printf("Enter the value of x2,y2: ");
scanf("%f %f",&x2,&y2);

detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\tc\bgi\egavga.bgi");

dx=abs(x2-x1);
dy=abs(y2-y1);
if (dx >= dy)
{  length = dx;
	        }
else
{  length = dy;
		}
dx = (x2-x1)/length;
dy = (y2-y1)/length;
x = x1 + 0.5; 
y = y1 + 0.5; 

i = 1; 
while(i <= length)
{   putpixel(x,y,15);
    x = x + dx;
    y = y + dy;
    i++;
    delay(100);      }
getch();
closegraph();
}

I get an error saying
Code:
BGI ERROR: Graphics not initialised (use 'initgraph')
damn iam using initgraph in this but then also it shows me the same problem...:mad: :mad:
 
shouldnt

initgraph(&gd,&gm,"c:\tc\bgi\egavga.bgi");

be

initgraph(&gd,&gm,"c:\\tc\\bgi\\egavga.bgi"); ?

oh and perhaps you can initialize the graphic variables by just pointing to the folder itself.

i.e.

c:\\tc\\bgi

instead of

c:\\tc\\bgi\\egavga.bgi
 
^ thats correct.alternatively in place of "\\" this may be used : "/"

also check in options->linker->libraries and confirm that graphics is enabled.

i believe that u r also a college student like me and this teaching of graphics in turbo c 3.0 just sicks,they could have taught us opengl/directx for these algos as well.but we have to do it..
 
nfsfan said:
^ thats correct.alternatively in place of "\\" this may be used : "/"

also check in options->linker->libraries and confirm that graphics is enabled.

i believe that u r also a college student like me and this teaching of graphics in turbo c 3.0 just sicks,they could have taught us opengl/directx for these algos as well.but we have to do it..

thanks man done with it...:hap2:

used "/" instead of "\" & "\\"..:p

but i used to use "\" in college and it used to work fine wats the problem at home then...:S
 
nfsfan said:
^ thats correct.alternatively in place of "\\" this may be used : "/"

also check in options->linker->libraries and confirm that graphics is enabled.

i believe that u r also a college student like me and this teaching of graphics in turbo c 3.0 just sicks,they could have taught us opengl/directx for these algos as well.but we have to do it..

There would be no use of teaching openGL or directx for CG. Dump turbo C as soon as your course finishes and start with dev cpp if you want to program in windows.
 
hahaha, i remember the good ol turboC days in engineering. bunch of crap. As rightly mentioned, start using the gcc/g++ compilers once you're out.
 
Back
Top