Drawing a Polygon on a Sphere

Hi there and thanks for this forum.

I managed to create/draw a Sphere using OpenGL.
The Sphere, infact, represent a virtual globe.

However my aim now is to draw polygons on the surface of that Sphere.

I have closed polygons representing the political boundaries of World countries. I could drawn the Polygons by joining the points list, but I could not draw the inner surface…

Any idea ?

Thank you in advance.

the easiest would be to use a texture map. if you want to be able to zoom in and out, then you need to implement some kind of clip mapping, similar to what you have in google earth.

another solution would be to convert your boundary into a list of triangles that represents the area for each country (one time processing on the cpu).

Hi Pierre, thank you for the answer…

I did not understand the first method. As for the second, well I am trying hard to find an easy-to-integrate triangulation method.

Take a look at ear clipping. See David Eberly’s paper Triangulation By Ear Clipping. It is fairly straightforward to get up and going. If you are looking to improve triangulation speed, see my coworker’s article: Triangulation Rhymes With Strangulation.

Unfortunately, triangulation is just one thing you need to do. First project your boundary points onto a plane tangent to the sphere. This simplifies your 3D coordinates to 2D. Then perform ear clipping. Next, project your points back to 3D. Since ear clipping does not introduce new vertices, just keep the 3D point with the 2D point. Most of the resulting triangles will actually be under your sphere’s surface, so subdivide them, e.g. recursively split them into two or more triangles, and raise the new vertices to the sphere’s surface (just normalize them if you are using a unit sphere). Your next problem will be z-fighting, try glPolygonOffset. Finally, if you get to a point where you want your polygon to cover terrain, I can post some information on using an approach based on shadow volumes.

The above is a lot of work, if you are just going for something simple, then burn your polygons into a texture as Pierre suggested.


I would also suggest texture mapping instead of drawing polygons. It’s very easy and gives you a better looking result. I have a demo which does this. The OpenGL code and required images are included. Go to -

OpenGL Image Loading & Texture Mapping

Copy all of the files onto your PC (?) and you should be good to go.

If you MUST use polygons instead of textures, you’ll have to get, or model, a polygonal world map where the continents are filled in with internal polygons. You can probably find something like that by Googling ‘Polygonal World Map’ ?


This is exactly what I am attempting to do. I have a set of polygons which are filled in to represent land on earth, but I have a problem where the vertices that bound the polygon are hidden (on the other side of the globe) the polygon is clipped, (see screenshot below at Asia & Russia). How would I wrap the polygon around the globe without texture mapping (if possible?), so that the polygon isnt clipped?


First of all - good idea to post a screenshot. This helps us help you. Your problem isn’t really clipping - it’s back face culling (which can be disabled but it won’t solve your problem). Polys with normals facing away from the camera aren’t drawn. If it was depth clipping, the little lakes in Russia near the horizon would not appear. Your problem is with the polygons themselves. They’re too big and complex. By ‘big’ I mean that no poly should span more than 5 degs in lat and lon. You have polys that cover half of Russia. By ‘complex’ I mean that they are concave. Concave polys don’t render correctly with OpenGL. That’s why parts of the Black Sea, Med. Sea, and Indian Ocean are filled with green. You can fix this problem by taking your polygonal model of the earth’s continents into a modeler and splitting the large polys into small ones. Or, you can search the web to try to find a model that’s more appropriate for your task. For example:


Any idea how I can do this? Can this be done in OpenGL itself?

Any idea how I can do this? Can this be done in OpenGL itself? [/QUOTE]
It would be non-trivial in OpenGL. It would be easier with a geometric modeler or CAD package in which case you’d use a combination of modeling utilities mixed in with some tedious polygon by polygon definitions. You see now why people are recommending you go with a textured sphere. It’s simple to program and you don’t have to deal with any nasty polygons. I have put a simple world map model (in .obj format) at:

Simple Spherical World Map Model

The .obj file (Wavefront format) has vertex and polygon definitions for the model shown in the .jpg image. If it’s not too simple for your needs, you are welcome to use it. Note that all the polygons in this model are either triangles or convex quads, and that all the polys are relatively small compared to the size of the earth. That’s what you need if you want to wrap a polygonal representation of the continents onto a sphere.

Any other ‘region’ you want to show on the earth’s surface has to be similarly tessellated. Not trying to discourage you, just point you in the right direction.

Hi Patrick,
I got back to this issue, after I abandoned it for a long time.
Thankfully, I solved the main issues and I am interested to know about that shadow technique that would allow the polygons to cover terrain and appear above the sea.