problem with light

hi guys, I have some codes which is written for a robot, it has some advance features include light.my codes had 2 parts: 1:dynamic and kinematic equations 2: graphical code to have vision part. after completing 2 part I linked these 2 parts(while they arnt overlapping), before linking there was my light and just after adding there was no light. i dont know why. i wanted to attach my codes, but it was to much. so if any body can help first I appreciate so much and then plz let me know, to mail my codes to him/her, since i think without codes its a bit difficult to get my point. I sincerely again appreciate if anybody knows the solution and help me.

regards

you only need to post bits of the code - the part where lighting is setup/initialised and the drawing function.

oh, and use {code} {/code} to encapsulate your code to make it readable on these forums.
Replace {} with [] brackets when you actually post.

oh, this the lighting part:

{
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<glut.h>
#include"vector.cpp"

using namespace std;

class Light
{
private:
int lightNo;
SF3dVector position; //an object from SF3dVector
SF3dVector direction; //an object from SF3dVector

float diffuse[4];
float ambient[4];
float specular[4];
float cutoff;
float exponent;
float temp[4];
bool visible;
float RotatedX, RotatedY;
SF3dVector RightVector; //an object from SF3dVector
SF3dVector UpVector;    //an object from SF3dVector

void check()
{
	for(int i=0;i&lt;4;i++)
	[
		//if(diffuse[i]&lt;0) //colored light
		//	diffuse[i]=0;
		//if(diffuse[i]&gt;1)
			diffuse[i]=1;

		//if(ambient[i]&lt;0) //light in arbitary direction
		//	ambient[i]=0;
		//if(ambient[i]&gt;1)
			ambient[i]=1;

		//if(specular[i]&lt;0) //A specular light is a light that sets highlights and often the shininess of an object
		//	specular[i]=0;
		//if(specular[i]&gt;1)
			specular[i]=1;
	]
	if(exponent&gt;1)
		exponent=1;
	if(exponent&lt;0)      ////ina chian bara chian?////
		exponent=0;
	if(cutoff&lt;0)
		cutoff=0;
	if(cutoff&gt;90 && cutoff!=180)
		cutoff=90;
}

public:
Light(int number) //number as a intiger input for loght function
{
this->lightNo=number;
this->temp[3]=1; //3 dimension array with 1 value
this->visible=false;
this->position=SF3dVector(); //position is same as SF3dVector() constructor in SF3dVector class
this->direction=SF3dVector(0,0,-1); //direction is same as SF3dVector(floatx, float y, float z) constructor in SF3dVector class

	RightVector = SF3dVector (1.0, 0.0, 0.0);
	UpVector = SF3dVector (0.0, 1.0, 0.0);
	RotatedX = RotatedY = 0.0;
}

void init()   //intialaizing each part: ambient, diffuse, specular, attenuation, cutoff, exp
{
	this-&gt;OnOff();
	this-&gt;setAmbient(1.0,1.0,1.0,1);
	this-&gt;setDifuse(1,1,0,1);
	this-&gt;setSpecular(1,1,1,0);
	this-&gt;setAttenuation(2,0,0);
	this-&gt;setCutoff(30);
	this-&gt;setExp(4);
}

void render()
{
	check();
	this-&gt;temp[0]= position.getx(); //declare the 'x' component of position
	this-&gt;temp[1]= position.gety(); //declare the 'y' component of position
	this-&gt;temp[2]= position.getz(); //declare the 'z' component of position
	glLightfv(this-&gt;lightNo,GL_POSITION,this-&gt;temp);//glLight — set light source parameters
	this-&gt;temp[0]= direction.getx();//declare the 'x' component of direction
	this-&gt;temp[1]= direction.gety();//declare the 'y' component of direction
	this-&gt;temp[2]= direction.getz();//declare the 'z' component of direction
	glLightfv(this-&gt;lightNo,GL_SPOT_DIRECTION,this-&gt;temp);//glLight — set light source parameters
}

void setDifuse(float r,float g,float b, float a) //function for setting the diffusion
{
	this-&gt;diffuse[0]=r;  //load the first of four array to red
	this-&gt;diffuse[1]=g;  //load the first of four array to green
	this-&gt;diffuse[2]=b; //load the first of four array to blue	
	this-&gt;diffuse[3]=a; //load the first of four array to
	glLightfv(this-&gt;lightNo,GL_DIFFUSE,this-&gt;diffuse);//glLight — set light source parameters
}

void incDifuse(const int &i,const float &d) //function for increasing the diffusion
{
	this-&gt;diffuse[i]+=d;  //increase the diffusion by 'd' step
	glLightfv(this-&gt;lightNo,GL_DIFFUSE,this-&gt;diffuse);//glLight — set light source parameters
}

void setAmbient(float r,float g,float b, float a) //function for setting the ambient
{
	this-&gt;ambient[0]=r;  //load the first of four array to red
	this-&gt;ambient[1]=g;  //load the first of four array to green
	this-&gt;ambient[2]=b; //load the first of four array to blue	
	this-&gt;ambient[3]=a;
	glLightfv(this-&gt;lightNo,GL_AMBIENT,this-&gt;ambient); //glLight — set light source parameters
}

void incAmb(const int &i,const float &d)  //function for increasing the diffusion
{
	this-&gt;ambient[i]+=d;  //increase the diffusion by 'd' step
	glLightfv(this-&gt;lightNo,GL_AMBIENT,this-&gt;ambient); //glLight — set light source parameters
}

void setSpecular(float r,float g,float b, float a) //function for setting the ambient
{
	this-&gt;specular[0]=r;   //load the first of four array to red
	this-&gt;specular[1]=g;   //load the first of four array to green
	this-&gt;specular[2]=b;  //load the first of four array to blue	
	this-&gt;specular[3]=a;
	glLightfv(this-&gt;lightNo,GL_SPECULAR,this-&gt;specular); //glLight — set light source parameters
}

void incSpec(const int &i,const float &d) //function for increasing the diffusion
{
	this-&gt;diffuse[i]+=d;   //increase the diffusion by 'd' step
	glLightfv(this-&gt;lightNo,GL_SPECULAR,this-&gt;specular);   //glLight — set light source parameters
}

void Move ( SF3dVector Direction )  //moving the light
{
	this-&gt;position = this-&gt;position + Direction;
	this-&gt;temp[0]=this-&gt;position.getx(); //declare the 'x' component of position after moving
	this-&gt;temp[1]=this-&gt;position.gety(); //declare the 'y' component of position after moving
	this-&gt;temp[2]=this-&gt;position.getz(); //declare the 'z' component of position after moving
	glLightfv(this-&gt;lightNo,GL_POSITION,this-&gt;temp);
}

void setPosition(float x,float y,float z) //intializing position afetr moving
{
	this-&gt;position=SF3dVector(x,y,z);
	this-&gt;temp[0]=x;
	this-&gt;temp[1]=y;
	this-&gt;temp[2]=z;
	glLightfv(this-&gt;lightNo,GL_POSITION,this-&gt;temp);
}

void setCutoff(float a)  //spotlight cutoff angle
{
	this-&gt;cutoff=a;
	glLightf(this-&gt;lightNo,GL_SPOT_CUTOFF,this-&gt;cutoff);
}

void incCutoff(float v)
{
	this-&gt;cutoff+=v;
	glLightf(this-&gt;lightNo,GL_SPOT_CUTOFF,this-&gt;cutoff);
}

void setExp(float exp) //control how concentrated the light is
{
	this-&gt;exponent=exp;
	glLightf(this-&gt;lightNo,GL_SPOT_EXPONENT,this-&gt;exponent);
}

void incExp(float exp)
{
	this-&gt;exponent+=exp;
	glLightf(this-&gt;lightNo,GL_SPOT_EXPONENT,this-&gt;exponent);
}

void setAttenuation(float constant, float linear, float quadratic)
{
	glLightf(this-&gt;lightNo, GL_CONSTANT_ATTENUATION, constant);
	glLightf(this-&gt;lightNo, GL_LINEAR_ATTENUATION, linear);
	glLightf(this-&gt;lightNo, GL_QUADRATIC_ATTENUATION, quadratic);
}

void setDirection(float x,float y,float z)
{
	this-&gt;direction=SF3dVector(x,y,z);
	this-&gt;temp[0]=x;
	this-&gt;temp[1]=y;
	this-&gt;temp[2]=z;
	glLightfv(this-&gt;lightNo,GL_SPOT_DIRECTION,this-&gt;temp);
}

void setDirection(SF3dVector dir)
{
	this-&gt;direction=dir;
	this-&gt;temp[0]=dir.getx();
	this-&gt;temp[1]=dir.gety();
	this-&gt;temp[2]=dir.getz();
	glLightfv(this-&gt;lightNo,GL_SPOT_DIRECTION,this-&gt;temp);
}

void setRight(const float &x,const float &y,const float &z)
{
	this-&gt;RightVector=SF3dVector(x,y,z);
}

void setUpvector(const float &x,const float &y,const float &z)
{
	this-&gt;UpVector=SF3dVector(x,y,z);
}

void RotateX ( float Angle )
{
	RotatedX += Angle;
	setDirection((direction*cos(Angle*PIdiv180)+ UpVector*sin(Angle*PIdiv180)).Normalize());
	UpVector = direction.CrossProduct(RightVector)*-1;
}

void setRotate(const float &x,const float &y)
{
	this-&gt;RotatedX=x;
	this-&gt;RotatedY=y;
}

void RotateY (GLfloat Angle)
{
	RotatedY += Angle;
	setDirection((direction*cos(Angle*PIdiv180)- RightVector*sin(Angle*PIdiv180)).Normalize());
	RightVector = direction.CrossProduct(UpVector);
}

void MoveForward( GLfloat Distance )
{
	this-&gt;position = this-&gt;position + (this-&gt;direction*-Distance);
}

void StrafeRight ( GLfloat Distance )
{
	this-&gt;position = this-&gt;position + (RightVector*Distance);
}

void MoveUpward( GLfloat Distance )
{
	this-&gt;position = this-&gt;position + (UpVector*Distance);
}

string toString()
{
	stringstream str;
	str&lt;&lt; "LightNo.Is: "&lt;&lt; this-&gt;lightNo-GL_LIGHT0&lt;&lt; endl;
	str&lt;&lt; "Visible: "&lt;&lt; this-&gt;visible&lt;&lt; endl;
	str&lt;&lt; "Pos: "&lt;&lt; this-&gt;position.getx()&lt;&lt; " "&lt;&lt; this-&gt;position.gety()&lt;&lt; " "&lt;&lt; this-&gt;position.getz()&lt;&lt;endl;
	str&lt;&lt; "Dir: "&lt;&lt; this-&gt;direction.getx()&lt;&lt; " "&lt;&lt; this-&gt;direction.gety()&lt;&lt; " "&lt;&lt; this-&gt;direction.getz()&lt;&lt;endl;
	str&lt;&lt; "Up: "&lt;&lt; UpVector.getx()&lt;&lt; " "&lt;&lt; UpVector.gety()&lt;&lt; " "&lt;&lt; UpVector.getz()&lt;&lt;endl;
	str&lt;&lt; "Right: "&lt;&lt; RightVector.getx()&lt;&lt; " "&lt;&lt; RightVector.gety()&lt;&lt; " "&lt;&lt; RightVector.getz()&lt;&lt;endl;
	str&lt;&lt; "Rotate: "&lt;&lt; RotatedX&lt;&lt; " "&lt;&lt; RotatedY&lt;&lt; endl;
	str&lt;&lt; "Ambient: "&lt;&lt; this-&gt;ambient[0]&lt;&lt; " "&lt;&lt; this-&gt;ambient[1]&lt;&lt; " "&lt;&lt; this-&gt;ambient[2]&lt;&lt; " "&lt;&lt; this-&gt;ambient[3]&lt;&lt; endl;
	str&lt;&lt; "Difuse: "&lt;&lt; this-&gt;diffuse[0]&lt;&lt; " "&lt;&lt; this-&gt;diffuse[1]&lt;&lt; " "&lt;&lt; this-&gt;diffuse[2]&lt;&lt; " "&lt;&lt; this-&gt;diffuse[3]&lt;&lt; endl;
	str&lt;&lt; "Speclar: "&lt;&lt; this-&gt;specular[0]&lt;&lt; " "&lt;&lt; this-&gt;specular[1]&lt;&lt; " "&lt;&lt; this-&gt;specular[2]&lt;&lt; " "&lt;&lt; this-&gt;specular[3]&lt;&lt; endl;
	str&lt;&lt; "Exponent: "&lt;&lt; this-&gt;exponent&lt;&lt; endl&lt;&lt; "Cutoff: "&lt;&lt; this-&gt;cutoff&lt;&lt; endl;
	return str.str();
}

void OnOff()
{
	visible=!visible;
	if(this-&gt;visible)
		glEnable(this-&gt;lightNo);
	else
		glDisable(this-&gt;lightNo);
}

void FinInfin()
{
	temp[3]=!temp[3];
}

void DrawDirection() //draw the direction of the exsist light
{
	if(!this-&gt;visible)
		return;
	SF3dVector t;
	t=position-direction;
	glPushMatrix();
	glColor3f(1,1,1);
	glTranslatef(t.getx(),t.gety(),t.getz());
	glutSolidSphere(.1,25,25);
	glScalef(2,2,2);
	glBegin(GL_LINES);
	glColor3f(1,0,0);
	glVertex3fv(SF3dVector().getV());
	glVertex3fv(this-&gt;direction.getV());
	glColor3f(0,1,0);
	glVertex3fv(SF3dVector().getV());
	glVertex3fv(this-&gt;RightVector.getV());
	glColor3f(0,0,1);
	glVertex3fv(SF3dVector().getV());
	glVertex3fv(this-&gt;UpVector.getV());
	glEnd();
	t=this-&gt;direction;
	glTranslatef(t.getx(),t.gety(),t.getz());
	glutSolidSphere(.1,25,25);
	glPopMatrix();
}

};

class Lights
{
private:
int max;
int curLight;
bool draw;
vector<Light> lights;
float colorStep;
float degreeStep;
float distanceStep;
public:
Lights()
{
this->colorStep=1.0/255.0;
this->distanceStep=.1;
this->degreeStep=1;
this->lights = vector<Light>();
this->draw=false;
}

void init()
{
	int temp;
	glGetIntegerv(GL_MAX_LIGHTS,&temp);
	this-&gt;max=temp;
	for(int i=0;i&lt;this-&gt;max;i++)
	{
		this-&gt;lights.push_back(Light(i+GL_LIGHT0));
		this-&gt;lights[i].init();
	}
	Load();
}

void Render()
{
	for(int i=0;i&lt;this-&gt;max;i++)
	{
		this-&gt;lights[i].render();
	}
}

void Draw()
{
	this-&gt;draw=!this-&gt;draw;
}

string toString()
{
	stringstream str;
	str&lt;&lt; "Total_Lights: "&lt;&lt; this-&gt;max&lt;&lt; "

Current_Light: "<< this->curLight<< endl;
str<< "Draw_Directions: "<< this->draw<< endl;
for(int i=0;i<this->max;i++)
{
str<< this->lights[i].toString()<< ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
";
}
return str.str();
}

void DrawDirections()
{
	if(!this-&gt;draw)
		return;
	for(int i=0;i&lt;this-&gt;max;i++)
	{
		this-&gt;lights[i].DrawDirection();
	}
}

void Save()
{
	ofstream out("mlights.obj");
	if(out.bad())
		throw exception("we have problem about light");
	for(int i=0;i&lt;this-&gt;max;i++)
		out&lt;&lt; this-&gt;toString()&lt;&lt; endl;
}

void Load()
{
	ifstream input("mlights.obj");
	if( input.bad() )
		return;
		//throw exception("BAD");
	string temp="";
	float x,y,z,a;
	int index,sz;
	input&gt;&gt; temp&gt;&gt; sz&gt;&gt; temp&gt;&gt; this-&gt;curLight&gt;&gt; temp&gt;&gt; this-&gt;draw;

	for(int i=0;i&lt;this-&gt;max; i++)
	{
		input&gt;&gt; temp&gt;&gt; index&gt;&gt; temp&gt;&gt; x;
		if(!x)
			this-&gt;lights[index].OnOff();
		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z;
		this-&gt;lights[index].setPosition(x,y,z);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z;
		this-&gt;lights[index].setDirection(x,y,z);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z;
		this-&gt;lights[index].setUpvector(x,y,z);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z;
		this-&gt;lights[index].setRight(x,y,z);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y;
		this-&gt;lights[index].setRotate(x,y);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z&gt;&gt; a;
		this-&gt;lights[index].setAmbient(x,y,z,a);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z&gt;&gt; a;
		this-&gt;lights[index].setDifuse(x,y,z,a);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; y&gt;&gt; z&gt;&gt; a;
		this-&gt;lights[index].setSpecular(x,y,z,a);

		input&gt;&gt; temp&gt;&gt; x&gt;&gt; temp&gt;&gt; y;
		this-&gt;lights[index].setExp(x);
		this-&gt;lights[index].setCutoff(y);
		input&gt;&gt; temp;
	}
}

void Do(char ch)
{
	if( ch&gt;='1' && ch&lt;='8')
		this-&gt;curLight=ch-'1';
	else
		switch (ch) 
		{
			case 'a':		
				this-&gt;lights[curLight].RotateY(degreeStep);
				break;
			case 'd':		
				this-&gt;lights[curLight].RotateY(-degreeStep);
				break;
			case 'w':		
				this-&gt;lights[curLight].MoveForward( -distanceStep ) ;
				break;
			case 's':		
				this-&gt;lights[curLight].MoveForward( distanceStep ) ;
				break;
			case 'x':		
				this-&gt;lights[curLight].RotateX(degreeStep);
				break;
			case 'y':		
				this-&gt;lights[curLight].RotateX(-degreeStep);
				break;
			case 'c':		
				this-&gt;lights[curLight].StrafeRight(-distanceStep);
				break;
			case 'v':		
				this-&gt;lights[curLight].StrafeRight(distanceStep);
				break;
			case 'f':
				this-&gt;lights[curLight].MoveUpward(-distanceStep);
				break;
			case 'r':
				this-&gt;lights[curLight].MoveUpward(distanceStep);
				break;
			case 'b':
				this-&gt;lights[curLight].OnOff();
				break;
			case '+':
				this-&gt;lights[curLight].incCutoff(degreeStep);
				break;
			case '-':
				this-&gt;lights[curLight].incCutoff(-degreeStep);
				break;
			case 't':
				system("cls");
				cout&lt;&lt; this-&gt;toString();
				break;
			case 'g':
				this-&gt;lights[curLight].FinInfin();
				break;
			case 'q':
				this-&gt;Draw();
				break;
			case 'e':
				this-&gt;lights[curLight].incExp(.1);
				break;
			case 'E':
				this-&gt;lights[curLight].incExp(-.1);
				break;
			case 'm':
				this-&gt;lights[curLight].incSpec(0,this-&gt;colorStep);
				break;
			case 'M':
				this-&gt;lights[curLight].incSpec(0,-this-&gt;colorStep);
				break;
			case ',':
				this-&gt;lights[curLight].incSpec(1,this-&gt;colorStep);
				break;
			case '&lt;':
				this-&gt;lights[curLight].incSpec(1,-this-&gt;colorStep);
				break;
			case '.':
				this-&gt;lights[curLight].incSpec(2,this-&gt;colorStep);
				break;
			case '&gt;':
				this-&gt;lights[curLight].incSpec(2,-this-&gt;colorStep);
				break;
			case '/':
				this-&gt;lights[curLight].incSpec(3,this-&gt;colorStep);
				break;
			case '?':
				this-&gt;lights[curLight].incSpec(3,-this-&gt;colorStep);
				break;
			case 'k':
				this-&gt;lights[curLight].incDifuse(0,this-&gt;colorStep);
				break;
			case 'K':
				this-&gt;lights[curLight].incDifuse(0,-this-&gt;colorStep);
				break;
			case 'l':
				this-&gt;lights[curLight].incDifuse(1,this-&gt;colorStep);
				break;
			case 'L':
				this-&gt;lights[curLight].incDifuse(1,-this-&gt;colorStep);
				break;
			case ';':
				this-&gt;lights[curLight].incDifuse(2,this-&gt;colorStep);
				break;
			case ':':
				this-&gt;lights[curLight].incDifuse(2,-this-&gt;colorStep);
				break;
			case '\'':
				this-&gt;lights[curLight].incDifuse(3,this-&gt;colorStep);
				break;
			case '"':
				this-&gt;lights[curLight].incDifuse(3,-this-&gt;colorStep);
				break;
			case 'o':
				this-&gt;lights[curLight].incAmb(0,this-&gt;colorStep);
				break;
			case 'O':
				this-&gt;lights[curLight].incAmb(0,-this-&gt;colorStep);
				break;
			case 'p':
				this-&gt;lights[curLight].incAmb(1,this-&gt;colorStep);
				break;
			case 'P':
				this-&gt;lights[curLight].incAmb(1,-this-&gt;colorStep);
				break;
			case '[':
				this-&gt;lights[curLight].incAmb(2,this-&gt;colorStep);
				break;
			case '{':
				this-&gt;lights[curLight].incAmb(2,-this-&gt;colorStep);
				break;
			case ']':
				this-&gt;lights[curLight].incAmb(3,this-&gt;colorStep);
				break;
			case '}':
				this-&gt;lights[curLight].incAmb(3,-this-&gt;colorStep);
				break;
			case 'S':
				this-&gt;Save();
				break;
		}
}

int GeSubMenu(int start,void *evn)
{
	int res=glutCreateMenu((void (__cdecl*)(int)) evn);
	for(int i=0;i&lt;this-&gt;max;i++)
	{
		glutAddMenuEntry("projector ",i+start);
	}
	return res;
}

};
}

and here it is the main:

{#using <system.dll>

#include<glut.h>
#include<windows.h>
#include"camera.cpp"
#include"lights.cpp"
#include"ball.cpp"
#include"axises.cpp"
#include"Robot.cpp"
#include"plane.cpp"
#include <stdio.h>
#include <math.h>

float resultArray[2000][3];
int resultCount=0;
int resultIndex=0;
/////////
void MatrixTranspose(double A[3][3], double B[3][3])
{
int i;
int j;
for(i = 0; i < 3; i++)
for(j = 0;j < 3; j++)
A[i][j] = B[j][i];
}

//-----------------------------------------------------------------------------
double Matrix3X3Det(double A[3][3])
{

double inverse_00 = A[1][1]*A[2][2] - A[1][2]*A[2][1];
double inverse_10 = A[1][2]*A[2][0] - A[1][0]*A[2][2];
double inverse_20 = A[1][0]*A[2][1] - A[1][1]*A[2][0];

double det = A[0][0] * inverse_00 +
A[0][1] * inverse_10 +
A[0][2] * inverse_20;

return det;
}
//---------------- inv: A = A^{-1} ---------------------------------------
void MatrixInverse(int z_size, double A[3][3])
{

//int z_size=3; // khodam ezafeeeeeeeeeee kardam???
int i;
int j;
int k;
for (k = 0; k < z_size; k++)

// the pivot element
{
A[k][k] = -1 / A[k][k];

//  the pivot column  
for (i = 0; i &lt; z_size; i++)            
    if (i != k) A[i][k] *= A[k][k];

//  elements not in a pivot row or column   
for (i = 0; i &lt; z_size; i++)
    if (i != k)
        for (j = 0;j &lt; z_size; j++)
            if (j != k)
                A[i][j] += A[i][k] * A[k][j];

//   elements in a pivot row   
for (i = 0; i &lt; z_size; i++)
    if (i != k)
        A[k][i] *= A[k][k];

}

// change sign
for (i = 0; i < z_size; i++) //reverse sign
for (j = 0; j < z_size; j++)
A[i][j] = -A[i][j];

}

//---------------C = A * B-----------------------------------------------------
void MatrixVectorMul(double C[3], double A[3][3], double B[3])
{
int a;
int b;
C[0]=C[1]=C[2]=0;
for(a=0;a<3;a++)
for(b=0;b<3;b++)
C[a] = C[a] + A[a][b]*B[b];
}

//---------------C = A * B-----------------------------------------------------
void MatrixMatrixMul(double C[3][3], double A[3][3], double B[3][3])
{

int a;
int b;
for(a=0;a&lt;3;a++)
    for(b=0;b&lt;3;b++)
        C[a][b] = A[a][0]*B[0][b]+A[a][1]*B[1][b]+A[a][2]*B[2][b];

}
//---------------C = A + B-----------------------------------------------------
void MatrixMatrixplus2(double C[3][3], double A[3][3], double B[3][3])
{
int a;
int b;
for(a=0;a<3;a++)
for(b=0;b<3;b++)
C[a][b] = A[a][b]+ B[a][b];//*B[0][b]+A[a][1]*B[1][b]+A[a][2]*B[2][b];
}
//------------- C = A + B (vectror) ----------------------------------------------------------
void MatrixMatrixplus(double C[3], double A[3], double B[3])
{
int a;

for(a=0;a&lt;3;a++)
        C[a] = A[a]+ B[a];//*B[0][b]+A[a][1]*B[1][b]+A[a][2]*B[2][b];

}
//------------- C=-A ----------------------------------------------------------
void NegativeMatrix(double C[3], double A[3])
{
int a;
for(a=0;a<3;a++)
C[a]=-A[a];

/void square(int i)
{
int sq = i * i;
cout << "Square of " << i << " is " << sq;
}
/

}

/////////////////////////////////////////////////////////////

void Dynamic(double result[], double q[])//, double qdot[3] )//,double KF[3], double Mmdot[3][3])
{
double M[3][3],V[3],G[3];

M[0][0] =  0.25*pow(cos(q[1] + q[2]),2) + cos(q[1] + q[2])*cos(q[1]) + 0.25*(5*pow(cos(q[1]),2)) + 9;
M[0][1] = 0;
M[0][2] = 4;

M[1][0] = 0;
M[1][1] =  cos(q[2]) + 8.500000;
M[1][2] = 0.5*cos(q[2]) + 0.250000;

M[2][0] = 4;        
M[2][1] = cos(q[2])/2 + 0.250000;
M[2][2] = 4.250000;

V[0] =-(q[3]*(5*q[4]*sin(2*q[1]) + q[4]*sin(2*q[1] + 2*q[2]) + q[5]*sin(2*q[1] + 2*q[2]) + 2*q[5]*sin(q[2]) + 4*q[4]*sin(2*q[1] + q[2]) + 2*q[5]*sin(2*q[1] + q[2])))*0.25;
V[1] =(pow(q[3],2)*sin(2*q[1] + q[2]))*0.5 - (pow(q[5],2)*sin(q[2]))*0.5 + (5*pow(q[3],2)*sin(2*q[1]))*0.125 + (pow(q[3],2)*sin(2*q[1] + 2*q[2]))*0.125 - q[4]*q[5]*sin(q[2]);
V[2] = (pow(q[3],2)*sin(q[2]))*0.25 + (pow(q[4],2)*sin(q[2]))*0.5 + (pow(q[3],2)*sin(2*q[1] + q[2]))*0.25 + (pow(q[3],2)*sin(2*q[1] + 2*q[2]))*0.125; 
	  
G[0] = 0;
G[1] = 0.1*(49*cos(q[1] + q[2])) + 0.1*(147*cos(q[1]));
G[2] = 0.1*(49*cos(q[1] + q[2]));


//double a0=1.0000000;double a1=1.0000000;

// double m1=1.0000000;double m2=1.0000000;
//double I0=2.0000000;double I1=3.0000000; double I2=4.0000000;
//double g=9.800000;
//double kz=0.200000;
//// M matrices in the joint space
////notice that M is symmetric

// M[0][0] = I0 + (pow(a1,2)m2pow(cos(q[1] + q[2]),2))/4 + (pow(a0,2)m1pow(cos(q[1]),2))/4 + pow(a0,2)m2pow(cos(q[1]),2) + a0a1m2*cos(q[1] + q[2])*cos(q[1]);//sin(q[1])
//M[0][1] = 0;
//M[0][2] = 0;

//M[1][0] = 0;
//M[1][1] = I1 + (pow(a0,2)*m1)/4 + pow(a0,2)*m2 + (pow(a1,2)*m2)/4 + a0*a1*m2*cos(q[2]);//5.0000*cos(q[2])
//M[1][2] = (a1*m2*(a1 + 2*a0*cos(q[2])))/4;

//M[2][0] = 0;
//M[2][1] = (a1*m2*(a1 + 2*a0*cos(q[2])))/4;//q[1]
//M[2][2] = (m2*pow(a1,2))/4 + I2;//pai5;

////notice that C is skew-symmetric
//V[0] = -(q[3]*(pow(a0,2)*m1*q[4]*sin(2*q[1]) + 4*pow(a0,2)*m2*q[4]*sin(2*q[1]) + pow(a1,2)*m2*q[4]*sin(2*q[1] + 2*q[2]) + pow(a1,2)*m2*q[5]*sin(2*q[1] + 2*q[2]) + 4*a0*a1*m2*q[4]*sin(2*q[1] + q[2]) + 2*a0*a1*m2*q[5]*sin(2*q[1] + q[2]) + 2*a0*a1*m2*q[5]*sin(q[2])))/4;//3.0000*q[5]*sin(q[0]);
//V[1] = (pow(a0,2)*m1*pow(q[3],2)*sin(2*q[1]))/8 + (pow(a0,2)*m2*pow(q[3],2)*sin(2*q[1]))/2 + (pow(a1,2)*m2*pow(q[3],2)*sin(2*q[1] + 2*q[2]))/8 - (a0*a1*m2*pow(q[5],2)*sin(q[2]))/2 + (a0*a1*m2*pow(q[3],2)*sin(2*q[1] + q[2]))/2 - a0*a1*m2*q[4]*q[5]*sin(q[2]);//3.0000*sin(q[2 ]);
//V[2] =(a1*m2*(a1*pow(q[3],2)*sin(2*q[1] + 2*q[2]) + 2*a0*pow(q[3],2)*sin(q[2]) + 4*a0*pow(q[4],2)*sin(q[2]) + 2*a0*pow(q[3],2)*sin(2*q[1] + q[2])))/8;//2.0000;


//G[0] = 0;
//G[1] =  g*m2*((a1*cos(q[1] + q[2]))/2 + a0*cos(q[1])) + (a0*g*m1*cos(q[1]))/2;//2.0000*cos(q[2]);
//G[2] = (a1*g*m2*cos(q[1] + q[2]))/2;//3.0000;
// M matrices in the joint space
//notice that M is symmetric

////////adadi 	

//M[0][0]= pow(cos(q[1] + q[2]),2)/4 + cos(q[1] + q[2])cos(q[1]) + (5pow(cos(q[1]),2))/4 + 2;
//M[0][1]= 0;
//M[0][2]= 0;
//
//M[1][0]= 0;
//M[1][1]= cos(q[2]) + 9/2;
//M[1][2]= cos(q[2])/2 + 1/4;
//
//M[2][0]= 0;
//M[2][1]= cos(q[2])/2 + 1/4;
//M[2][2]= 17/4;
//
////notic
//V[0] = -(q[3](5q[4]sin(2q[1]) + q[4]sin(2q[1] + 2q[2]) + q[5]sin(2q[1] + 2q[2]) + 2q[5]sin(q[2]) + 4q[4]sin(2q[1] + q[2]) + 2q[5]sin(2q[1] + q[2])))/4;
//V[1] = (pow(q[3],2)sin(2q[1] + q[2]))/2 - (pow(q[5],2)sin(q[2]))/2 + (5pow(q[3],2)sin(2q[1]))/8 + (pow(q[3],2)sin(2q[1] + 2*q[2]))/8 - q[4]q[5]sin(q[2]);
//V[2] = (pow(q[3],2)sin(q[2]))/4 + (pow(q[4],2)sin(q[2]))/2 + (pow(q[3],2)sin(2q[1] + q[2]))/4 + (pow(q[3],2)sin(2q[1] + 2q[2]))/8;
//
//
//G[0] = 0;
//G[1] = (49
cos(q[1] + q[2]))/10 + (147
cos(q[1]))/10;
//G[2] = (49
cos(q[1] + q[2]))/10;

////////////////////random example
// M[0][0] = sin(q[1]);//pai1+pai2SQ(cos(Th[1]))+(pai3+pai5)SQ(sin(Th[2]))+2pai6cos(Th[1])*sin(Th[2]);
//M[0][1] = 2.000000;
//M[0][2] = 5.000000;

//M[1][0] = 7.000000;
//M[1][1] = 5.000000*cos(q[2]);//pai4+pai5-2*pai6*sin(Th[1]-Th[2]);
//M[1][2] = 4.000000;//pai5-pai6*sin(Th[1]-Th[2]);

//M[2][0] = 0.000000;
//M[2][1] = q[1];//pai5-pai6*sin(Th[1]-Th[2]);
//M[2][2] = 2.000000;//pai5;

////notice that C is skew-symmetric
//V[0] = 3.000000*q[5]*sin(q[0]);//-Thdot[1]*(pai2*sin(Th[1])*cos(Th[1])+pai6*sin(Th[1])*sin(Th[2]))+Thdot[2]*((pai3+pai5)*sin(Th[2])*cos(Th[2])+pai6*cos(Th[1])*cos(Th[2]));
//V[1] = 3.000000*sin(q[2]);//-Thdot[0]*(pai2*sin(Th[1])*cos(Th[1])+pai6*sin(Th[1])*sin(Th[2]));
//V[2] =2.000000;// Thdot[0]*((pai3+pai5)*sin(Th[2])*cos(Th[2])+pai6*cos(Th[1])*cos(Th[2]));


//G[0] = 0.000000;
//G[1] = 2.000000*cos(q[2]);//pai7*cos(Th[1]);
//G[2] = 3.000000;//pai8*sin(Th[2]);

///////////////////////

double r[3] = {0,0,0};
MatrixMatrixplus(r, V, G);
double s[3] = {0,0,0};
MatrixInverse(3,M);
MatrixVectorMul(s, M, r);
NegativeMatrix(result, s);

}

//Example: y1’=y2+y3-3y1, y2’=y1+y3-3y2, y3’=y1+y2-3y3
double fp(int k, double x, double *y) {
double result[3];
Dynamic(result,y);

switch(k) {
case 0: return y[3];
case 1: return y[4];
case 2: return y[5];
case 3: return result[0];
case 4: return result[1];
case 5: return result[2];
default: return 0;

}
}

// print results
void Display(double *t1,double *t2,double *t3,double *t4,double *t5,double *t6,int m,int p,double xi,double xf) {
int i;
double h,x;
h=(xf-xi)/(m-1);
x=xi-h;
printf("
X");
for (i=1; i<=p; i++) printf(" Y%d", i);
printf("
“);
printf(”-------------------------------------------------------------------------------
");

resultCount=m;
for (i=1; i<m+1; i++) {
x += h;
resultArray[i][0]=57.295780t1[i];
resultArray[i][1]=57.295780
t2[i];
resultArray[i][2]=57.295780t3[i];
printf(" %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f
",x,57.295780
t1[i],57.295780t2[i],57.295780t3[i],57.295780t4[i],57.295780t5[i],57.295780*t6[i]);
}
// resultArray=new Point3D[m];
// resultCount=m;
// for (i=1; i<m+1; i++) {
// x += h;
//resultArray[i]=Point3D(t1[i],t2[i],t3[i]);
//printf(" %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f %9.6f
“,x,t1[i],t2[i],t3[i],t4[i],t5[i],t6[i]);
// }
printf(”--------------------------------------------------------------------------------
");
}

void Eqdifp(double *t1,double *t2,double *t3,double *t4,double *t5,double *t6,double xi,double xf,double *Yi,
int m,int p,int fi)
{
double h,x;
double ta[10],tb[10],tc[10],td[10],y[10],z[10];
int i,j,k,ni;
if (fi<1) return;
h = (xf - xi) / fi / (m-1);
p–;
t1[1]=Yi[0];
t2[1]=Yi[1];
t3[1]=Yi[2];
t4[1]=Yi[3];
t5[1]=Yi[4];
t6[1]=Yi[5];

for (k=0; k<p+1; k++) {
y[k]=Yi[k]; z[k]=Yi[k];
}
for (i=1; i<m+1; i++) {
ni=(i-1)fi-1;
for (j=1; j<fi+1; j++) {
x=xi+h
(ni+j); // baraye chieeeeeeeeeeeeeeeeeeeeeeeeeee?
for (k=0; k<p+1; k++) y[k]=z[k];
for (k=0; k<p+1; k++) ta[k]=hfp(k,x,y);
for (k=0; k<p+1; k++) y[k]=z[k]+ta[k]/2;
x=x+h/2;
for (k=0; k<p+1; k++) tb[k]=h
fp(k,x,y);
for (k=0; k<p+1; k++) y[k]=z[k]+tb[k]/2;
for (k=0; k<p+1; k++) tc[k]=hfp(k,x,y);
for (k=0; k<p+1; k++) y[k]=z[k]+tc[k];
x=x+h/2;
for (k=0; k<p+1; k++) td[k]=h
fp(k,x,y);
for (k=0; k<p+1; k++)
z[k]=z[k]+(ta[k]+2tb[k]+2tc[k]+td[k])/6;
}
t1[i+1]=z[0];
t2[i+1]=z[1];
t3[i+1]=z[2];
t4[i+1]=z[3];
t5[i+1]=z[4];
t6[i+1]=z[5];
}
Display(t1,t2,t3,t4,t5,t6,m,p+1,xi,xf);
}

////////
Camera c;
Lights ls;
Ball b(.13);
Axises ax;
Robot r(.05,.5);
Plane pl;
int bi=0,bi1=0;
void reshape(int x, int y)
{
// r=*new Robot(float b,float a,float c,float d,float e,float f)//base- arm lenght- q1-q2-q3-q hand
//if (y == 0 || x == 0) return; //Nothing is visible then, so return

//Set a new projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Angle of view:40 degrees
//Near clipping plane distance: 0.5
//Far clipping plane distance: 30.0
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,30);

glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);  //Use the whole window for rendering

}
int i=0;
void Display(void)
{
//////////////////////////////////
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

c.Render();
ls.Render();

glColor3f(.8,.8,.8);
//w.Draw();
r.Draw();
ax.Draw();
pl.Draw();
b.Draw();
ls.DrawDirections();
glutSwapBuffers();

}

int h=0;
int y;
int th=0;
void KeyDown(unsigned char key, int x, int y)
{

if(key=='1')
{
	r.SetTetaArm1(i++);
}
if(key=='2')
{
	r.SetTetaArm1(i--);
}
if(key=='3')
{
	r.SetTetaArm2(bi++);
}
if(key=='4')
{
	r.SetTetaArm2(bi--);
}
/*if(key=='3')
{
	r.SetTetaHand(th++);
}*/
if(key=='b')
{
	r.SetTetaBase(bi1++);
}
if(key==27)
	PostQuitMessage(0);
switch(h)//-y)
{
case 0:
	c.Do(key);
	break;
case 1:
	ls.Do(key);
	break;
case 2:
	b.Do(key);
	break;
default:
	//w.Do(h,key);
	break;
}
glutPostRedisplay();

}

void myinit()
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);

glShadeModel(GL_SHADE_MODEL);
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
ls.init();

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE);

r.SetBall(&b);

}

void menu(int ch)
{
h=ch;
}

void createMenu()
{
int i=0;
glutCreateMenu(menu);
glutAddMenuEntry(“Camera”,i++);
glutAddMenuEntry(“Lights”,i++);
glutAddMenuEntry(“Ball”,i++);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}

void OnTimedEvent( System::Object^ source, System::Timers::ElapsedEventArgs^ e )
{
resultIndex++;
if(resultIndex>=resultCount)
{
((System::Timers::Timer^)source)->Enabled = false;
return;
}
r.SetTetaBase(resultArray[resultIndex][0]);
r.SetTetaArm1(resultArray[resultIndex][1]);
r.SetTetaArm2(resultArray[resultIndex][2]);

   //cout&lt;&lt;"

x of base is"<<r.targetBase.getX()<<endl;
//cout<<"
x of Arm1 is"<<r.targetArm1.getX()<<endl;
//cout<<"
x of base is"<<r.targetArm2.getX()<<endl;

   //r.SetTetaBase(resultArray[resultIndex].GetX());
   //r.SetTetaArm1(resultArray[resultIndex].GetY());
   //r.SetTetaArm2(resultArray[resultIndex].GetZ());

   glutPostRedisplay();

}
//cout<<r.targetHand.getX();
/////////////////////////////////////////////////////
#define SIZE 2000 //baraye chieeeeeeeeeeeeee?

int fi,ndata,p=6.00;
double xi,xf;
double yi[10];
double pi=3.1416;
double v1[SIZE],v2[SIZE],v3[SIZE],v4[SIZE],v5[SIZE],v6[SIZE]; //baraye chieeeeeeeeeeeeeee?
/////////////////////////////////////////////////////

int main(int argc, char **argv)
{
/////////////////////////////////////////////////////
printf("
DIFFERENTIAL EQUATIONS WITH 6 VARIABLES OF ORDER 1
“);
printf(” of type yi’ = f(y1,y2,…,yn), i=1…n

");

xi=0;
xf=5;
printf("
end value x : %f ",xf);
i=0; yi[i]=0;
i++;yi[i]=-1.570796;
i++;yi[i]=-1.570796;
i++;yi[i]=0;
i++;yi[i]=0;
i++;yi[i]=0;
ndata=501; fi=1;

// printf("
begin value x : “);
// scanf(”%lf",&xi);
// printf(" end value x : “);
// scanf(”%lf",&xf);
// for (int i=0; i<p; i++) {
// printf(" y%d value at x0 : “,i+1);
//scanf(”%lf",&yi[i]);
// }
// printf(" number of points : “);
// scanf(”%d",&ndata);
// printf(" finesse : “);
// scanf(”%d",&fi);

Eqdifp(v1,v2,v3,v4,v5,v6,xi,xf,yi,ndata,p,fi);

/////////////////////////////////////////////////////
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(900,500);
int u=glutCreateWindow(“3DOF robot”);
myinit();
createMenu();
glutDisplayFunc(Display);
glutReshapeFunc(reshape);
glutKeyboardFunc(KeyDown);
System::Timers::Timer^ aTimer = gcnew System::Timers::Timer( 10 );
//tt=aTimer;
// Hook up the Elapsed event for the timer.
aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler( OnTimedEvent );

  // Set the Interval to 2 seconds (2000 milliseconds).
  aTimer-&gt;Enabled = true;
glutMainLoop();
return 0;

}
}

So you didn’t bother to read my last post about using tags. Nice.

It would help if you post the parts which are relevant and trim the rest. We don’t need to see pages of comments and key press code.

You have glEnable(GL_ColorMaterial)
Try disabling that instead.