glPointSize() not working properly

Started by
1 comment, last by Kostya 18 years, 7 months ago
I am having trouble re-setting glPointSize. That is, when the program reaches the first glPointSize(x) it keeps that point size setting throughout the program. It doesn't matter where I place the next glPointSize() statement or what size I choose the program creates points based on that first setting. Here is my code.. the first point size is set to 5.0 under the curMode == OPENGL if block. If I change modes to DDA or BESENHAM instead of drawing the points at 1.0 they are drawn at 5.0. Thanks for any advice. void doDisplay (void) { int iX, iCount, dX, dY, iSteps; float xIncrement, yIncrement, x, y; glClear(GL_COLOR_BUFFER_BIT); if (curMode == OPENGL) { glColor3f(0.0, 1.0, 0.0); glLineWidth(3.0); glBegin(GL_LINE_STRIP); for (iX = 0;iX < curPos; iX++) { glVertex2i(gx[iX], gy[iX]); } glEnd(); glColor3f(1.0, 0.0, 0.0); glPointSize(5.0); glBegin(GL_POINTS); for (iX = 0;iX < curPos; iX++) { glVertex2i(gx[iX], gy[iX]); } glEnd(); } if (curMode == DDA) { glViewport(0,0,600,400); glBegin(GL_POINTS); glColor3f(0.0, 1.0, 0.0); glPointSize(1.0); if (curPos > 1) { for (iCount=0;iCount<curPos-1;iCount++) { dX = gx[iCount+1] - gx[iCount]; dY = gy[iCount+1] - gy[iCount]; x = gx[iCount]; y = gy[iCount]; if ( fabs(dX) > fabs(dY) ) iSteps = fabs(dX); else iSteps = fabs(dY); xIncrement = float(dX) / float(iSteps); yIncrement = float(dY) / float(iSteps); for (iX=0;iX<iSteps;iX++) { x += xIncrement; y += yIncrement; glVertex2i( round(x), round(y) ); } } } glColor3f(1.0, 0.0, 0.0); glPointSize(5.0); for (iX=0;iX<curPos;iX++) { glVertex2i( gx[iX], gy[iX] ); } glEnd(); } if (curMode == BRESENHAM) { glViewport(0,0,600,400); glBegin(GL_POINTS); glColor3f(0.0, 1.0, 0.0); glPointSize(1.0); if (curPos > 1) { for (iX=0;iX<curPos-1;iX++) { doBresenham(gx[iX], gy[iX], gx[iX+1], gy[iX+1]); } } glColor3f(1.0, 0.0, 0.0); glPointSize(5.0); for (iX=0;iX<curPos;iX++) { glVertex2i( gx[iX], gy[iX] ); } glEnd(); } glFlush(); }
Advertisement
Try not putting your glPointSize inside a glBegin()/glEnd() pair. Not all functions work in side there.
Thanks.. that worked.

Now I'm trying to fix this damn Besenham's algorithm to work with steep slopes. Would be great if someone new whats missing. Thanks.

This topic is closed to new replies.

Advertisement