tweak all internal pub mod / pub use and re-do the prelude module
this is based off what i saw some other libraries doing. i'm not sure what is the "best practice" to be honest, but i definitely like this. especially the prelude is now much simpler, which is nice.
This commit is contained in:
parent
e8847d01be
commit
73e5b9c7bc
|
@ -2,7 +2,9 @@ use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::AudioSpec;
|
use crate::audio::AudioSpec;
|
||||||
|
|
||||||
pub mod wav;
|
mod wav;
|
||||||
|
|
||||||
|
pub use wav::*;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum AudioBufferError {
|
pub enum AudioBufferError {
|
||||||
|
|
|
@ -7,9 +7,8 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use sdl2::audio::AudioFormat;
|
use sdl2::audio::AudioFormat;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::buffer::AudioBuffer;
|
use crate::audio::{AudioBuffer, AudioSpec};
|
||||||
use crate::audio::AudioSpec;
|
use crate::utils::StreamSize;
|
||||||
use crate::utils::io::StreamSize;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum WavError {
|
pub enum WavError {
|
||||||
|
|
|
@ -3,8 +3,7 @@ use std::ops::{Index, IndexMut};
|
||||||
use sdl2::audio::AudioCallback;
|
use sdl2::audio::AudioCallback;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::buffer::AudioBuffer;
|
use crate::audio::{AudioBuffer, AudioGenerator, AudioSpec, NUM_CHANNELS};
|
||||||
use crate::audio::{AudioGenerator, AudioSpec, NUM_CHANNELS};
|
|
||||||
|
|
||||||
/// Represents a "channel" of audio playback that will be mixed together with all of the other
|
/// Represents a "channel" of audio playback that will be mixed together with all of the other
|
||||||
/// actively playing audio channels to get the final audio playback.
|
/// actively playing audio channels to get the final audio playback.
|
||||||
|
|
|
@ -2,11 +2,15 @@ use sdl2::audio::{AudioFormat, AudioFormatNum, AudioSpecDesired};
|
||||||
use sdl2::AudioSubsystem;
|
use sdl2::AudioSubsystem;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::device::AudioDevice;
|
use crate::audio::AudioDevice;
|
||||||
|
|
||||||
pub mod buffer;
|
mod buffer;
|
||||||
pub mod device;
|
mod device;
|
||||||
pub mod queue;
|
mod queue;
|
||||||
|
|
||||||
|
pub use buffer::*;
|
||||||
|
pub use device::*;
|
||||||
|
pub use queue::*;
|
||||||
|
|
||||||
/// The number of simultaneously playing audio channels supported by this library currently.
|
/// The number of simultaneously playing audio channels supported by this library currently.
|
||||||
pub const NUM_CHANNELS: usize = 8;
|
pub const NUM_CHANNELS: usize = 8;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::audio::buffer::AudioBuffer;
|
use crate::audio::{Audio, AudioBuffer, AudioDevice, AudioDeviceError, AudioGenerator, AudioSpec, NUM_CHANNELS};
|
||||||
use crate::audio::device::{AudioDevice, AudioDeviceError};
|
|
||||||
use crate::audio::{Audio, AudioGenerator, AudioSpec, NUM_CHANNELS};
|
|
||||||
|
|
||||||
pub enum AudioCommand {
|
pub enum AudioCommand {
|
||||||
StopChannel(usize),
|
StopChannel(usize),
|
||||||
|
|
|
@ -131,11 +131,10 @@
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::device::AudioDeviceError;
|
use crate::audio::AudioDeviceError;
|
||||||
use crate::events::{EventListeners, EventPublisher};
|
use crate::events::{EventListeners, EventPublisher};
|
||||||
use crate::states::{AppState, StateError, States};
|
use crate::states::{AppState, StateError, States};
|
||||||
use crate::system::res::SystemResources;
|
use crate::system::{System, SystemError, SystemResources};
|
||||||
use crate::system::{System, SystemError};
|
|
||||||
|
|
||||||
pub trait CoreState<SystemResType>
|
pub trait CoreState<SystemResType>
|
||||||
where
|
where
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::graphics::bitmap::Bitmap;
|
use crate::graphics::{Bitmap, Pixel};
|
||||||
use crate::graphics::Pixel;
|
use crate::math::Rect;
|
||||||
use crate::math::rect::Rect;
|
|
||||||
|
|
||||||
/// Clips the region for a source bitmap to be used in a subsequent blit operation. The source
|
/// Clips the region for a source bitmap to be used in a subsequent blit operation. The source
|
||||||
/// region will be clipped against the clipping region given for the destination bitmap. The
|
/// region will be clipped against the clipping region given for the destination bitmap. The
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
//!
|
//!
|
||||||
//! Only a subset of the most common Bitmap drawing operations will be provided here.
|
//! Only a subset of the most common Bitmap drawing operations will be provided here.
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::{IndexedBitmap, IndexedBlitMethod};
|
use crate::graphics::{
|
||||||
use crate::graphics::bitmap::rgb::{RgbaBitmap, RgbaBlitMethod};
|
BitmapError, Font, FontRenderOpts, IndexedBitmap, IndexedBlitMethod, Pixel, RgbaBitmap, RgbaBlitMethod,
|
||||||
use crate::graphics::bitmap::BitmapError;
|
};
|
||||||
use crate::graphics::font::{Font, FontRenderOpts};
|
use crate::math::Rect;
|
||||||
use crate::graphics::Pixel;
|
|
||||||
use crate::math::rect::Rect;
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum GeneralBlitMethod<PixelType: Pixel> {
|
pub enum GeneralBlitMethod<PixelType: Pixel> {
|
||||||
|
|
|
@ -5,10 +5,8 @@ use std::path::Path;
|
||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{IndexedBitmap, Palette, PaletteError, PaletteFormat, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::utils::{lzw_decode, lzw_encode, LzwError};
|
||||||
use crate::graphics::palette::{Palette, PaletteError, PaletteFormat};
|
|
||||||
use crate::utils::lzwgif::{lzw_decode, lzw_encode, LzwError};
|
|
||||||
|
|
||||||
const BITS_FOR_256_COLORS: u32 = 7; // formula is `2 ^ (bits + 1) = num_colors`
|
const BITS_FOR_256_COLORS: u32 = 7; // formula is `2 ^ (bits + 1) = num_colors`
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,8 @@ use std::path::Path;
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{IndexedBitmap, Palette, PaletteError, PaletteFormat, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::utils::{pack_bits, unpack_bits, PackBitsError};
|
||||||
use crate::graphics::palette::{Palette, PaletteError, PaletteFormat};
|
|
||||||
use crate::utils::packbits::{pack_bits, unpack_bits, PackBitsError};
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum IffError {
|
pub enum IffError {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::graphics::bitmap::blit::{clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit};
|
use crate::graphics::{
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit, BitmapAtlas, BlendMap, IndexedBitmap,
|
||||||
use crate::graphics::bitmapatlas::BitmapAtlas;
|
};
|
||||||
use crate::graphics::blendmap::BlendMap;
|
use crate::math::Rect;
|
||||||
use crate::math::rect::Rect;
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum IndexedBlitMethod {
|
pub enum IndexedBlitMethod {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::graphics::{Bitmap, BitmapError, Palette, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::{Bitmap, BitmapError};
|
|
||||||
use crate::graphics::palette::Palette;
|
|
||||||
|
|
||||||
mod blit;
|
mod blit;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{BlendMap, IndexedBitmap};
|
||||||
use crate::graphics::blendmap::BlendMap;
|
|
||||||
|
|
||||||
impl IndexedBitmap {
|
impl IndexedBitmap {
|
||||||
/// Sets the pixel at the given coordinates using a blended color via the specified blend map,
|
/// Sets the pixel at the given coordinates using a blended color via the specified blend map,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{edge_function, per_pixel_triangle_2d, BlendMap, IndexedBitmap};
|
||||||
use crate::graphics::bitmap::triangles::{edge_function, per_pixel_triangle_2d};
|
use crate::math::Vector2;
|
||||||
use crate::graphics::blendmap::BlendMap;
|
|
||||||
use crate::math::vector2::Vector2;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum IndexedTriangle2d<'a> {
|
pub enum IndexedTriangle2d<'a> {
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::Pixel;
|
use crate::graphics::Pixel;
|
||||||
use crate::math::rect::Rect;
|
use crate::math::Rect;
|
||||||
|
|
||||||
pub mod blit;
|
mod blit;
|
||||||
pub mod general;
|
mod general;
|
||||||
pub mod gif;
|
mod gif;
|
||||||
pub mod iff;
|
mod iff;
|
||||||
pub mod indexed;
|
mod indexed;
|
||||||
pub mod pcx;
|
mod pcx;
|
||||||
pub mod png;
|
mod png;
|
||||||
pub mod primitives;
|
mod primitives;
|
||||||
pub mod rgb;
|
mod rgb;
|
||||||
pub mod triangles;
|
mod triangles;
|
||||||
|
|
||||||
|
pub use blit::*;
|
||||||
|
pub use general::*;
|
||||||
|
pub use gif::*;
|
||||||
|
pub use iff::*;
|
||||||
|
pub use indexed::*;
|
||||||
|
pub use pcx::*;
|
||||||
|
pub use png::*;
|
||||||
|
pub use primitives::*;
|
||||||
|
pub use rgb::*;
|
||||||
|
pub use triangles::*;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum BitmapError {
|
pub enum BitmapError {
|
||||||
|
|
|
@ -5,11 +5,8 @@ use std::path::Path;
|
||||||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{from_rgb32, IndexedBitmap, Palette, PaletteError, PaletteFormat, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::utils::ReadFixedLengthByteArray;
|
||||||
use crate::graphics::color::from_rgb32;
|
|
||||||
use crate::graphics::palette::{Palette, PaletteError, PaletteFormat};
|
|
||||||
use crate::utils::bytes::ReadFixedLengthByteArray;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum PcxError {
|
pub enum PcxError {
|
||||||
|
|
|
@ -7,13 +7,11 @@ use std::path::Path;
|
||||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
from_argb32, from_rgb32, to_argb32, to_rgb32, Bitmap, IndexedBitmap, Palette, PaletteError, PaletteFormat, Pixel,
|
||||||
use crate::graphics::bitmap::Bitmap;
|
RgbaBitmap,
|
||||||
use crate::graphics::color::{from_argb32, from_rgb32, to_argb32, to_rgb32};
|
};
|
||||||
use crate::graphics::palette::{Palette, PaletteError, PaletteFormat};
|
use crate::utils::ReadFixedLengthByteArray;
|
||||||
use crate::graphics::Pixel;
|
|
||||||
use crate::utils::bytes::ReadFixedLengthByteArray;
|
|
||||||
|
|
||||||
const PNG_HEADER: [u8; 8] = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
const PNG_HEADER: [u8; 8] = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
|
|
||||||
use crate::graphics::bitmap::Bitmap;
|
use crate::graphics::{Bitmap, Character, Font, FontRenderOpts, Pixel};
|
||||||
use crate::graphics::font::{Character, Font, FontRenderOpts};
|
use crate::math::{lerp, Rect};
|
||||||
use crate::graphics::Pixel;
|
|
||||||
use crate::math::lerp;
|
|
||||||
use crate::math::rect::Rect;
|
|
||||||
|
|
||||||
impl<PixelType: Pixel> Bitmap<PixelType> {
|
impl<PixelType: Pixel> Bitmap<PixelType> {
|
||||||
/// Fills the entire bitmap with the given color.
|
/// Fills the entire bitmap with the given color.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::graphics::bitmap::blit::{clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit};
|
use crate::graphics::{
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
clip_blit, per_pixel_blit, per_pixel_flipped_blit, per_pixel_rotozoom_blit, tint_argb32, BitmapAtlas,
|
||||||
use crate::graphics::bitmapatlas::BitmapAtlas;
|
BlendFunction, RgbaBitmap,
|
||||||
use crate::graphics::color::{tint_argb32, BlendFunction};
|
};
|
||||||
use crate::math::rect::Rect;
|
use crate::math::Rect;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum RgbaBlitMethod {
|
pub enum RgbaBlitMethod {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use byteorder::ReadBytesExt;
|
use byteorder::ReadBytesExt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::graphics::bitmap::{Bitmap, BitmapError};
|
use crate::graphics::{to_argb32, to_rgb32, Bitmap, BitmapError, Palette};
|
||||||
use crate::graphics::color::{to_argb32, to_rgb32};
|
|
||||||
use crate::graphics::palette::Palette;
|
|
||||||
|
|
||||||
mod blit;
|
mod blit;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::graphics::{BlendFunction, RgbaBitmap};
|
||||||
use crate::graphics::color::BlendFunction;
|
|
||||||
|
|
||||||
impl RgbaBitmap {
|
impl RgbaBitmap {
|
||||||
/// Sets the pixel at the given coordinates using a blended color via the specified blend function
|
/// Sets the pixel at the given coordinates using a blended color via the specified blend function
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::graphics::{
|
||||||
use crate::graphics::bitmap::triangles::{edge_function, per_pixel_triangle_2d};
|
edge_function, from_argb32, from_rgb32, multiply_argb32, per_pixel_triangle_2d, tint_argb32, to_argb32, to_rgb32,
|
||||||
use crate::graphics::color::{
|
BlendFunction, RgbaBitmap,
|
||||||
from_argb32, from_rgb32, multiply_argb32, tint_argb32, to_argb32, to_rgb32, BlendFunction,
|
|
||||||
};
|
};
|
||||||
use crate::math::vector2::Vector2;
|
use crate::math::Vector2;
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub enum RgbaTriangle2d<'a> {
|
pub enum RgbaTriangle2d<'a> {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
use crate::graphics::bitmap::Bitmap;
|
use crate::graphics::{Bitmap, Pixel};
|
||||||
use crate::graphics::Pixel;
|
use crate::math::{NearlyEqual, Rect, Vector2};
|
||||||
use crate::math::rect::Rect;
|
|
||||||
use crate::math::vector2::Vector2;
|
|
||||||
use crate::math::NearlyEqual;
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn edge_function(a: Vector2, b: Vector2, c: Vector2) -> f32 {
|
pub fn edge_function(a: Vector2, b: Vector2, c: Vector2) -> f32 {
|
||||||
|
|
|
@ -2,8 +2,8 @@ use std::ops::Index;
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::general::GeneralBitmap;
|
use crate::graphics::GeneralBitmap;
|
||||||
use crate::math::rect::Rect;
|
use crate::math::Rect;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum BitmapAtlasError {
|
pub enum BitmapAtlasError {
|
||||||
|
@ -136,7 +136,7 @@ where
|
||||||
mod tests {
|
mod tests {
|
||||||
use claim::*;
|
use claim::*;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::IndexedBitmap;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ use std::path::Path;
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::color::{from_rgb32, luminance};
|
use crate::graphics::{from_rgb32, luminance, Palette};
|
||||||
use crate::graphics::palette::Palette;
|
|
||||||
use crate::math::lerp;
|
use crate::math::lerp;
|
||||||
use crate::utils::bytes::ReadFixedLengthByteArray;
|
use crate::utils::ReadFixedLengthByteArray;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum BlendMapError {
|
pub enum BlendMapError {
|
||||||
|
|
|
@ -5,9 +5,8 @@ use std::path::Path;
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::Bitmap;
|
use crate::graphics::{Bitmap, Pixel};
|
||||||
use crate::graphics::Pixel;
|
use crate::math::Rect;
|
||||||
use crate::math::rect::Rect;
|
|
||||||
|
|
||||||
pub static VGA_FONT_BYTES: &[u8] = include_bytes!("../../assets/vga.fnt");
|
pub static VGA_FONT_BYTES: &[u8] = include_bytes!("../../assets/vga.fnt");
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
use num_traits::{PrimInt, Unsigned};
|
use num_traits::{PrimInt, Unsigned};
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
pub mod bitmap;
|
mod bitmap;
|
||||||
pub mod bitmapatlas;
|
mod bitmapatlas;
|
||||||
pub mod blendmap;
|
mod blendmap;
|
||||||
pub mod color;
|
mod color;
|
||||||
pub mod font;
|
mod font;
|
||||||
pub mod palette;
|
mod palette;
|
||||||
|
|
||||||
|
pub use bitmap::*;
|
||||||
|
pub use bitmapatlas::*;
|
||||||
|
pub use blendmap::*;
|
||||||
|
pub use color::*;
|
||||||
|
pub use font::*;
|
||||||
|
pub use palette::*;
|
||||||
|
|
||||||
/// Common trait to represent single pixel/colour values.
|
/// Common trait to represent single pixel/colour values.
|
||||||
pub trait Pixel: PrimInt + Unsigned + Default + Display {}
|
pub trait Pixel: PrimInt + Unsigned + Default + Display {}
|
||||||
|
|
|
@ -7,8 +7,7 @@ use std::path::Path;
|
||||||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{from_rgb32, lerp_rgb32, to_argb32, to_rgb32, IndexedBitmap};
|
||||||
use crate::graphics::color::{from_rgb32, lerp_rgb32, to_argb32, to_rgb32};
|
|
||||||
use crate::utils::abs_diff;
|
use crate::utils::abs_diff;
|
||||||
|
|
||||||
const NUM_COLORS: usize = 256;
|
const NUM_COLORS: usize = 256;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::math::vector2::Vector2;
|
use crate::math::{distance_between, distance_squared_between, Vector2};
|
||||||
use crate::math::{distance_between, distance_squared_between};
|
|
||||||
|
|
||||||
/// Represents a 2D circle, using integer center coordinates and radius.
|
/// Represents a 2D circle, using integer center coordinates and radius.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::ops::{Mul, MulAssign};
|
use std::ops::{Mul, MulAssign};
|
||||||
|
|
||||||
use crate::math::nearly_equal;
|
use crate::math::{nearly_equal, Vector2};
|
||||||
use crate::math::vector2::Vector2;
|
|
||||||
|
|
||||||
/// Represents a 3x3 column-major matrix and provides common methods for matrix math.
|
/// Represents a 3x3 column-major matrix and provides common methods for matrix math.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
use std::ops::{Add, Div, Mul, Sub};
|
use std::ops::{Add, Div, Mul, Sub};
|
||||||
|
|
||||||
pub mod circle;
|
mod circle;
|
||||||
pub mod matrix3x3;
|
mod matrix3x3;
|
||||||
pub mod rect;
|
mod rect;
|
||||||
pub mod vector2;
|
mod vector2;
|
||||||
|
|
||||||
|
pub use circle::*;
|
||||||
|
pub use matrix3x3::*;
|
||||||
|
pub use rect::*;
|
||||||
|
pub use vector2::*;
|
||||||
|
|
||||||
pub const PI: f32 = std::f32::consts::PI;
|
pub const PI: f32 = std::f32::consts::PI;
|
||||||
// 180 degrees
|
// 180 degrees
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||||
|
|
||||||
use crate::math::matrix3x3::Matrix3x3;
|
use crate::math::{angle_between, angle_to_direction, nearly_equal, Matrix3x3, NearlyEqual};
|
||||||
use crate::math::{angle_between, angle_to_direction, nearly_equal, NearlyEqual};
|
|
||||||
|
|
||||||
/// Represents a 2D vector and provides common methods for vector math.
|
/// Represents a 2D vector and provides common methods for vector math.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
|
|
|
@ -1,52 +1,9 @@
|
||||||
pub use crate::{
|
pub use crate::audio::*;
|
||||||
//
|
pub use crate::base::*;
|
||||||
audio::{
|
pub use crate::entities::*;
|
||||||
buffer::{wav::*, *},
|
pub use crate::events::*;
|
||||||
device::*,
|
pub use crate::graphics::*;
|
||||||
queue::*,
|
pub use crate::math::*;
|
||||||
*,
|
pub use crate::states::*;
|
||||||
},
|
pub use crate::system::*;
|
||||||
base::*,
|
pub use crate::utils::*;
|
||||||
entities::*,
|
|
||||||
events::*,
|
|
||||||
graphics::{
|
|
||||||
//
|
|
||||||
bitmap::{
|
|
||||||
blit::*, general::*, gif::*, iff::*, indexed::*, pcx::*, png::*, primitives::*, rgb::*, triangles::*, *,
|
|
||||||
},
|
|
||||||
bitmapatlas::*,
|
|
||||||
blendmap::*,
|
|
||||||
color::*,
|
|
||||||
font::*,
|
|
||||||
palette::*,
|
|
||||||
*,
|
|
||||||
},
|
|
||||||
math::{
|
|
||||||
//
|
|
||||||
circle::*,
|
|
||||||
matrix3x3::*,
|
|
||||||
rect::*,
|
|
||||||
vector2::*,
|
|
||||||
*,
|
|
||||||
},
|
|
||||||
states::*,
|
|
||||||
system::{
|
|
||||||
event::*, //
|
|
||||||
input_devices::{
|
|
||||||
keyboard::{codes::*, scancodes::*, *},
|
|
||||||
mouse::{buttons::*, cursor::*, *},
|
|
||||||
*,
|
|
||||||
},
|
|
||||||
res::{dos_like::*, standard::*, *},
|
|
||||||
*,
|
|
||||||
},
|
|
||||||
utils::{
|
|
||||||
//
|
|
||||||
bytes::*,
|
|
||||||
io::*,
|
|
||||||
lzwgif::*,
|
|
||||||
packbits::*,
|
|
||||||
*,
|
|
||||||
},
|
|
||||||
*,
|
|
||||||
};
|
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
|
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
||||||
use crate::system::input_devices::keyboard::codes::Keycode;
|
use crate::system::{Keycode, MouseButton, MouseButtons, Scancode};
|
||||||
use crate::system::input_devices::keyboard::scancodes::Scancode;
|
|
||||||
use crate::system::input_devices::mouse::buttons::{MouseButton, MouseButtons};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
|
||||||
pub enum WindowEvent {
|
pub enum WindowEvent {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
use byte_slice_cast::AsByteSlice;
|
use byte_slice_cast::AsByteSlice;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::graphics::{IndexedBitmap, Palette, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
|
||||||
use crate::graphics::palette::Palette;
|
|
||||||
|
|
||||||
pub fn calculate_logical_screen_size(window_width: u32, window_height: u32, scale_factor: u32) -> (u32, u32) {
|
pub fn calculate_logical_screen_size(window_width: u32, window_height: u32, scale_factor: u32) -> (u32, u32) {
|
||||||
let logical_width = (window_width as f32 / scale_factor as f32).ceil() as u32;
|
let logical_width = (window_width as f32 / scale_factor as f32).ceil() as u32;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use crate::system::event::{KeyboardEvent, SystemEvent, SystemEventHandler};
|
use crate::system::{ButtonState, InputDevice, KeyboardEvent, SystemEvent, SystemEventHandler};
|
||||||
use crate::system::input_devices::keyboard::scancodes::Scancode;
|
|
||||||
use crate::system::input_devices::{ButtonState, InputDevice};
|
|
||||||
|
|
||||||
pub mod codes;
|
mod codes;
|
||||||
pub mod scancodes;
|
mod scancodes;
|
||||||
|
|
||||||
|
pub use codes::*;
|
||||||
|
pub use scancodes::*;
|
||||||
|
|
||||||
const MAX_KEYS: usize = 512;
|
const MAX_KEYS: usize = 512;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
pub mod keyboard;
|
mod keyboard;
|
||||||
pub mod mouse;
|
mod mouse;
|
||||||
|
|
||||||
|
pub use keyboard::*;
|
||||||
|
pub use mouse::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||||
pub enum ButtonState {
|
pub enum ButtonState {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use crate::graphics::bitmap::general::{GeneralBitmap, GeneralBlitMethod};
|
use crate::graphics::{GeneralBitmap, GeneralBlitMethod, IndexedBitmap, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
use crate::math::Rect;
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
use crate::system::Mouse;
|
||||||
use crate::math::rect::Rect;
|
|
||||||
use crate::system::input_devices::mouse::Mouse;
|
|
||||||
|
|
||||||
const DEFAULT_MOUSE_CURSOR_HOTSPOT_X: u32 = 0;
|
const DEFAULT_MOUSE_CURSOR_HOTSPOT_X: u32 = 0;
|
||||||
const DEFAULT_MOUSE_CURSOR_HOTSPOT_Y: u32 = 0;
|
const DEFAULT_MOUSE_CURSOR_HOTSPOT_Y: u32 = 0;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use crate::system::event::{MouseEvent, SystemEvent, SystemEventHandler};
|
use crate::system::{ButtonState, InputDevice, MouseEvent, SystemEvent, SystemEventHandler};
|
||||||
use crate::system::input_devices::mouse::buttons::{MouseButton, MouseButtons};
|
|
||||||
use crate::system::input_devices::{ButtonState, InputDevice};
|
|
||||||
|
|
||||||
pub mod buttons;
|
mod buttons;
|
||||||
pub mod cursor;
|
mod cursor;
|
||||||
|
|
||||||
|
pub use buttons::*;
|
||||||
|
pub use cursor::*;
|
||||||
|
|
||||||
const MAX_BUTTONS: usize = 32;
|
const MAX_BUTTONS: usize = 32;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::AudioError;
|
use crate::audio::AudioError;
|
||||||
use crate::system::event::{SystemEvent, SystemEventPump};
|
|
||||||
use crate::system::res::{SystemResources, SystemResourcesConfig, SystemResourcesError};
|
|
||||||
|
|
||||||
pub mod event;
|
|
||||||
pub mod input_devices;
|
|
||||||
pub mod res;
|
|
||||||
|
|
||||||
|
mod event;
|
||||||
mod framebuffer;
|
mod framebuffer;
|
||||||
|
mod input_devices;
|
||||||
|
mod res;
|
||||||
|
|
||||||
|
pub use event::*;
|
||||||
|
pub use input_devices::*;
|
||||||
|
pub use res::*;
|
||||||
|
|
||||||
fn is_x11_compositor_skipping_problematic() -> bool {
|
fn is_x11_compositor_skipping_problematic() -> bool {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -26,18 +26,13 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::audio::queue::AudioQueue;
|
use crate::audio::{Audio, AudioQueue, TARGET_AUDIO_CHANNELS, TARGET_AUDIO_FREQUENCY};
|
||||||
use crate::audio::{Audio, TARGET_AUDIO_CHANNELS, TARGET_AUDIO_FREQUENCY};
|
use crate::graphics::{BitmaskFont, IndexedBitmap, Palette};
|
||||||
use crate::graphics::bitmap::indexed::IndexedBitmap;
|
|
||||||
use crate::graphics::font::BitmaskFont;
|
|
||||||
use crate::graphics::palette::Palette;
|
|
||||||
use crate::system::event::{SystemEvent, SystemEventHandler, WindowEvent};
|
|
||||||
use crate::system::framebuffer::{calculate_logical_screen_size, SdlFramebuffer};
|
use crate::system::framebuffer::{calculate_logical_screen_size, SdlFramebuffer};
|
||||||
use crate::system::input_devices::keyboard::Keyboard;
|
use crate::system::{
|
||||||
use crate::system::input_devices::mouse::cursor::CustomMouseCursor;
|
CustomMouseCursor, InputDevice, Keyboard, Mouse, SystemEvent, SystemEventHandler, SystemResources,
|
||||||
use crate::system::input_devices::mouse::Mouse;
|
SystemResourcesConfig, SystemResourcesError, WindowEvent,
|
||||||
use crate::system::input_devices::InputDevice;
|
};
|
||||||
use crate::system::res::{SystemResources, SystemResourcesConfig, SystemResourcesError};
|
|
||||||
|
|
||||||
const DEFAULT_SCREEN_WIDTH: u32 = 320;
|
const DEFAULT_SCREEN_WIDTH: u32 = 320;
|
||||||
const DEFAULT_SCREEN_HEIGHT: u32 = 240;
|
const DEFAULT_SCREEN_HEIGHT: u32 = 240;
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::audio::device::AudioDeviceError;
|
use crate::audio::{AudioDeviceError, AudioError};
|
||||||
use crate::audio::AudioError;
|
|
||||||
use crate::graphics::Pixel;
|
use crate::graphics::Pixel;
|
||||||
use crate::system::event::SystemEvent;
|
|
||||||
use crate::system::framebuffer::SdlFramebufferError;
|
use crate::system::framebuffer::SdlFramebufferError;
|
||||||
|
use crate::system::SystemEvent;
|
||||||
|
|
||||||
pub mod dos_like;
|
mod dos_like;
|
||||||
pub mod standard;
|
mod standard;
|
||||||
|
|
||||||
|
pub use dos_like::*;
|
||||||
|
pub use standard::*;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum SystemResourcesError {
|
pub enum SystemResourcesError {
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
use crate::audio::queue::AudioQueue;
|
use crate::audio::{Audio, AudioQueue, TARGET_AUDIO_CHANNELS, TARGET_AUDIO_FREQUENCY};
|
||||||
use crate::audio::{Audio, TARGET_AUDIO_CHANNELS, TARGET_AUDIO_FREQUENCY};
|
use crate::graphics::{BitmaskFont, RgbaBitmap};
|
||||||
use crate::graphics::bitmap::rgb::RgbaBitmap;
|
|
||||||
use crate::graphics::font::BitmaskFont;
|
|
||||||
use crate::system::event::{SystemEvent, SystemEventHandler, WindowEvent};
|
|
||||||
use crate::system::framebuffer::{calculate_logical_screen_size, SdlFramebuffer};
|
use crate::system::framebuffer::{calculate_logical_screen_size, SdlFramebuffer};
|
||||||
use crate::system::input_devices::keyboard::Keyboard;
|
use crate::system::{
|
||||||
use crate::system::input_devices::mouse::cursor::CustomMouseCursor;
|
CustomMouseCursor, InputDevice, Keyboard, Mouse, SystemEvent, SystemEventHandler, SystemResources,
|
||||||
use crate::system::input_devices::mouse::Mouse;
|
SystemResourcesConfig, SystemResourcesError, WindowEvent,
|
||||||
use crate::system::input_devices::InputDevice;
|
};
|
||||||
use crate::system::res::{SystemResources, SystemResourcesConfig, SystemResourcesError};
|
|
||||||
|
|
||||||
const DEFAULT_SCREEN_WIDTH: u32 = 320;
|
const DEFAULT_SCREEN_WIDTH: u32 = 320;
|
||||||
const DEFAULT_SCREEN_HEIGHT: u32 = 240;
|
const DEFAULT_SCREEN_HEIGHT: u32 = 240;
|
||||||
|
|
|
@ -4,10 +4,15 @@ use num_traits::Unsigned;
|
||||||
use rand::distributions::uniform::SampleUniform;
|
use rand::distributions::uniform::SampleUniform;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
pub mod bytes;
|
mod bytes;
|
||||||
pub mod io;
|
mod io;
|
||||||
pub mod lzwgif;
|
mod lzwgif;
|
||||||
pub mod packbits;
|
mod packbits;
|
||||||
|
|
||||||
|
pub use bytes::*;
|
||||||
|
pub use io::*;
|
||||||
|
pub use lzwgif::*;
|
||||||
|
pub use packbits::*;
|
||||||
|
|
||||||
pub fn rnd_value<N: SampleUniform + PartialOrd>(low: N, high: N) -> N {
|
pub fn rnd_value<N: SampleUniform + PartialOrd>(low: N, high: N) -> N {
|
||||||
rand::thread_rng().gen_range(low..=high)
|
rand::thread_rng().gen_range(low..=high)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
use ggdt::graphics::RgbaBitmap;
|
||||||
|
use ggdt::system::{SystemEvent, SystemEventHandler};
|
||||||
|
|
||||||
use crate::platform::Platform;
|
use crate::platform::Platform;
|
||||||
use crate::renderer::Renderer;
|
use crate::renderer::Renderer;
|
||||||
use ggdt::graphics::bitmap::rgb::RgbaBitmap;
|
|
||||||
use ggdt::system::event::{SystemEvent, SystemEventHandler};
|
|
||||||
|
|
||||||
pub mod platform;
|
mod platform;
|
||||||
pub mod renderer;
|
mod renderer;
|
||||||
|
|
||||||
|
pub use platform::*;
|
||||||
|
pub use renderer::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ImGui {
|
pub struct ImGui {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use ggdt::graphics::bitmap::rgb::RgbaBitmap;
|
|
||||||
use ggdt::system::event::{KeyModifiers, KeyboardEvent, MouseEvent, SystemEvent};
|
|
||||||
use ggdt::system::input_devices::keyboard::scancodes::Scancode;
|
|
||||||
use ggdt::system::input_devices::mouse::buttons::MouseButton;
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use ggdt::graphics::RgbaBitmap;
|
||||||
|
use ggdt::system::{KeyModifiers, KeyboardEvent, MouseButton, MouseEvent, Scancode, SystemEvent};
|
||||||
|
|
||||||
fn handle_key(io: &mut imgui::Io, key: Scancode, down: bool) {
|
fn handle_key(io: &mut imgui::Io, key: Scancode, down: bool) {
|
||||||
let key = match key {
|
let key = match key {
|
||||||
Scancode::A => imgui::Key::A,
|
Scancode::A => imgui::Key::A,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use ggdt::graphics::bitmap::rgb::{RgbaBitmap, RgbaPixelFormat};
|
use ggdt::graphics::{to_argb32, BlendFunction, RgbaBitmap, RgbaPixelFormat};
|
||||||
use ggdt::graphics::color::{to_argb32, BlendFunction};
|
use ggdt::math::{Rect, Vector2};
|
||||||
use ggdt::math::rect::Rect;
|
|
||||||
use ggdt::math::vector2::Vector2;
|
|
||||||
use imgui::internal::RawWrapper;
|
use imgui::internal::RawWrapper;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Reference in a new issue