DrawPanelBounds
From X-Plane SDK
This code draws the panel's visible bounds in red and total bounds in magenta during panel callbacks (and is visible in 2-d and 3-d). It draws the panels' visible bounds in green and total bounds in blue during the window callbacks and is only visible in 2-d.
XPLMRegisterDrawCallback( PostPanelCB, xplm_Phase_Panel, 0, 0); XPLMRegisterDrawCallback( PostWindowCB, xplm_Phase_Window, 0, 0); int PostPanelCB( XPLMDrawingPhase inPhase, int inIsBefore, void * inRefcon) { // BEN SAYS: WARNING - Calling XPLMFindDataRef per frame is REALLY BAD! This is just dumb sample code. // Make sure in your code to FIND the dataref once and read it per callback! float vl = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_pnl_l")); float vb = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_pnl_b")); float vr = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_pnl_r")); float vt = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_pnl_t")); float tl = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_pnl_l")); float tb = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_pnl_b")); float tr = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_pnl_r")); float tt = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_pnl_t")); XPLMSetGraphicsState(0, 0, 0, 0, 0, 0, 0); glColor3f(1, 0, 0); glBegin(GL_LINE_LOOP); glVertex2f(vl+8, vb+8); glVertex2f(vl+8, vt-8); glVertex2f(vr-8, vt-8); glVertex2f(vr-8, vb+8); glEnd(); glColor3f(1, 0, 1); glBegin(GL_LINE_LOOP); glVertex2f(tl+6, tb+6); glVertex2f(tl+6, tt-6); glVertex2f(tr-6, tt-6); glVertex2f(tr-6, tb+6); glEnd(); return 1; } int PostWindowCB( XPLMDrawingPhase inPhase, int inIsBefore, void * inRefcon) { // BEN SAYS: WARNING - Calling XPLMFindDataRef per frame is REALLY BAD! This is just dumb sample code. // Make sure in your code to FIND the dataref once and read it per callback! float vl = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_win_l")); float vb = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_win_b")); float vr = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_win_r")); float vt = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_visible_win_t")); float tl = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_win_l")); float tb = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_win_b")); float tr = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_win_r")); float tt = XPLMGetDataf(XPLMFindDataRef("sim/graphics/view/panel_total_win_t")); XPLMSetGraphicsState(0, 0, 0, 0, 0, 0, 0); glColor3f(0, 1, 0); glBegin(GL_LINE_LOOP); glVertex2f(vl+2, vb+2); glVertex2f(vl+2, vt-2); glVertex2f(vr-2, vt-2); glVertex2f(vr-2, vb+2); glEnd(); glColor3f(0, 1, 1); glBegin(GL_LINE_LOOP); glVertex2f(tl+4, tb+4); glVertex2f(tl+4, tt-4); glVertex2f(tr-4, tt-4); glVertex2f(tr-4, tb+4); glEnd(); return 1; }