Jump to content
  • Advertisement
Sign in to follow this  
Kostya

glPointSize() not working properly

This topic is 4747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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(); }

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!