Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I vary the point size in OpenGL glBegin(GL_POINTS)?

Is there any way to vary the point size when drawing lots of points? I know there's the glPointSize(float), but is there a way to do it in a 'batch' or array?

I would like the points to have different sizes based on an attribute of the data. Such as each point having x, y, z, and a size attribute. I'm using frame buffers right now in java.

Could I possibly use vertex shaders for this?

like image 521
max Avatar asked Jan 04 '11 18:01

max


2 Answers

I believe it's with glPointSize(GLfloat size)

Source:

http://www.talisman.org/opengl-1.1/Reference/glPointSize.html

like image 138
MajuiF Avatar answered Oct 25 '22 07:10

MajuiF


This was what I ever did,

 //reset 
 glLoadIdentity();                                   

 //set size to 1 for a group of points
 glPointSize(1);                                     

 //group #1 starts here     
 glBegin(GL_POINTS);                                 

    //color of group #1 is white 
    glColor3f(1,1,1);                                

    for(int a=0; a<x; a++)
        for(int b=0; b<y; b++)
                    glVertex3f(a/953.,-b/413.,0.);   //location of points
 glEnd();


 //set size to 5 for another group of points
 glPointSize(5);  

 //group #2 starts here     
 glBegin(GL_POINTS);

    //color of group #2 is red 
    glColor3f(1,0,0);
    for(unsigned long int a=0; a<jd; a++)
    {
           glVertex3f(data[a].i,data[a].j,0);
    }
 glEnd();
like image 42
h45 Avatar answered Oct 25 '22 07:10

h45