huangzl99

09-09-2001, 11:13 AM

if I know a sphere equation, for example

x2+y2+z2=100, how do opengl draw this sphere?

thanks a lot!

x2+y2+z2=100, how do opengl draw this sphere?

thanks a lot!

View Full Version : please help me!

huangzl99

09-09-2001, 11:13 AM

if I know a sphere equation, for example

x2+y2+z2=100, how do opengl draw this sphere?

thanks a lot!

x2+y2+z2=100, how do opengl draw this sphere?

thanks a lot!

mikael_aronsson

09-09-2001, 12:08 PM

Hi !

OpenGL can only draw triangles (and maybe quads) but that's it, so you have to tesselate your sphere into triangles, you gan use GLU to do it for you with gluSphere, or you can do it yourself.

You can always look at the glu source code to see how it's done (at least the Mesa version of glu) it's at http://www.sourceforge.net

Mikael

OpenGL can only draw triangles (and maybe quads) but that's it, so you have to tesselate your sphere into triangles, you gan use GLU to do it for you with gluSphere, or you can do it yourself.

You can always look at the glu source code to see how it's done (at least the Mesa version of glu) it's at http://www.sourceforge.net

Mikael

john

09-09-2001, 04:37 PM

Hello,

yes, the glu source will tell you how to make a colelction of triangles make a sphere, but I think the poster is asking about how to interpret the equation of a sphere?

OpenGL cannot plot functions for you; you can't just call some gl function to render f(x)=x^2+4, for example.

However, x^2+y^2+z^2=100 describes a sphere with radius 10, so you can just call

gluSolidSphere(10);

(or whatever the syntax for for gluSolidSPhere is; I forget).

Oh, and for anything more complex, like an ellipsoide? <chuckles politely> then you'll need ot use scale.

cheers,

John

yes, the glu source will tell you how to make a colelction of triangles make a sphere, but I think the poster is asking about how to interpret the equation of a sphere?

OpenGL cannot plot functions for you; you can't just call some gl function to render f(x)=x^2+4, for example.

However, x^2+y^2+z^2=100 describes a sphere with radius 10, so you can just call

gluSolidSphere(10);

(or whatever the syntax for for gluSolidSPhere is; I forget).

Oh, and for anything more complex, like an ellipsoide? <chuckles politely> then you'll need ot use scale.

cheers,

John

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.