PDA

View Full Version : Why is my Line Strip visible and invisible at times?



sunnymonk
02-26-2005, 12:19 AM
Hi ppl,
I have an array of 3D coordinates of some points that i want to display on screen. Let the array be called displayStrokes3D, the coordinates are in double format. Below is my pseudocode..

if displayStrokes3D is true,
{
glColor3f (1.0,1.0,1.0);
glLineWidth (2);
glBegin(GL_LINE_STRIP);
for every element in displayStrokes3D
{
glVertex3d(displayStrokes3D[i].x, displayStrokes3D[i].y, displayStrokes3D[i].z);

}//end for loop
glEnd();
}

This segment of code is in my Render function and it is called whenever i add more points into displayStrokes3D array and then i call glutPostRedisplay(); Points are added as i add the (x,y) of mouse coordinates when i drag the mouse.

By right, the line strip will get longer and longer when i add more points. However, sometimes i see the full line strip on screen and sometimes, the line strips seems cut off at some place, and some times i don't see any lines on the screen at all..why is this so?

I do not see any wrong in my code or logic, maybe some one can enlighten me or spot my mistakes. Thanks!

MMMovania
02-26-2005, 12:51 AM
Originally posted by sunnymonk:
Hi ppl,
I have an array of 3D coordinates of some points that i want to display on screen. Let the array be called displayStrokes3D, the coordinates are in double format. Below is my pseudocode..

if displayStrokes3D is true,
{
glColor3f (1.0,1.0,1.0);
glLineWidth (2);
glBegin(GL_LINE_STRIP);
for every element in displayStrokes3D
{
glVertex3d(displayStrokes3D[i].x, displayStrokes3D[i].y, displayStrokes3D[i].z);

}//end for loop
glEnd();
}

This segment of code is in my Render function and it is called whenever i add more points into displayStrokes3D array and then i call glutPostRedisplay(); Points are added as i add the (x,y) of mouse coordinates when i drag the mouse.

By right, the line strip will get longer and longer when i add more points. However, sometimes i see the full line strip on screen and sometimes, the line strips seems cut off at some place, and some times i don't see any lines on the screen at all..why is this so?

I do not see any wrong in my code or logic, maybe some one can enlighten me or spot my mistakes. Thanks!Hello there, try this
Your are testing the array in the first condition change it with a boolean variable that is set in the drag handler where you add points to the array. I don't think there is anything else here.

sunnymonk
02-26-2005, 08:30 PM
Hello,
i do not think that the first condition is a problem.

This is because a line breaks at some points in a line strip..this shows that the lines are actually drawn to the screen as intended. The problem is i could not figure out about the breaks in the line, since i did not use line stipple..and sometimes the breaks are so much until the line becomes invisible...and the breaks happen at different location whenever i redisplay the screen.

If the code is not the problem, what could it be?
*Confused*

MMMovania
02-27-2005, 01:35 AM
May be your hardware is the culprit here? Give the code wne let me check on my machine.