This is a pastime project I’ve been working on for a while and I recently got it to a state where I could share the code, because why not?
It’s a quite simple app that generates a sphere mesh in 3D at runtime, with customizable resolution ie. You can decide how many fragments you want the sphere to be divided into, both horizontally and vertically.
And the sphere can be textured too! Yay
You will need some kind of square texture though, but a quick google search will do the job, remember that it has to be square or you will get weird results.
About the texture mapping, it is not optimal, the top and bottom of the square contains artefacts because of the way I decided to map the texture, it can be improved. But at a high resolution you barely notice the artefacts. You are welcome to improve on that.
As a last mention here, as I said that the mesh is not optimized you sha’nt go too high on the resolution as the mesh gets very big and the amount of redundant vertices increase exponentially (vertices get alot more compressed at the top and bottom, making the overall concentration of verts increase at the poles)
Note: no texture or shader included!
Though you only need a real basic texture shader or a color only shader depending on what you want to use.
But enough talking, here’s the code:
http://pastebin.com/7kPkXwSV
Edit: added shader to code, and fixed errors, now it should be fully working!