feat: Add temporary project icon

Former-commit-id: 05da47f328f076045f4b27f521c72e03648ede77
This commit is contained in:
Michel Heily 2020-01-12 01:29:36 +02:00
parent 4a73d80ace
commit 49a3bc6fd0
5 changed files with 32 additions and 10 deletions

View file

@ -17,7 +17,7 @@ nom = "5.0.0"
colored = "1.8" colored = "1.8"
ansi_term = "0.11.0" ansi_term = "0.11.0"
hexdump = "0.1.0" hexdump = "0.1.0"
sdl2 = "0.32.2" sdl2 = {version = "0.32.2", features = ["image"]}
minifb = "0.11.2" minifb = "0.11.2"
time = "0.1.42" time = "0.1.42"
bitfield = "0.13.1" bitfield = "0.13.1"

View file

@ -2,6 +2,8 @@
[![Build Status](https://travis-ci.com/michelhe/rustboyadvance-ng.svg?branch=master)](https://travis-ci.com/michelhe/rustboyadvance-ng) [![Build Status](https://travis-ci.com/michelhe/rustboyadvance-ng.svg?branch=master)](https://travis-ci.com/michelhe/rustboyadvance-ng)
![icon ](assets/icon.png)
RustBoyAdvance-NG Nintendo GameBoy Advance emulator and debugger, written in the rust programming language. RustBoyAdvance-NG Nintendo GameBoy Advance emulator and debugger, written in the rust programming language.
Currently passing armwrestler tests, and displays some of TONC's Demos. Currently passing armwrestler tests, and displays some of TONC's Demos.

BIN
assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,6 +1,9 @@
extern crate sdl2; extern crate sdl2;
use sdl2::event::Event; use sdl2::event::Event;
use sdl2::image::{InitFlag, LoadTexture};
use sdl2::keyboard::Keycode; use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::EventPump; use sdl2::EventPump;
extern crate spin_sleep; extern crate spin_sleep;
@ -52,10 +55,11 @@ fn main() {
let debug = matches.occurrences_of("debug") != 0; let debug = matches.occurrences_of("debug") != 0;
let sdl_context = sdl2::init().unwrap(); let sdl_context = sdl2::init().expect("failed to initialize sdl2");
let mut event_pump = sdl_context.event_pump().unwrap(); let mut event_pump = sdl_context.event_pump().unwrap();
let video_subsystem = sdl_context.video().unwrap(); let video_subsystem = sdl_context.video().unwrap();
let _image_context = sdl2::image::init(InitFlag::PNG | InitFlag::JPG).unwrap();
let window = video_subsystem let window = video_subsystem
.window( .window(
"RustBoyAdvance", "RustBoyAdvance",
@ -66,7 +70,27 @@ fn main() {
.position_centered() .position_centered()
.build() .build()
.unwrap(); .unwrap();
let video = Rc::new(RefCell::new(create_video_interface(window))); let mut canvas = window.into_canvas().accelerated().build().unwrap();
// Display the icon as a placeholder
canvas.set_draw_color(Color::RGB(0x80, 0x75, 0x85)); // default background color for the icon
canvas.clear();
let texture_creator = canvas.texture_creator();
let icon_texture = texture_creator
.load_texture("assets/icon.png")
.expect("failed to load icon");
canvas
.copy(
&icon_texture,
None,
Some(Rect::new(0, 0, SCREEN_WIDTH * SCALE, SCREEN_HEIGHT * SCALE)),
)
.unwrap();
canvas.present();
// TODO also set window icon
let video = Rc::new(RefCell::new(create_video_interface(canvas)));
let audio = Rc::new(RefCell::new(create_audio_player(&sdl_context))); let audio = Rc::new(RefCell::new(create_audio_player(&sdl_context)));
let input = Rc::new(RefCell::new(create_input())); let input = Rc::new(RefCell::new(create_input()));

View file

@ -1,7 +1,7 @@
use sdl2::pixels::{Color, PixelFormatEnum}; use sdl2::pixels::PixelFormatEnum;
use sdl2::rect::Rect; use sdl2::rect::Rect;
use sdl2::render::{Texture, TextureCreator, WindowCanvas}; use sdl2::render::{Texture, TextureCreator, WindowCanvas};
use sdl2::video::{Window, WindowContext}; use sdl2::video::WindowContext;
use rustboyadvance_ng::core::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH}; use rustboyadvance_ng::core::gpu::{DISPLAY_HEIGHT, DISPLAY_WIDTH};
use rustboyadvance_ng::VideoInterface; use rustboyadvance_ng::VideoInterface;
@ -42,11 +42,7 @@ impl<'a> VideoInterface for Sdl2Video<'a> {
} }
} }
pub fn create_video_interface<'a>(window: Window) -> Sdl2Video<'a> { pub fn create_video_interface<'a>(canvas: WindowCanvas) -> Sdl2Video<'a> {
let mut canvas = window.into_canvas().accelerated().build().unwrap();
canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
canvas.present();
let mut tc = canvas.texture_creator(); let mut tc = canvas.texture_creator();
let texture = unsafe { let texture = unsafe {
let tc_ptr = &mut tc as *mut TextureCreator<WindowContext>; let tc_ptr = &mut tc as *mut TextureCreator<WindowContext>;