{"library":"moderngl-window","title":"moderngl-window","description":"moderngl-window is a cross-platform helper library for ModernGL, simplifying window creation and resource loading for OpenGL applications. It provides a unified API over various windowing backends like Pyglet, GLFW, and SDL2. The library is actively maintained with frequent updates, currently at version 3.1.1, ensuring compatibility and introducing new features.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install moderngl-window","pip install \"moderngl-window<3\""],"cli":null},"imports":["import moderngl_window as mglw","from moderngl_window import WindowConfig"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import moderngl_window as mglw\n\nclass MyWindow(mglw.WindowConfig):\n    # Set OpenGL version (e.g., 3.3 for core profile)\n    gl_version = (3, 3)\n    # Set window size\n    window_size = (1280, 720)\n    # Set window title\n    title = \"Hello, moderngl-window!\"\n    \n    # Optionally, specify a resource directory for shaders, textures etc.\n    # resource_dir = Path(__file__).parent.resolve() / \"resources\"\n\n    def __init__(self, **kwargs):\n        super().__init__(**kwargs)\n        # Any setup for ModernGL context or resources goes here\n        print(\"ModernGL context initialized!\")\n\n    def on_render(self, time: float, frametime: float):\n        # Clear the framebuffer with a color (e.g., red)\n        self.ctx.clear(1.0, 0.0, 0.0, 1.0)\n\n    # You can also implement other event handlers like on_key_event, on_mouse_press_event etc.\n\nif __name__ == '__main__':\n    # Run the window config. This creates the window and starts the event loop.\n    MyWindow.run()","lang":"python","description":"This quickstart demonstrates creating a basic window by extending `moderngl_window.WindowConfig`. It sets up an OpenGL 3.3 context, specifies window dimensions and title, and provides a minimal `on_render` method to clear the screen with a red color. The `run()` method then starts the window's event loop.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}