Results 1 to 7 of 7

Thread: Drawing a sphere with GL_POINTS

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Denton,TX,USA
    Posts
    1

    Drawing a sphere with GL_POINTS

    What I want to do is draw a sphere using only GL_POINTS. Don't ask me why...just want to.
    What I have so far is a function that will draw a circle with GL_POINTS flat on the x and z axis that looks like this:
    DrawCircle(GLfloat y,GLfloat radius);
    This function will draw the circle with the given radius and at the y coordinate(repeat:flat on the x and z axis).
    What I'm having trouble with is using this function to draw a sphere. I know what y coordinates to use; just from a starting point to the displacement (Maximum radius) BUT I'm having trouble changing the radius to make it look like a sphere.
    I know I either have to use the sine function to fluctuate the radius but I keep getting screwed up stuff.
    PLEASE HELP!


    [This message has been edited by aphiox (edited 01-25-2002).]

  2. #2
    Member Contributor
    Join Date
    Oct 2001
    Location
    Germany
    Posts
    60

    Re: Drawing a sphere with GL_POINTS

    The easy way is to rotate the circle around a diameter and draw again

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: Drawing a sphere with GL_POINTS

    In the sdk there is sample code for a recursive subdivision sphere. It is for polys but all it does is produce the vertexs so draw points there instead. When you say draw a sphere there are vaarious different 'patterns' you can use. Look up geodesic spheres or something on the web.

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2001
    Location
    Omaha, NE US
    Posts
    119

    Re: Drawing a sphere with GL_POINTS

    I have a question, but it's not really related to this topic. It has to do with drawing points however, so I'll post it here.

    When I draw a plot of points, using GL_POINTS like he said, and scale it, say, 10x, the points that are drawn are turned into giant squares. My question is, is there any way to make 'circular' points instead of squares here?

  5. #5
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: Drawing a sphere with GL_POINTS

    >>When I draw a plot of points, using GL_POINTS like he said, and scale it, say, 10x, the points that are drawn are turned into giant squares. My question is, is there any way to make 'circular' points instead of squares here?<<

    if u mean glScale(10,10,10) this shouldnt happen. if willl happen though if u use glPointSize(10)
    to get round point u need to enable point smooth + blending, this is in the red book + perhaps also in the faq

    also u can draw the sphere normally but use glPolygonMode( GL_FRONT_AMD_BACK, XX );

    XX can be GL_POINTS, GL_LINES, GL_SOLID?(i dont think so but its the default)

    [This message has been edited by zed (edited 01-25-2002).]

  6. #6

    Re: Drawing a sphere with GL_POINTS

    Here is what I do to get round points.

    // round points
    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  7. #7

    Re: Drawing a sphere with GL_POINTS

    To draw a sphere with the points arranged like the intersections of latitude and longitude lines on a globe, it works like this:

    #define PI 3.14159
    #define STEPS 20

    float y, radius;

    // assuming you want a sphere of radius 1.0
    // with STEPS rows of points
    for( float theta = 0.0; theta <= PI; theta += PI / STEPS )
    {
    y = cos( theta );
    radius = sin( theta );
    DrawCircle( y, radius );
    }

    try that. note that i'm coming up with this from memory, so i'm not too sure about it, but i think that's right.

    hope it helps.

Similar Threads

  1. GL_POINTS problem with drawing circles with outline
    By karkarotten1337 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-28-2017, 04:39 PM
  2. glDrawArrays(GL_POINTS,...) only drawing a single point
    By TravisG in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-24-2013, 06:09 PM
  3. GL_POINTS not drawing points in Android
    By guihazan in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-26-2013, 05:49 PM
  4. drawing GL_POINTS with mouse. Spacings? [brush stroke]
    By hockeyman in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-12-2012, 07:20 AM
  5. 2D Drawing using GL_POINTS
    By Brlja in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-02-2010, 04:39 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