Multiple Graph Output

Sid Kraft 96 Reputation points
2026-08-06T19:54:15.8+00:00
//OpenGL functions, open a window and initialize
void display(void)
{
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT);
	glLoadIdentity();
	//issue the GL commands
	glTranslatef(-.3, 0., 0.);
	glRotated(45.,0., 1.,0.);
	glScalef(.5, .5, .5);
	glColor3f(0., 0., 0.);
	glBegin(GL_LINES);
	I = 0.;
	do
	{
		//draw the axes
	if (I==0)
		{
		glVertex3f(0., 0., 0.);
		glVertex3f(1., 0., 0.);
		glVertex3f(0., 0., 0.);
		glVertex3f(0., 1., 0.);
		glVertex3f(0., 0., 0.);
		glVertex3f(0., 0., 1.);
		glVertex3f(0., 0., 0.);
		}
	//draw the curve
		glVertex3f(PLOTX[I], PLOTY[I], PLOTZ[I]);
		glVertex3f(PLOTX[I + 1], PLOTY[I + 1], PLOTZ[I + 1]);
		++I;
	} while (I <= INOW);
	glEnd();
	glFlush();
Have the above sequence of commands in the "visual" function, using the OpenGL glutInit and execute commands. Strange
that the only output that I get is for the coordinate axes, not the curve data in the "do" loop? INOW=45 Sid Kraft
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AlexCodex 0 Reputation points
    2026-08-07T06:33:02.9566667+00:00

    If the axes are rendering but the curve isn't, the OpenGL pipeline is probably working, so I'd start by checking the data rather than the drawing code.

    A few things to verify:

    • Make sure PLOTX, PLOTY, and PLOTZ actually contain valid values (not all zeros, NaN, or uninitialized).
    • Check that INOW doesn't exceed the array bounds. Since you're accessing I + 1, the arrays need at least INOW + 2 elements.
    • Print a few values of PLOTX[I], PLOTY[I], and PLOTZ[I] before calling glVertex3f() to confirm they're what you expect.
    • Also verify the transformed coordinates are inside the visible viewing volume after glTranslatef(), glRotated(), and glScalef().

    If you can share how PLOTX, PLOTY, PLOTZ, and INOW are initialized, it'll be much easier to pinpoint the issue.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.