# moderngl_window.conf.Settings

moderngl_window.conf.Settings

  Bag of settings values. New attributes can be freely added runtime. Various apply* methods are supplied so the user have full control over how settings values are initialized. This is especially useful for more custom usage. And instance of the Settings class is created when the conf module is imported.

  Attribute names must currently be in upper case to be recognized.

  Some examples of usage:

      from moderngl_window.conf import settings

      # Mandatory settings values
      try:
          value = settings.VALUE
      except KeyError:
          raise ValueError("This settings value is required")

      # Fallback in code
      value = getattr(settings, 'VALUE', 'default_value')

      # Pretty printed string representation for easy inspection
      print(settings)

## Methods

Settings.__init__()

  Initialize settings with default values

Settings.apply_default_settings() → None

  Apply keys and values from the default settings module located in this package. This is to ensure we always have the minimal settings for the system to run.

  If replacing or customizing the settings class you must always apply default settings to ensure compatibility when new settings are added.

Settings.apply_settings_from_env() → None

  Apply settings from `MODERNGL_WINDOW_SETTINGS_MODULE` environment variable. If the environment variable is undefined no action will be taken. Normally this would be used to easily be able to switch between different configuration by setting env vars before executing the program.

  Example:

      import os
      from moderngl_window.conf import settings

      os.environ['MODERNGL_WINDOW_SETTINGS_MODULE'] = 'python.path.to.module'
      settings.apply_settings_from_env()

  Raises:

    ImproperlyConfigured if the module was not found –

Settings.apply_from_module_name(settings_module_name: str) → None

  Apply settings from a python module by supplying the full pythonpath to the module.

  Parameters:

    settings_module_name (str) – Full python path to the module

  Raises:

    ImproperlyConfigured if the module was not found –

Settings.apply_from_dict(data: dict) → None

  Apply settings values from a dictionary

  Example:

      >> from moderngl_window.conf import settings
      >> settings.apply_dict({'SOME_VALUE': 1})
      >> settings.SOME_VALUE
      1

Settings.apply_from_module(module: module) → None

  Apply settings values from a python module

  Example:

      my_settings.py module containing the following line:
      SOME_VALUE = 1

      >> from moderngl_window.conf import settings
      >> import my_settings
      >> settings.apply_module(my_settings)
      >> settings.SOME_VALUE
      1

Settings.apply_from_cls(cls) → None

  Apply settings values from a class namespace

  Example:

      >> from moderngl_window.conf import settings
      >> class MySettings:
      >>    SOME_VALUE = 1
      >>
      >> settings.apply(MySettings)
      >> settings.SOME_VALUE
      1

Settings.apply_from_iterable(iterable: Iterable | generator) → None

  Apply (key, value) pairs from an interable or generator

Settings.to_dict()

  Create a dict representation of the settings Only uppercase attributes are included

  Returns:

    dict representation

  Return type:

    dict

## Attributes

Settings.WINDOW

  Window/screen properties. Most importantly the `class` attribute decides what class should be used to handle the window.

      # Default values
      WINDOW = {
          "gl_version": (3, 3),
          "class": "moderngl_window.context.pyglet.Window",
          "size": (1280, 720),
          "aspect_ratio": 16 / 9,
          "fullscreen": False,
          "resizable": True,
          "title": "ModernGL Window",
          "vsync": True,
          "cursor": True,
          "samples": 0,
      }

  Other Properties:

  - `gl_version`: The minimum required major/minor OpenGL version

  - `size`: The window size to open.

  - `aspect_ratio` is the enforced aspect ratio of the viewport.

  - `fullscreen`: True if you want to create a context in fullscreen mode

  - `resizable`: If the window should be resizable. This only applies in windowed mode.

  - `vsync`: Only render one frame per screen refresh

  - `title`: The visible title on the window in windowed mode

  - `cursor`: Should the mouse cursor be visible on the screen? Disabling this is also useful in windowed mode when controlling the camera on some platforms as moving the mouse outside the window can cause issues.

  - `Samples`: Number if samples used in multisampling. Values above 1 enables multisampling.

  The created window frame buffer will by default use:

  - RGBA8 (32 bit per pixel)

  - 24 bit depth buffer

  - Double buffering

  - color and depth buffer is cleared for every frame

Settings.SCREENSHOT_PATH

  Absolute path to the directory screenshots will be saved by the screenshot module. Screenshots will end up in the project root of not defined. If a path is configured, the directory will be auto-created.

Settings.PROGRAM_FINDERS

  Finder classes for locating programs/shaders.

      # Default values
      PROGRAM_FINDERS = [
          "moderngl_window.finders.program.FileSystemFinder",
      ]

Settings.TEXTURE_FINDERS

  Finder classes for locating textures.

      # Default values
      TEXTURE_FINDERS = [
          "moderngl_window.finders.texture.FileSystemFinder",
      ]

Settings.SCENE_FINDERS

  Finder classes for locating scenes.

      # Default values
      SCENE_FINDERS = [
          "moderngl_window.finders.scene.FileSystemFinder",
      ]

Settings.DATA_FINDERS

  Finder classes for locating data files.

      # Default values
      DATA_FINDERS = [
          "moderngl_window.finders.data.FileSystemFinder",
      ]

Settings.PROGRAM_DIRS

  Lists of str or pathlib.Path used by `FileSystemFinder` to looks for programs/shaders.

Settings.TEXTURE_DIRS

  Lists of str or pathlib.Path used by `FileSystemFinder` to looks for textures.

Settings.SCENE_DIRS

  Lists of str or pathlib.Path used by `FileSystemFinder` to looks for scenes (obj, gltf, stl etc).

Settings.DATA_DIRS

  Lists of str or pathlib.Path used by `FileSystemFinder` to looks for data files.

Settings.PROGRAM_LOADERS

  Classes responsible for loading programs/shaders.

      # Default values
      PROGRAM_LOADERS = [
          'moderngl_window.loaders.program.single.Loader',
          'moderngl_window.loaders.program.separate.Loader',
      ]

Settings.TEXTURE_LOADERS

  Classes responsible for loading textures.

      # Default values
      TEXTURE_LOADERS = [
          'moderngl_window.loaders.texture.t2d.Loader',
          'moderngl_window.loaders.texture.array.Loader',
      ]

Settings.SCENE_LOADERS

  Classes responsible for loading scenes.

      # Default values
      SCENE_LOADERS = [
          "moderngl_window.loaders.scene.gltf.GLTF2",
          "moderngl_window.loaders.scene.wavefront.ObjLoader",
          "moderngl_window.loaders.scene.stl_loader.STLLoader",
      ]

Settings.DATA_LOADERS

  Classes responsible for loading data files.

      # Default values
      DATA_LOADERS = [
          'moderngl_window.loaders.data.binary.Loader',
          'moderngl_window.loaders.data.text.Loader',
          'moderngl_window.loaders.data.json.Loader',
      ]