Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering inside an irregular area e.g. country boundary


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 04 December 2012 - 11:00 AM

I want to render the terrain map along with some other graphics inside the Canadian country boundary, the part of the terrain map that is outside Canada is designed to be discarded. The geographic data is available. How can I do this? Thanks in advance.

Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2120

Like
0Likes
Like

Posted 04 December 2012 - 11:32 AM

It'd be useful to know what format your data is in.

Assuming it's some sort of grid bitmap (e.g. for each 'pixel' of your data, you can query whether it's canada or not) , you can turn that into a outline using the 'marching squares' algorithm. This can result in a vector representation of the country (perhaps that's what you're starting with, in which case you can skip the marching squares step).

Now it sounds like you want to triangulate this outline so you draw it as a solid filled polygon. For this your best bet might be 'ear clipping'.

Marching squares and ear clipping are well documented algorithms, so rather than detail them, you can just google them.

#3 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 04 December 2012 - 11:55 PM

Thanks for your quick response, C0lumbo.
Our Canada country boundary is just an array of points and we draw the boundary as a polygon (GL_POLYGON). Using marching squares and ear clipping algorithm may be an overkill. Our preliminary method is to create a mask that mask out all graphics outside the polygon. But we are not sure whether OpenGL provides such mechanism.

#4 Ashaman73   Crossbones+   -  Reputation: 6717

Like
0Likes
Like

Posted 05 December 2012 - 12:34 AM

Look up the stencil buffer and test. You would render the country with writing to the stencil buffer, after that everything else would render to the screen with stencil test on (render only pixels, where a stencil flag has been set).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS