Drawing Callbacks

When you create a new map layer (using XPLMCreateMapLayer), you can provide any or all of these callbacks. They allow you to insert your own OpenGL drawing, text labels, and icons into the X-Plane map at the appropriate places, allowing your layer to behave as similarly to X-Plane's built-in layers as possible.


XPLMMapLayerID

typedef

This is an opaque handle for a plugin-created map layer. Pass it to the map drawing APIs from an appropriate callback to draw in the layer you created.

typedef void * XPLMMapLayerID;

XPLMMapProjectionID

typedef

This is an opaque handle for a map projection. Pass it to the projection APIs to translate between map coordinates and latitude/longitudes.

typedef void * XPLMMapProjectionID;

XPLMMapStyle

enum

Indicates the visual style being drawn by the map. In X-Plane, the user can choose between a number of map types, and different map types may have use a different visual representation for the same elements (for instance, the visual style of the terrain layer changes drastically between the VFR and IFR layers), or certain layers may be disabled entirely in some map types (e.g., localizers are only visible in the IFR low-enroute style).

Name Value Description
xplm_MapStyle_VFR_Sectional 0
xplm_MapStyle_IFR_LowEnroute 1
xplm_MapStyle_IFR_HighEnroute 2

XPLMMapDrawingCallback_f

callback

This is the OpenGL map drawing callback for plugin-created map layers. You can perform arbitrary OpenGL drawing from this callback, with one exception: changes to the Z-buffer are not permitted, and will result in map drawing errors.

All drawing done from within this callback appears beneath all built-in X-Plane icons and labels, but above the built-in "fill" layers (layers providing major details, like terrain and water). Note, however, that the relative ordering between the drawing callbacks of different plugins is not guaranteed.

typedef void (* XPLMMapDrawingCallback_f)(
                         XPLMMapLayerID       inLayer,
                         const float *        inMapBoundsLeftTopRightBottom,
                         float                zoomRatio,
                         float                mapUnitsPerUserInterfaceUnit,
                         XPLMMapStyle         mapStyle,
                         XPLMMapProjectionID  projection,
                         void *               inRefcon
                    );

XPLMMapIconDrawingCallback_f

callback

This is the icon drawing callback that enables plugin-created map layers to draw icons using X-Plane's built-in icon drawing functionality. You can request an arbitrary number of PNG icons to be drawn via XPLMDrawMapIconFromSheet() from within this callback, but you may not perform any OpenGL drawing here.

Icons enqueued by this function will appear above all OpenGL drawing (performed by your optional XPLMMapDrawingCallback_f), and above all built-in X-Plane map icons of the same layer type ("fill" or "markings," as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, however, that the relative ordering between the drawing callbacks of different plugins is not guaranteed.

typedef void (* XPLMMapIconDrawingCallback_f)(
                         XPLMMapLayerID       inLayer,
                         const float *        inMapBoundsLeftTopRightBottom,
                         float                zoomRatio,
                         float                mapUnitsPerUserInterfaceUnit,
                         XPLMMapStyle         mapStyle,
                         XPLMMapProjectionID  projection,
                         void *               inRefcon
                    );

XPLMMapLabelDrawingCallback_f

callback

This is the label drawing callback that enables plugin-created map layers to draw text labels using X-Plane's built-in labeling functionality. You can request an arbitrary number of text labels to be drawn via XPLMDrawMapLabel() from within this callback, but you may not perform any OpenGL drawing here.

Labels enqueued by this function will appear above all OpenGL drawing (performed by your optional XPLMMapDrawingCallback_f), and above all built-in map icons and labels of the same layer type ("fill" or "markings," as determined by the XPLMMapLayerType in your XPLMCreateMapLayer_t). Note, however, that the relative ordering between the drawing callbacks of different plugins is not guaranteed.

typedef void (* XPLMMapLabelDrawingCallback_f)(
                         XPLMMapLayerID       inLayer,
                         const float *        inMapBoundsLeftTopRightBottom,
                         float                zoomRatio,
                         float                mapUnitsPerUserInterfaceUnit,
                         XPLMMapStyle         mapStyle,
                         XPLMMapProjectionID  projection,
                         void *               inRefcon
                    );