View Full Version : How to color a sphere non-uniformly ?
05-07-2009, 08:49 AM
I am drawing a sphere using 'gluSphere()', after setting the color with 'glColor3f()'. I would like to apply different colors to the two sides of the sphere e.g. to specify the colors separately for each segment of the sphere. Is there a way to do that, that is documented online ?
Thanks for any pointers...
05-07-2009, 08:58 AM
either with texture or rendering the sphere with multiple draw calls one part at a time, changing the color. gluSphere renderes whole sphere i guess but you could use clipping planes to cut through. better yet textures.
05-07-2009, 09:04 AM
Just write your own sphere drawing code and you will have control of texture coordinates or the color of each vertex. Otherwise you won't.
As NK47 suggests, you could use gluSphere to draw two spheres with different colors or textures, then use glClipPlane to cut away half of each sphere. This approach would be the easier of the two - BUT is limited to fairly simple sphere tesselations. This is how I did the earth in the figure below ...
Two Spheres Cut In Half Using glClipPlane (http://imagebin.ca/view/ZU6-RFT.html)
If you want to get fancy and apply lots of different colors/textures to various pieces of the sphere, you have to write your own sphere routine, as dletozeun says. This is how I did the polygonal earth below. It's not that hard to write your own sphere routine. It would be an interesting OpenGL exercise for a beginner.
Polygonal Sphere (http://imagebin.ca/view/F0uCZbU.html)
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.