# Using multiple windows

pyglet allows you to create and display any number of windows simultaneously. Each will be created with its own OpenGL context, however all contexts will share the same texture objects, display lists, shader programs, and so on, by default [7]. Each context has its own state and framebuffers.

There is always an active context (unless there are no windows). When using pyglet.app.run for the application event loop, pyglet ensures that the correct window is the active context before dispatching the on_draw or on_resize events.

In other cases, you can explicitly set the active context with Window.switch_to.

[7] | Sometimes objects and lists cannot be shared between contexts; for example, when the contexts are provided by different video devices. This will usually only occur if you explicitly select different screens driven by different devices.