Exemple #1
0
        private int DrawAfterHook(XPLMDrawingPhase inPhase, int inIsBefore)
        {
            Assert.Equal(0, inIsBefore);

            var dr = Api.Data.GetInt(TestData.Name($"draw/hook/count"));

            ++dr.Value;

            return(1);
        }
Exemple #2
0
 private unsafe int XPLMDrawHook(XPLMDrawingPhase inPhase, int inIsBefore, void *inRefcon)
 {
     try
     {
         var ret = m_loopDelegate(inPhase, inIsBefore);
         return(ret);
     }
     catch (Exception exc)
     {
         PluginBridge.Log.Log(exc);
         return(1);                // If an exception happens in the draw hook, then let X-Plane draw
     }
 }
Exemple #3
0
        private int DrawingHook(XPLMDrawingPhase inPhase, int inIsBefore)
        {
            m_api.Log.Log("GraphicsTestPlugin: Entering drawing hook");

            var(x, y, z) = m_api.Graphics.WorldToLocal(47.439444, 19.261944, 0);
            var res = m_probe.ProbeTerrainXYZ((float)x, 0, (float)z);

            m_api.Log.Log($"Probed terrain, got result {res.LocationY} with code {res.Result}");

            var(lat, lon, alt) = m_api.Graphics.LocalToWorld(res.LocationX, res.LocationY, res.LocationZ);

            testTug.Draw(0, 0, new XPLMDrawInfo_t[] { new XPLMDrawInfo_t(res.LocationX, res.LocationY, res.LocationZ, 0.0f, 0.0f, 0.0f) });
            return(1);
        }
Exemple #4
0
        public unsafe XPDrawingLoopHook(DrawDelegate drawCallbackDelegate, XPLMDrawingPhase inPhase, int inWantsBefore)
        {
            m_loopDelegate  = drawCallbackDelegate;
            m_inPhase       = inPhase;
            m_inWantsBefore = inWantsBefore;
            m_hookDelegate  = new XPLMDrawCallback_f(XPLMDrawHook);

            var res = PluginBridge.ApiFunctions.XPLMRegisterDrawCallback(m_hookDelegate, m_inPhase, m_inWantsBefore, null);

            if (res == 0)
            {
                throw new ArgumentException($"Phase {m_inPhase} does not exist in this version of X-Plane");
            }
            else if (res > 1)
            {
                throw new Exception($"Unexpected return value {res}.");
            }
        }
Exemple #5
0
 public IXPDrawingLoopHook RegisterDrawHook(DrawDelegate drawDelegate, XPLMDrawingPhase inPhase, int inWantsBefore)
 {
     return(new XPDrawingLoopHook(drawDelegate, inPhase, inWantsBefore));
 }