API Guide > Viewport 2.0 API > Maya Viewport 2.0 API Guide > 5. Devices and Draw APIs >

# 5.1 Single Device Model

At any given time, there is only one device which can be active. If there is more than one video card present in a system configuration, then the framework is instantiated relative to the first device (card) detected. This does not preclude the card driver from taking advantage of subsequent cards, but internally, there are no implicit optimizations made for multiple cards.

The concept of one device can be interpreted as using one OpenGL context for the entire framework. This differs from older interfaces where multiple contexts can be accessed with one OpenGL context per device context/drawable (for example, one per 3d viewport). The implication for a plug-in is that the code should never switch OpenGL contexts or frame buffer objects nor use pixel buffer objects within its code. If such changes are required then the original state should always be restored.

Sharing of contexts or devices is still possible for OpenGL and DirectX, respectively.

As has been previously mentioned, there are specific points at which it is safe to access a device or context. In particular, for OpenGL, it is only safe to access an OpenGL context when a render target is active. The basic rule-of-thumb is that if a draw context (MDrawContext) is available, then the OpenGL context can be accessed. For DirectX, because access performed at the device level, it should be safe at all times.