Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# ModernGL Types

Before throwing you into doing shaders we’ll go through some of the most important types/objects in ModernGL.

- `Buffer` is an OpenGL buffer we can for example write vertex data into. This data will reside in graphics memory.

- `Program` is a shader program. We can feed it GLSL source code as strings to set up our shader program

- `VertexArray` is a light object responsible for communication between `Buffer` and `Program` so it can understand how to access the provided buffers and do the rendering call. These objects are currently immutable but are cheap to make.

- `Texture`, `TextureArray`, `Texture3D` and `TextureCube` represents the different texture types. `Texture` is a 2d texture and is most commonly used.

- `Framebuffer` is an offscreen render target. It supports different attachments types such as a `Texture` and a depth texture/buffer.

All of the objects above can only be created from a `Context` object:

- `Context.buffer()`

- `Context.program()`

- `Context.vertex_array()`

- `Context.texture()`

- `Context.texture_array()`

- `Context.texture3d()`

- `Context.texture_cube()`

- `Context.framebuffer()`

The ModernGL types cannot be extended as in; you cannot subclass them. Extending them must be done through substitution and not inheritance. This is related to performance. Most objects have an `extra` property that can contain any python object.