backspace 0.1.0

Game engine.
Documentation
// Copyright 2024-2025 Gabriel Bjørnager Jensen.
//
// This file is part of Backspace.
//
// Backspace is free software: you can redistribute
// it and/or modify it under the terms of the GNU
// Affero General Public License as published by
// the Free Software Foundation, either version 3
// of the License, or (at your option) any later
// version.
//
// Backspace is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; with-
// out even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Af-
// fero General Public License along with Back-
// space. If not, see
// <https://www.gnu.org/licenses/>.

use crate::error::Result;

use winit::event_loop::ActiveEventLoop;
use winit::window::{Window, WindowAttributes};

/// An initialised graphics context.
#[derive(Debug)]
pub(super) struct InitGraphics {
	/// The main window.
	window: Window,
}

impl InitGraphics {
	/// Constructs a new, initialised graphics context.
	pub fn new(event_loop: &ActiveEventLoop, app_name: &str) -> Result<Self> {
		let window = {
			let mut attributes = WindowAttributes::default();

			attributes.title = app_name.into();

			event_loop
				.create_window(attributes)
				.unwrap()
		};

		let this = Self { window };
		Ok(this)
	}
}