Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GMTK23
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
Service Desk
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
Noxim
GMTK23
Commits
ccb2b096
Commit
ccb2b096
authored
1 year ago
by
Noxim
Browse files
Options
Downloads
Patches
Plain Diff
Disable sRGB
parent
9f9f8303
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib.rs
+6
-25
6 additions, 25 deletions
src/lib.rs
src/sprite.rs
+0
-2
0 additions, 2 deletions
src/sprite.rs
src/state.rs
+25
-20
25 additions, 20 deletions
src/state.rs
with
31 additions
and
47 deletions
src/lib.rs
+
6
−
25
View file @
ccb2b096
...
...
@@ -73,17 +73,8 @@ pub async fn run() -> Result<()> {
}
else
{
TextureFormat
::
Rgba8Unorm
};
let
view_formats
=
if
adapter
.get_downlevel_capabilities
()
.flags
.contains
(
DownlevelFlags
::
SURFACE_VIEW_FORMATS
)
{
vec!
[
format
.add_srgb_suffix
()]
}
else
{
vec!
[]
};
debug!
(
"Using {format:?}
with sRGB: {}"
,
!
view_formats
.is_empty
()
);
debug!
(
"Using {format:?}
"
);
let
mut
reconfigure
=
true
;
let
mut
framebuffer
=
device
.create_texture
(
&
TextureDescriptor
{
...
...
@@ -125,7 +116,7 @@ pub async fn run() -> Result<()> {
height
,
present_mode
:
PresentMode
::
AutoNoVsync
,
alpha_mode
:
CompositeAlphaMode
::
Opaque
,
view_formats
:
v
iew_formats
.clone
()
,
view_formats
:
v
ec!
[]
,
},
);
...
...
@@ -141,7 +132,7 @@ pub async fn run() -> Result<()> {
dimension
:
framebuffer
.dimension
(),
format
:
framebuffer
.format
(),
usage
:
framebuffer
.usage
(),
view_formats
:
&
view_formats
,
view_formats
:
&
[]
,
});
depthbuffer
=
device
.create_texture
(
&
TextureDescriptor
{
...
...
@@ -178,16 +169,8 @@ pub async fn run() -> Result<()> {
});
{
let
fb_view
=
framebuffer
.create_view
(
&
TextureViewDescriptor
{
label
:
Some
(
"Antialias target"
),
format
:
view_formats
.get
(
0
)
.copied
(),
..
Default
::
default
()
});
let
rs_view
=
swapchain
.texture
.create_view
(
&
TextureViewDescriptor
{
label
:
Some
(
"Resolve target"
),
format
:
view_formats
.get
(
0
)
.copied
(),
..
Default
::
default
()
});
let
fb_view
=
framebuffer
.create_view
(
&
Default
::
default
());
let
rs_view
=
swapchain
.texture
.create_view
(
&
Default
::
default
());
let
db_view
=
depthbuffer
.create_view
(
&
Default
::
default
());
let
mut
pass
=
enc
.begin_render_pass
(
&
RenderPassDescriptor
{
...
...
@@ -210,11 +193,9 @@ pub async fn run() -> Result<()> {
}),
});
let
pipeline_fmt
=
view_formats
.get
(
0
)
.copied
()
.unwrap_or
(
format
);
let
aspect
=
window
.inner_size
()
.width
as
f32
/
window
.inner_size
()
.height
as
f32
;
state
.update
(
&
queue
,
&
device
,
&
mut
pass
,
pipeline_fmt
,
aspect
);
state
.update
(
&
queue
,
&
device
,
&
mut
pass
,
format
,
aspect
);
}
queue
.submit
([
enc
.finish
()]);
...
...
This diff is collapsed.
Click to expand it.
src/sprite.rs
+
0
−
2
View file @
ccb2b096
...
...
@@ -3,7 +3,6 @@ use wgpu::*;
pub
struct
Sprite
{
layout
:
BindGroupLayout
,
texture
:
Texture
,
uniforms
:
Buffer
,
bindgroup
:
BindGroup
,
pub
transforms
:
Mat4
,
...
...
@@ -109,7 +108,6 @@ impl Sprite {
Ok
(
Self
{
layout
,
texture
,
uniforms
,
bindgroup
,
transforms
,
...
...
This diff is collapsed.
Click to expand it.
src/state.rs
+
25
−
20
View file @
ccb2b096
...
...
@@ -2,22 +2,26 @@ use wgpu::{RenderPass, TextureFormat};
use
crate
::
prelude
::
*
;
pub
enum
State
{
Loading
{
fg
:
Sprite
,
bg
:
Sprite
,
scale
:
Animation
<
f32
>
,
rot
:
Animation
<
f32
>
,
},
pub
struct
State
{
splash
:
Splash
,
}
pub
struct
Splash
{
fg
:
Sprite
,
bg
:
Sprite
,
scale
:
Animation
<
f32
>
,
rot
:
Animation
<
f32
>
,
}
impl
State
{
pub
async
fn
new
(
queue
:
&
Queue
,
device
:
&
Device
)
->
Result
<
State
>
{
Ok
(
State
::
Loading
{
fg
:
Sprite
::
new
(
"splash_fg.png"
,
queue
,
device
,
true
)
.await
?
,
bg
:
Sprite
::
new
(
"splash_bg.png"
,
queue
,
device
,
true
)
.await
?
,
scale
:
Animation
::
new
(
vec!
[
0.0
,
0.1
,
0.25
],
Duration
::
from_secs
(
1
)),
rot
:
Animation
::
new
(
vec!
[
PI
,
PI
,
0.0
],
Duration
::
from_secs
(
3
)),
Ok
(
State
{
splash
:
Splash
{
fg
:
Sprite
::
new
(
"splash_fg.png"
,
queue
,
device
,
true
)
.await
?
,
bg
:
Sprite
::
new
(
"splash_bg.png"
,
queue
,
device
,
true
)
.await
?
,
scale
:
Animation
::
new
(
vec!
[
0.0
,
0.1
,
0.25
],
Duration
::
from_secs
(
1
)),
rot
:
Animation
::
new
(
vec!
[
PI
,
PI
,
0.0
],
Duration
::
from_secs
(
3
)),
},
})
}
...
...
@@ -29,16 +33,17 @@ impl State {
format
:
TextureFormat
,
aspect
:
f32
,
)
{
match
self
{
State
::
Loading
{
fg
,
bg
,
scale
,
rot
}
=>
{
bg
.transforms
=
Mat4
::
from_2d
(
Vec2
::
ZERO
,
s
cale
.get
(),
rot
.get
());
fg
.transforms
=
Mat4
::
from_2d
(
Vec2
::
ZERO
,
0.25
,
0.0
);
if
!
self
.splash.rot
.complete
()
{
self
.splash.bg.transforms
=
Mat4
::
from_2d
(
Vec2
::
ZERO
,
s
elf
.splash.scale
.get
(),
self
.splash.
rot
.get
());
self
.splash.
fg.transforms
=
Mat4
::
from_2d
(
Vec2
::
ZERO
,
0.25
,
0.0
);
bg
.record
(
queue
,
device
,
pass
,
format
,
aspect
);
if
scale
.complete
()
{
fg
.record
(
queue
,
device
,
pass
,
format
,
aspect
)
}
self
.splash.bg
.record
(
queue
,
device
,
pass
,
format
,
aspect
);
if
self
.splash.scale
.complete
()
{
self
.splash.fg
.record
(
queue
,
device
,
pass
,
format
,
aspect
)
}
}
else
{
}
}
}
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