can someone check this code and tell me problem?

hi everyone,

i am a c++ and opengl learner, so any help/idea/advice/suggestion would be appreciated a lot.

here is the problem; I am trying to get some information from a text file in order to draw some shapes, according to latest test which i tried for my code it is working and getting data from the file correctly, however , it is not drawing anything, and i do not know why… here is the some piece of the code::

void twoPoints(double **s,int numpo)//i am using this //method,in order to get two points’ coordinates from the file
{
double **copy;
copy= new double *[numpo];

for(int i=0;i<numpo;i++)
{
	copy[i]=new double [3];
	copy[i][0]=s[i][0];
	copy[i][1]=s[i][1];
	copy[i][2]=s[i][2];
}
for(int i=0;i<numpo;i++)
	{
		a0=copy[i][0];
		b0=copy[i][1];
		a1=copy[i+1][0];
		b1=copy[i+1][1];
		/*cout<<a0<<" "<<b0<<endl;
		cout<<a1<<" "<<b1<<endl;*/
		drawLine();
	}

}
void drawLine()
{
glPointSize(posize);
/glBegin(GL_POINTS);/

GLdouble x0=a0,y0=b0,x1=a1,y1=b1,x, y, d, m, deltax, deltay, tempx, tempy;

deltax = x1-x0;
deltay = y1-y0;

//=========some conditions… this part is long…==== then

if( m == 1) // case 1: 0 <= m <= 1
{
	y = y0;
	d = 2*(y0-y1)*(x0+1) + (x1-x0)*(2*y0+1) + 2*x0*y1 - 2*x1*y0;
	
	glBegin(GL_POINTS);
	
	for( x = x0; x <= x1; x++)
	{
		glVertex2d(x, y);
		if(d < 0)
		{
			y = y + 1;
			d = d + 2*(x1 - x0) + 2*(y0 - y1);
		}
		else
			d = d + 2*(y0-y1);
	}
	glEnd();
}

//========other conditions…then

glFlush();
}
//====then main…

when it runs, it gives information box with this: “programName.exe has stopped , a problem caused the program to stop correctly…”

can someone tell me what i am doing wrong?

heyy,
after glFlush(), you should add the command “glutSwapBuffers();”. This command allows the drawing of the image

Using code tags and format it a bit would improve readability and thus make it easier for people to help.

hi,

i added and run the program, nothing changed :frowning: ,it still is not working…

You haven’t shown us your windowing or viewport commands. It’s possible that you are trying to draw points/lines outside the defined viewing volume. My first suggestion is to temporarily comment out your ‘twoPoints’ routine and write a much simpler version that has NO calculations in it. Just try to plot a few points using numbers for coordinates in the glVertex2d calls. If that doesn’t work it means you have very basic graphics problems. If it does work it means the calculations you are doing to compute coordinates are not giving you what you expected. Good luck.