DrawLayers issue

diofantisdiofantis Global Mapper UserPosts: 35Trusted User
edited April 2009 in SDK
Hi Mike,

In my application i have two layers,
the first layer is used for the map rendering and
the second layer is used for displaying moving tracks (icons/symbols) received for example from the ethernet.

The concept is that every one second, the application have to update the tracks positions on the display.

What i observe, is that if i use the GM_DrawLayer function only for the second layer (tracks layer), then the previous tracks positions are displayed and not cleaned.

Is this the way it should be?

Thanks in advance.

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited April 2009
    The GM_DrawLayer behavior is going to depend on what flags you pass in. Unless you pass in the GM_DrawFlags_EraseBackground, the GM_DrawLayer call won't erase anything that you've already drawn to your device context. I think what you'll want to do is draw your map layer to an offscreen bitmap, then each time you want to update your track display, bit-blt that offscreen bitmap into your DC, then draw your updated track layer on top of that.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • diofantisdiofantis Global Mapper User Posts: 35Trusted User
    edited April 2009
    ok, i understand the point with the drawing flags.
    Exactly, how to use the double buffering mechanism, i am looking for the last two days, in VB.NET in combination with GM.
    Which GM function should i use, in order to draw the map layer to an offscreen bitmap?

    Thanks again.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited April 2009
    You use the same GM SDK functions for offscreen bitmaps. The draw functions just take a device context and don't care if they are based on offscreen or onscreen bitmaps. I don't know how to do it in VB.NET, but in the Windows GDI you could create an offscreen device context with CreateCompatibleDC and then an offscreen bitmap with CreateCompatibleBitmap, then select that bitmap into the DC and draw to that with the SDKto get your offscreen bitmap populated with the map data. You can then BitBlt from that offscreen DC to the onscreen one to start each draw.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.