niebieski Posted December 27, 2013 Report Posted December 27, 2013 Hello guys! I've asked this on the other forums, but no one answered my question so far. I know there are some talented devs here, so i thought i'll give it a try and ask for your help. I'm just taking my first steps with drawing custom instruments using OpenGL (and OpenGL in general). So far i have properly registered drawing callback for gauges phase that draws simple OpenGL primivites. I'm aware that i need to do all of my OpenGL rendering on the panel texture for the instrument to be visible in 3D cockpit. However all my drawing stuff ends up being simply rendered inside X-Plane window (on top of the panel, gauges etc.) and not on the underlying panel texture. For now, my drawing callback is really simple:int myDrawingCallback(XPLMDrawingPhase inPhase, int inIsBefore, void* inRefcon) { XPLMSetGraphicsState(0, 1, 0, 0, 0, 0, 0); ... [couple of basic gl* functions to draw a simple line] ... return 1; }Could someone please explain to me what should i do to direct all of my OpenGL drawing to the underlying panel texture and not to the X-Plane window itself? Thanks in advance! Quote
tkyler Posted December 27, 2013 Report Posted December 27, 2013 (edited) There are two phases specific to drawing to the panel texture....'xplm_Phase_Panel" and 'xplm_Phase_Gauges'. The phase in which your drawing callback is called is defined during the registration of your drawing function with 'XPLMRegisterDrawCallback'. First, ensure you registered your drawing callback to be called during the phase, "xplm_Phase_Gauges" like so:XPLMRegisterDrawCallback (myDrawingCallback, xplm_Phase_Gauges, 1, NULL);This says you want the function named "myDrawingCallback" to draw during the Gauge drawing phase (which is drawn to the panel texture)....the 1 says, "draw before x-plane draws(I think.....the docs do not clarify but if you don't draw on top of xplane graphics it won't matter). the NULL, of course, means you're using no reference pointer of any type. Without your registration function, we can't know if this is the problem for sure...so this is just a stab. The following link covers this topic http://www.xsquawkbox.net/xpsdk/mediawiki/XPLMDisplay TomKIXEG Edited December 27, 2013 by tkyler 1 Quote
niebieski Posted December 27, 2013 Author Report Posted December 27, 2013 (edited) Thanks for your reply, Tom Registering drawing callback seems to be the easy part of it. I'm pretty sure i'm doing everything ok when it comes to registering the callback:XPLMRegisterDrawCallback(myDrawingCallback, xplm_Phase_Gauges, 0, NULL);I'm 100% sure myDrawingCallback is getting called by X-Plane rendering pipeline. I bet the problem is in the drawing callback itself... Edited December 27, 2013 by niebieski Quote
tkyler Posted December 27, 2013 Report Posted December 27, 2013 (edited) Not necessarily, there are some subtleties and caveats related to camera and acf settings though, both in planemaker and in sim that have tripped me up also. For example, if your aircraft loads with a 2D panel visible (dependent on a few factors), then it will appear as if you are drawing to the xplane window when in reality you are drawing to the panel texture....its just that the 2D panel texture is visible. Try going to a 3D view using SHIFT-9 and see if you openGL drawing appears any different. TomK Edited December 27, 2013 by tkyler Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.