PDA

View Full Version : Drawing a sphere with GL_POINTS

aphiox
01-24-2002, 10:06 PM
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:
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.

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

wedge
01-24-2002, 10:19 PM
The easy way is to rotate the circle around a diameter and draw again

Gavin
01-25-2002, 01:33 AM
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.

rpxmaster
01-25-2002, 06:47 PM
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?

zed
01-25-2002, 08:03 PM
>>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).]

J P
01-28-2002, 01:28 PM
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);

munificent
01-29-2002, 09:20 AM
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