Skip to content
Snippets Groups Projects
Verified Commit b526f77b authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: support for icons

parent fe5dae3b
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,12 @@ path = "../.."
[dependencies.sdl2]
version = "0.34"
features = ["bundled", "static-link"]
features = ["bundled", "static-link", "image"]
[package.metadata.vcpkg]
dependencies = ["sdl2", "sdl2-image[libjpeg-turbo,tiff,libwebp]", "sdl2-ttf", "sdl2-gfx", "sdl2-mixer"]
git = "https://github.com/microsoft/vcpkg"
rev = "72fa4d4630c0971eadea7d0a70045351ab13be9d"
[profile.release]
debug = false
......
# Desktop CHIP-8 Emulator
Utilizes the [`jc-chip8`](../../jc-chip8/) crate and the [SDL crate](https://github.com/Rust-SDL2/rust-sdl2) to build a desktop application.
Utilizes the [`chip-ahoyto`](../../) crate and the [SDL crate](https://github.com/Rust-SDL2/rust-sdl2) to build a desktop application.
## Running
```bash
$ cargo run --release
cargo install cargo-vcpkg
cargo vcpkg build --release
cargo build --release
cargo run --release
```
Drag and drop your ROM to play.
......
use chip_ahoyto::chip8::{Chip8, SCREEN_PIXEL_HEIGHT, SCREEN_PIXEL_WIDTH};
use sdl2::{event::Event, keyboard::Keycode, pixels::PixelFormatEnum, surface::Surface};
use std::{fs::File, io::Read, path::Path};
use sdl2::{event::Event, keyboard::Keycode, pixels::PixelFormatEnum, surface::Surface, image::LoadSurface};
use std::{fs::File, io::Read};
const PIXEL_SET: [u8; 3] = [80, 203, 147];
const SYSTEM_HZ: u32 = 240;
......@@ -14,7 +14,7 @@ fn main() {
// creates the system window that is going to be used to
// show the emulator and sets it to the central are o screen
let window = video_subsystem
let mut window = video_subsystem
.window(
TITLE,
SCREEN_SCALE as u32 * SCREEN_PIXEL_WIDTH as u32,
......@@ -27,8 +27,7 @@ fn main() {
// updates the icon of the window to reflect the image
// and style of the emulator
let path = Path::new("./resources/icon.png");
let surface_ref = Surface::from_file(path);
let surface_ref = Surface::from_file("./resources/icon.png").unwrap();
window.set_icon(surface_ref);
let mut canvas = window.into_canvas().build().unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment