jmurrayufo jmurrayufo - 3 months ago 49
C++ Question

Drawing points with GL_POINTS and GL_POINT_SMOOTH results it two pixel tall points?

I have the following:

glHint(GL_POINT_SMOOTH, GL_NICEST);
glEnable(GL_POINT_SMOOTH);


The issue is that when I attempt to draw a pixel:

DrawPoints(float x1,float y1)
{
glBlendFunc(GL_DST_ALPHA,GL_ONE_MINUS_DST_ALPHA);
glPointSize(1);
glBegin(GL_POINTS);
glVertex2f(x1, y1);
glEnd();
}


I get points on the screen that are two pixels wide, and two pixels tall. The pixels that were two pixels wide were solved by making sure that
x1
is called with a
.5
at the end. Forcing the
y1
variable to end in
.5
did not fix the height issue. The points are always 2 pixels tall despite being set to be only one.

How could I solve this?

EDIT:

Took a screen shot of the issue in question. It is drawing out a sine wave on the screen.

Shot0

EDIT 2:

Here's the full initialization code:

if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
fprintf(stderr,"%s:%d\n SDL_Init call failed.\n",__FILE__,__LINE__);
return false;
}

if((Surf_Display = SDL_SetVideoMode(WWIDTH, WHEIGHT, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) {
fprintf(stderr,"%s:%d\n SDL_SetVideoMode call failed.\n",__FILE__,__LINE__);
return false;
}
// Init GL system
glClearColor(0, 0, 0, 1);

glClearDepth(1.0f);

glViewport(0, 0, WWIDTH, WHEIGHT);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0, WWIDTH, WHEIGHT, 0, 1, -1);

glMatrixMode(GL_MODELVIEW);

glEnable(GL_TEXTURE_2D);

glHint(GL_POINT_SMOOTH, GL_NICEST);
glHint(GL_LINE_SMOOTH, GL_NICEST);
glHint(GL_POLYGON_SMOOTH, GL_NICEST);

glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);

glLoadIdentity();


Making sure that
glEnable(GL_BLEND);
has been called did not help either.

Another note, calling
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
had no effect on the pixel height either.

Answer

I found the answer to what went wrong.

This code caused the error:

glHint(GL_POINT_SMOOTH, GL_NICEST);
glHint(GL_LINE_SMOOTH, GL_NICEST);
glHint(GL_POLYGON_SMOOTH, GL_NICEST);

These are not the correct flags to give to glHint.

This code fixed it and got rid of a ENUM error that OpenGL was throwing. I found that one through debugging whole other issue. Serves me right for not checking error states!

glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);