Results 1 to 7 of 7

Thread: How to define Point Size in openGL ?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    10

    How to define Point Size in openGL ?

    Following does not work:

    glBegin(GL_POINTS);
    glPointSize(0.2);
    glVertex3f(-5,0,0);
    glPointSize(2.0);
    glVertex3f(-5,4,0);
    glPointSize(26.;
    glVertex3f(-5,8,0);
    glPointSize(4;
    glVertex3f(-5,-4,0);
    glPointSize(4);
    glVertex3f(-5,-8,0);
    glPointSize(0.6);
    glVertex3f(-5,14,0);
    glEnd();

    This code draws points each with the same size. I changed and try this same code with many different values (big/small integers/floats) , but it always draws all points with the same size. Questions at that point: What does glPointSize do ? It propably not changes the point size. What is wrong in my code? How can I draw points with different sizes ?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: How to define Point Size in openGL ?

    Read the manual for glBegin. You'll see that there are only a few commands that can be called between glBegin and glEnd. glPointSize is not one of them. If you must use GL_POINTS to draw your dots, then you'll have to call glBegin and glEnd for every dot, with glPointSize called before each glBegin.
    Am I doing your homework for you?

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    10

    Re: How to define Point Size in openGL ?

    ok, thx for your helpful answer. Now, it works, but one more question. Are you sure that I have to write glBegin and glEnd for each points ? Because I use GL_POINTS in glBegin , which means plural. It does not make much sense to me if I have each time to write glBegin and glEnd.

    Is there any other opportunities to draw a filled sphere by a given 3d points and a radius r ?

    What I do is , there is a set of 3d points which are connected with edges. I want the nodes to be drawn (where I use GL_POINTS at the moment), but the graph is 3d and rotatable by mouse. If I rotate them , the GL_POINTS do not look very fine. Would it be better to draw a sphere with some radius ? Or any other solutions for that ?

    (I am new to OpenGL and to C++)

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: How to define Point Size in openGL ?

    Are you sure that I have to write glBegin and glEnd for each points ? Because I use GL_POINTS in glBegin , which means plural. It does not make much sense to me if I have each time to write glBegin and glEnd.
    You can define as many points as you want between glBegin/glEnd calls. In your case it is possible because you call glPointSize for each point and it is invalid operation between glBegin and glEnd calls.
    See errors in glPointSize man page.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    10

    Re: How to define Point Size in openGL ?

    ok thanks. Actuall I only need one and the same size, so I use glPointSize out of glBegin and it works now. My question was more for demonstration how to manage to draw points with different pointsize. At the moment I only need the same pointsize , but later I might need to draw different size. In this case I will use as many glBegin and glEnds as I need points with different size , right ?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: How to define Point Size in openGL ?

    Quote Originally Posted by Disney
    I only need one and the same size, so I use glPointSize out of glBegin and it works now. My question was more for demonstration how to manage to draw points with different pointsize. At the moment I only need the same pointsize, but later I might need to draw different size. In this case I will use as many glBegin and glEnds as I need points with different size, right?
    That's correct. This is exactly what I do to display star fields. I put 7,000 stars into 6 bins by magnitude (brightness). Each bin is displayed as a set of points between a glBegin-glEnd pair, preceeded by a PointSize command.
    Am I doing your homework for you?

  7. #7
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: How to define Point Size in openGL ?

    Some other methods are to use GL_POINT_DISTANCE_ATTENTUATION, or use the gl_PointSize command in a vertex shader which has access to an array of point sizes, or calculates them procedurally.

    http://www.opengl.org/sdk/docs/man/x...tParameter.xml

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2009, 08:27 AM
  2. point size limit?
    By andras in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-27-2006, 04:10 PM
  3. Maximum point size
    By chuck in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-03-2004, 03:27 AM
  4. how to define a point of reference in a war tank game world
    By candy in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-15-2004, 07:43 PM
  5. the point size
    By huangzl99 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-19-2001, 08:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean