From X-Plane SDK
Jump to: navigation, search


XPLM_API void                 XPLMSetGraphicsState(
                                   int                  inEnableFog,    
                                   int                  inNumberTexUnits,    
                                   int                  inEnableLighting,    
                                   int                  inEnableAlphaTesting,    
                                   int                  inEnableAlphaBlending,    
                                   int                  inEnableDepthTesting,    
                                   int                  inEnableDepthWriting);    

XPLMSetGraphicsState changes OpenGL's graphics state in a number of ways:

inEnableFog - enables or disables fog, equivalent to: glEnable(GL_FOG);

inNumberTexUnits - enables or disables a number of multitexturing units. If the number is 0, 2d texturing is disabled entirely, as in glDisable(GL_TEXTURE_2D); Otherwise, 2d texturing is enabled, and a number of multitexturing units are enabled sequentially, starting with unit 0, e.g. glActiveTextureARB(GL_TEXTURE0_ARB); glEnable (GL_TEXTURE_2D);

inEnableLighting - enables or disables OpenGL lighting, e.g. glEnable(GL_LIGHTING); glEnable(GL_LIGHT0);

inEnableAlphaTesting - enables or disables the alpha test per pixel, e.g. glEnable(GL_ALPHA_TEST);

inEnableAlphaBlending - enables or disables alpha blending per pixel, e.g. glEnable(GL_BLEND);

inEnableDepthTesting - enables per pixel depth testing, as in glEnable(GL_DEPTH_TEST);

inEnableDepthWriting - enables writing back of depth information to the depth bufffer, as in glDepthMask(GL_TRUE);

The purpose of this function is to change OpenGL state while keeping X-Plane aware of the state changes; this keeps X-Plane from getting surprised by OGL state changes, and prevents X-Plane and plug-ins from having to set all state before all draws; XPLMSetGraphicsState internally skips calls to change state that is already properly enabled.

X-Plane does not have a 'default' OGL state to plug-ins; plug-ins should totally set OGL state before drawing. Use XPLMSetGraphicsState instead of any of the above OpenGL calls.

WARNING: Any routine that performs drawing (e.g. XPLMDrawString or widget code) may change X-Plane's state. Always set state before drawing after unknown code has executed.