moved indexed (256 colour) graphics stuff into new "indexed" module
in preparation for adding 32-bit graphics stuff, i want to keep things separate using modules
This commit is contained in:
parent
7896146914
commit
aab19ba6b3
|
@ -3,7 +3,7 @@ use std::path::Path;
|
|||
use anyhow::Result;
|
||||
|
||||
use ggdt::audio::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::system::*;
|
||||
use ggdt::utils::rnd_value;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::path::Path;
|
|||
use anyhow::Result;
|
||||
|
||||
use ggdt::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::system::*;
|
||||
use ggdt::utils::*;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use ggdt::*;
|
||||
use ggdt::entities::*;
|
||||
use ggdt::events::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::utils::*;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use ggdt::entities::*;
|
||||
use ggdt::events::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::states::*;
|
||||
use ggdt::system::*;
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::path::Path;
|
|||
use std::rc::Rc;
|
||||
|
||||
use ggdt::entities::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::utils::rnd_value;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use anyhow::{Context, Result};
|
|||
use ggdt::base::*;
|
||||
use ggdt::entities::*;
|
||||
use ggdt::events::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::system::*;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
|
||||
use ggdt::base::*;
|
||||
use ggdt::entities::*;
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::states::*;
|
||||
use ggdt::system::*;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::states::*;
|
||||
|
||||
use crate::{Game, TILE_HEIGHT, TILE_WIDTH};
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
|||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
use ggdt::utils::rnd_value;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use ggdt::{SCREEN_BOTTOM, SCREEN_RIGHT};
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::system::*;
|
||||
use ggdt::utils::rnd_value;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||
|
||||
use ggdt::{SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut source = Bitmap::new(SCREEN_WIDTH, SCREEN_HEIGHT).unwrap();
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
|
||||
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
use ggdt::math::*;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::io::Cursor;
|
|||
|
||||
use criterion::{black_box, Criterion, criterion_group, criterion_main};
|
||||
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
|
||||
pub static SMALL_GIF_FILE_BYTES: &[u8] = include_bytes!("../test-assets/test.gif");
|
||||
pub static LARGE_GIF_FILE_BYTES: &[u8] = include_bytes!("../test-assets/test_image.gif");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
|||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::utils::lzwgif::*;
|
||||
|
||||
const BITS_FOR_256_COLORS: u32 = 7; // formula is `2 ^ (bits + 1) = num_colors`
|
||||
|
@ -556,9 +556,9 @@ pub mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
|
||||
#[test]
|
||||
fn load_and_save() -> Result<(), GifError> {
|
|
@ -6,7 +6,7 @@ use std::path::Path;
|
|||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::utils::packbits::*;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -564,9 +564,9 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
|
||||
#[test]
|
||||
pub fn load_and_save() -> Result<(), IffError> {
|
|
@ -4,7 +4,7 @@ use std::slice;
|
|||
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
pub use self::blit::*;
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
|||
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::utils::bytes::ReadFixedLengthByteArray;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
|
@ -284,9 +284,9 @@ pub mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
pub static TEST_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw.bin");
|
||||
pub static TEST_LARGE_BMP_PIXELS_RAW_2: &[u8] = include_bytes!("../../../../test-assets/test_large_bmp_pixels_raw2.bin");
|
||||
|
||||
#[test]
|
||||
pub fn load_and_save() -> Result<(), PcxError> {
|
|
@ -1,6 +1,6 @@
|
|||
use std::mem::swap;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
impl Bitmap {
|
|
@ -2,7 +2,7 @@ use std::ops::Index;
|
|||
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
#[derive(Error, Debug)]
|
|
@ -6,7 +6,7 @@ use std::path::Path;
|
|||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
use crate::utils::bytes::ReadFixedLengthByteArray;
|
||||
|
|
@ -6,10 +6,10 @@ use std::path::Path;
|
|||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
pub static VGA_FONT_BYTES: &[u8] = include_bytes!("../../assets/vga.fnt");
|
||||
pub static VGA_FONT_BYTES: &[u8] = include_bytes!("../../../assets/vga.fnt");
|
||||
|
||||
pub const NUM_CHARS: usize = 256;
|
||||
pub const CHAR_HEIGHT: usize = 8;
|
11
ggdt/src/graphics/indexed/mod.rs
Normal file
11
ggdt/src/graphics/indexed/mod.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
pub use self::bitmap::*;
|
||||
pub use self::bitmapatlas::*;
|
||||
pub use self::blendmap::*;
|
||||
pub use self::font::*;
|
||||
pub use self::palette::*;
|
||||
|
||||
pub mod bitmap;
|
||||
pub mod bitmapatlas;
|
||||
pub mod blendmap;
|
||||
pub mod font;
|
||||
pub mod palette;
|
|
@ -7,7 +7,7 @@ use std::path::Path;
|
|||
use byteorder::{ReadBytesExt, WriteBytesExt};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::NUM_COLORS;
|
||||
use crate::utils::abs_diff;
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub trait ColorRange: RangeBounds<u8> + Iterator<Item=u8> {}
|
|||
|
||||
impl<T> ColorRange for T where T: RangeBounds<u8> + Iterator<Item=u8> {}
|
||||
|
||||
pub static VGA_PALETTE_BYTES: &[u8] = include_bytes!("../../assets/vga.pal");
|
||||
pub static VGA_PALETTE_BYTES: &[u8] = include_bytes!("../../../assets/vga.pal");
|
||||
|
||||
/// Converts a set of individual ARGB components to a combined 32-bit color value, packed into
|
||||
/// the format 0xAARRGGBB
|
|
@ -1,12 +1,2 @@
|
|||
pub use self::bitmap::*;
|
||||
pub use self::bitmapatlas::*;
|
||||
pub use self::blendmap::*;
|
||||
pub use self::font::*;
|
||||
pub use self::palette::*;
|
||||
|
||||
pub mod bitmap;
|
||||
pub mod bitmapatlas;
|
||||
pub mod blendmap;
|
||||
pub mod font;
|
||||
pub mod palette;
|
||||
pub mod indexed;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// that are not specific to just our 256 colour Bitmap functionality. whether this takes the form
|
||||
// of a generified CustomMouseCursor struct, or multiple versions ... well, i'm not quite sure yet!
|
||||
|
||||
use crate::graphics::*;
|
||||
use crate::graphics::indexed::*;
|
||||
use crate::math::*;
|
||||
|
||||
use super::*;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::graphics::*;
|
||||
use crate::math::*;
|
||||
use crate::system::MouseEvent;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use thiserror::Error;
|
|||
|
||||
use crate::{DEFAULT_SCALE_FACTOR, SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
use crate::audio::*;
|
||||
use crate::graphics::*;
|
||||
|
||||
pub use self::event::*;
|
||||
pub use self::input_devices::*;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//! instance to provide something resembling an old DOS VGA mode 13h style experience (there are differences, however).
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use ggdt::graphics::*;
|
||||
//! use ggdt::graphics::indexed::*;
|
||||
//! use ggdt::system::*;
|
||||
//!
|
||||
//! let config = DosLikeConfig::new();
|
||||
|
@ -30,6 +30,7 @@
|
|||
use sdl2::video::Window;
|
||||
|
||||
use crate::system::*;
|
||||
use crate::graphics::indexed::*;
|
||||
|
||||
/// Configuration / builder for configuring and constructing an instance of [`DosLike`].
|
||||
pub struct DosLikeConfig {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
use std::rc::Rc;
|
||||
|
||||
use ggdt::{SCREEN_HEIGHT, SCREEN_WIDTH};
|
||||
use ggdt::graphics::*;
|
||||
use ggdt::graphics::indexed::*;
|
||||
|
||||
fn setup() -> (Bitmap, Palette) {
|
||||
let palette = Palette::new_vga_palette().unwrap();
|
||||
|
|
Loading…
Reference in a new issue