Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
7f8aeafe
Verified
Commit
7f8aeafe
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
feat: support for embeded icon
parent
93f706fa
No related branches found
No related tags found
No related merge requests found
Pipeline
#964
passed
2 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/sdl/res/icon.png
+0
-0
0 additions, 0 deletions
examples/sdl/res/icon.png
examples/sdl/src/data.rs
+591
-0
591 additions, 0 deletions
examples/sdl/src/data.rs
examples/sdl/src/main.rs
+15
-4
15 additions, 4 deletions
examples/sdl/src/main.rs
with
606 additions
and
4 deletions
examples/sdl/res/icon.png
deleted
100644 → 0
+
0
−
0
View file @
93f706fa
12.2 KiB
This diff is collapsed.
Click to expand it.
examples/sdl/src/data.rs
0 → 100644
+
591
−
0
View file @
7f8aeafe
This diff is collapsed.
Click to expand it.
examples/sdl/src/main.rs
+
15
−
4
View file @
7f8aeafe
...
...
@@ -2,12 +2,16 @@ use boytacean::{
gb
::
GameBoy
,
pad
::
PadKey
,
ppu
::{
DISPLAY_HEIGHT
,
DISPLAY_WIDTH
},
util
::
read_file
,
};
use
sdl2
::{
event
::
Event
,
image
::
LoadSurface
,
keyboard
::
Keycode
,
pixels
::
PixelFormatEnum
,
surface
::
Surface
,
video
::
Window
,
AudioSubsystem
,
EventPump
,
TimerSubsystem
,
VideoSubsystem
,
event
::
Event
,
image
::
LoadSurface
,
keyboard
::
Keycode
,
pixels
::
PixelFormatEnum
,
rwops
::
RWops
,
surface
::
Surface
,
sys
::
image
,
video
::
Window
,
AudioSubsystem
,
EventPump
,
TimerSubsystem
,
VideoSubsystem
,
};
pub
mod
data
;
/// The base title to be used in the window.
static
TITLE
:
&
'static
str
=
"Boytacean"
;
...
...
@@ -55,13 +59,20 @@ fn start_sdl() -> Graphics {
}
}
pub
fn
surface_from_bytes
(
bytes
:
&
[
u8
])
->
Surface
{
unsafe
{
let
rw_ops
=
RWops
::
from_bytes
(
bytes
)
.unwrap
();
let
raw_surface
=
image
::
IMG_Load_RW
(
rw_ops
.raw
(),
0
);
Surface
::
from_ll
(
raw_surface
)
}
}
fn
main
()
{
let
mut
graphics
=
start_sdl
();
// updates the icon of the window to reflect the image
// and style of the emulator
let
surface
=
Surface
::
from_file
(
"./res/icon.png"
)
.unwrap
();
graphics
.window
.set_icon
(
&
surface
);
graphics
.window
.set_icon
(
surface_from_bytes
(
&
data
::
ICON
));
let
mut
canvas
=
graphics
.window
.into_canvas
()
.accelerated
()
.build
()
.unwrap
();
canvas
.clear
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment