## Creating a 3D Sphere using Android GL

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

### Creating a 3D Sphere using Android GL

Hi Guys,
I've trying this for a few days... can somebody help on how to create a 3d sphere in androidGL. most of the samples here are cubes, squares and triangles...
I've seen some examples in the web... regarding 3D Sphere but i can't find the API's that I need to use in android...

regards,

Rex
whreckz
Freshman

Posts: 9
Joined: Wed May 07, 2008 3:59 am
Location: Manila, Philippines

Android GLUT does not have many functionalities, and sphere generation is the lacking one. I believe you'll have to generate the vertices and indices buffer manually.

What I have done with sky dome ( half a sphere ) is something like this. Unfortunately, my coworker did the maths, so I can only give you the idea:

Using java Syntax Highlighting
1. vertices = new float[NUM_VERTICES];
2.
3. voffset = 0;
4.
5. y = 0;
6.
8.
9. while( y < HEIGHT )
10.
11. {
12.
13.   voffset += generateCircleVertices( vertices, voffset, y, radius );
14.
16.
17.   y += 1.0f;
18.
19. }
20.
21. indices = generateSkyDomeIndices();
22.
23.
24.
25.
26.
27. int generateCircleVertices( float[] arr, int offset, float y, float r )
28.
29. {
30.
31.    < use your maths to generate a number of vertices of a circle >
32.
33.    < the more vertices, the nicer the dome will look >
34.
35. }
36.
37.
38.
39. short[] generateSkyDomeIndices()
40.
41. {
42.
43.    < lots of brain work here >
44.
45. }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4
shredder
Junior Developer

Posts: 12
Joined: Mon Mar 03, 2008 2:34 pm

hi,
Thanks for your quick reply. Not much of a help but it gave me a lot of ideas. Again, thanks
whreckz
Freshman

Posts: 9
Joined: Wed May 07, 2008 3:59 am
Location: Manila, Philippines