Drawing a 2D silhouette of an island in opengl
I'm trying to draw a 2D silhouette of an island/land of sort in C++ with OpenGL. It is just a simple islan开发者_如何学编程d that looks something like the one here
I tried ways like drawing polygons, fill the colour black and then hard-code tons of vertex points to get the shape of the island and also to keep the edges look rough like the one in the example. But I feel that this really isn't the best way to do this because the number of vertices is just too many. It is also very difficult to tweak because it's not like I'm in Photoshop where I could just pull/add/change the points visually.
Are there any better and more clever way to draw a 2D island silhouette to get the mountain-like edges? As for the overall shape of the island, is my naive way to plant tons of points to form the polygon shape the only way?
I have just started on OpenGL and will be grateful for any suggestions. Thanks!
There are many ways to go about this here are two simple ones;
Easy way: As said in the comments, create the island in an image editor (with alpha) and draw as a quad/tris with blending enabled.
Harder way: Import a vector graphic (vector meaning points making a shape) and draw as polygons. This could get complicated for a newbie if using an existing format. Also, not as efficient as method 1, but can have a much nicer visual effect especially if you plan on zooming/scaling.
In the end it is entirely up to you how you want to implement it, but the first method is straight-forward and easy, I recommend that for a newbie (be sure to come back to it later and try method 2 though ;) ).
精彩评论