Graphics Error

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Graphics Error

Postby prashant45 » Tue Dec 02, 2008 9:55 am

#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<graphics.h>
#include<dos.h>
#include<time.h>
#include<STDLIB.H> // FOR EXIT
#define ESC 0x1b /* Define the escape key */

void graph()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(2,0,2);

}

void Pause(void)
{

int c;

c = getch(); /* Read a character from kbd */

if( ESC == c ){ /* Does user wish to leave? */

exit( 1 ); /* Return to OS */
}

if( 0 == c ){ /* Did use hit a non-ASCII key? */
c = getch(); /* Read scan code for keyboard */
}
}

void main()
{
graph();
clrscr();
textbackground(0); // set's backgroundcolor to black
textcolor(GREEN); // set's fontcolor
time_t t; // glabally declared in time.h header file
time(&t);
cout<<"\t\t\t\t\t\t\t"<<ctime(&t); // prints the surrent date and time

//settextstyle(1,HORIZ_DIR,2);

//DEFAULT font
//TRIPLEX font
//SMALL font
//SANS SERIF font
//GOTHIC font


//CLASS 10
// PHYSICS

//LIGHT

ofstream ob1("10phlight");
ob1<<"\n \t\t Light Reflection and Refraction \n\n";
ob1<<" Light seems to travel in straight lines.";
ob1<<" Mirrors and lenses form images of objects, Images can be either real or virtual depending on the position of the object.";
ob1<<" The reflecting surfaces obey laws of reflection. Refracting surfaces obey laws of refraction.";
ob1<<" Mirror formula (1/u + 1/v = 1/f) gives the relationship between object distance (u), image distance (v) and focal length (f) of a spherical mirror.";
ob1<<" The focal length of a spherical mirror is equal to half is radius of curvature.";
ob1<<" The magnification produced by a spherical mirror is the ratio of the height of the image to the height of the object.";
ob1<<" Refractive index of a transparent medium is the ratio of the speed of light in vacuum to that in the medium.";
ob1<<" Power of a lens is the reciprocal of its focal length. SI unit of the power of a lens is Dioptre.";
ob1.close();

ifstream ob2("10phlight");
cout<<"\n\t\t \t LIGHT REFLECTION AND REFRACTION \n\n";
cout<<"\n 1.Light seems to travel in straight lines.\n";
cout<<"\n 2.Mirrors and lenses form images of objects, Images can be either\n real or virtual depending on the position of the object.\n";
cout<<"\n 3.The reflecting surfaces obey laws of reflection. Refracting surfaces\n obey laws of refraction.\n";
cout<<"\n 4.Mirror formula (1/u + 1/v = 1/f) gives the relationship between\n object distance (u), image distance (v) and focal length (f) of\n a spherical mirror.\n";
cout<<"\n 5.The focal length of a spherical mirror is equal to half is radius\n of curvature.\n";
cout<<"\n 6.The magnification produced by a spherical mirror is the ratio of\n the height of the image to the height of the object.\n";
cout<<"\n 7.Refractive index of a transparent medium is the ratio of the speed\n of light in vacuum to that in the medium.\n";
cout<<"\n 8.Power of a lens is the reciprocal of its focal length. SI unit of\n the power of a lens is Dioptre.\n\n\n";
ob2.close();
Pause();
clrscr();
// HUMAN - EYE
ofstream ob3("10pheye");
ob3<<"\n \t\t THE HUMAN-EYE AND THE COLOURFUL WORLD \n\n";
ob3<<"The ability of the eye to focus both near and distant objects, by adjusting its focal length, is called accommodation of the eye.";
ob3<<"The smallest distance, at which the eye can see objects clearly without strain, is called the near point of the eye or least distinct vision. For a young adult with normal vision, it’s about 25 cm.";
ob3<<"The splitting of white light into its component colors is called dispersion.";
ob3<<"Scattering of light causes the blue color of the sky and the reddening of the sun at sunrise and sunset.";
ob3.close();

ifstream ob4("10pheye");
cout<<"\t\t\t\t\t\t\t"<<ctime(&t); // prints the surrent date and time
cout<<"\n \t\t THE HUMAN-EYE AND THE COLOURFUL WORLD \n\n";
cout<<"\n1.The ability of the eye to focus both near and distant objects,\n by adjusting its focal length, is called accommodation of the\n eye.\n";
cout<<"\n2.The smallest distance, at which the eye can see objects clearly\n without strain, is called the near point of the eye or least\n distinct vision. For a young adult with normal vision, its about\n 25 cm.\n";
cout<<"\n3.The splitting of white light into its component colors is called\n dispersion.\n";
cout<<"\n4.Scattering of light causes the blue color of the sky and the\n reddening of the sun at sunrise and sunset.\n\n\n";
ob4.close();
Pause(); clrscr();

getch();
}




Following are the error when I tried to compile the program :

    Undefined Symbol settextstyle(int,int,int) in module
    undefined Symbol initgraph(int far*,int far*, char far*) in module
Last edited by prashant45 on Wed Dec 24, 2008 4:39 am, edited 1 time in total.
prashant45
 
Posts: 3
Joined: Tue Dec 02, 2008 9:42 am

Postby ventsyv » Tue Dec 02, 2008 12:54 pm

That means those functions were not declared before used. You are most likely missing a header file.


You need to have forward declarations before you can use a function:
Code: Select all
void myFunction(int num);//forward declaration
//if forward declaration is made in header file, you need to include it.
int main()
{
myFunction(5);//from the forward declaration the computer knows such function exists somewhere.
}

void myFunction(int num)//could be in another .cpp file, in that case you have to use a header file.
{
   //do something
}
User avatar
ventsyv
 
Posts: 2828
Joined: Mon Sep 22, 2003 5:25 pm
Location: MD USA

Postby prashant45 » Thu Dec 04, 2008 8:30 pm

i did not understand what should i do can you please explain me in detail
prashant45
 
Posts: 3
Joined: Tue Dec 02, 2008 9:42 am


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 3 guests