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

20,070

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);
Share:
20,070

Related videos on Youtube

jmurrayufo
Author by

jmurrayufo

Updated on August 26, 2020

Comments

  • jmurrayufo
    jmurrayufo over 3 years

    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.

    • E_net4 the comment flagger
      E_net4 the comment flagger over 11 years
      I would try testing that in a different machine, so as to be sure that the graphic's card and drivers are not to blame for the lack of smoothing the points.
  • user1118321
    user1118321 over 11 years
    FWIW, this doesn't say anything about you. It says loads about how poorly designed OpenGL is that you have to call a separate function to determine if something earlier went wrong. It also speaks loads that the functions don't take typed parameters that would have caught this at compile time. You shouldn't be able to pass the wrong type to glHint(). It should be a fatal compile error. I run into this kind of crap all the time with OpenGL and it irks me to no end.
  • Jim Cote
    Jim Cote over 10 years
    I've tried the suggestions here, but I still get 2x2 pixels. If I use a coordinate like (10.5,10.5), then I get a little plus shape of 5 pixels.