Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to force SRGB off within opengl #30

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ notify = "4.0.3"
reqwest = "~0.9"
clippy = { version = "0.*", optional = true }
anyhow = "1.0.0"
gfx_gl = "0.6.1"

[[bin]]
path = "src/main.rs"
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ Federico Menozzi <federicogmenozzi@gmail.com>
Desktop client for Shadertoy

USAGE:
shadertoy [OPTIONS] [shader] [SUBCOMMAND]
shadertoy [FLAGS] [OPTIONS] [shader] [SUBCOMMAND]

FLAGS:
-h, --help Prints help information
-V, --version Prints version information
--force_srgb_off Forces SRGB to be off (replicates shadertoy.com color blending)
-h, --help Prints help information
-V, --version Prints version information

OPTIONS:
-e, --example <example> Run example shader from examples/ directory
Expand Down
6 changes: 6 additions & 0 deletions src/argvalues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub struct ArgValues {

// True if also running downloaded shader.
pub andrun: bool,

// True if we should force disable srgb
pub force_srgb_off: bool,
}

impl ArgValues {
Expand Down Expand Up @@ -118,6 +121,8 @@ impl ArgValues {
(None, false)
};

let force_srgb_off = matches.is_present("force_srgb_off");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere (README.md, src/cli.yml), I'd prefer force-srgb-off (i.e. dashes instead of underscores

Copy link
Contributor Author

@seifane seifane Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there is another parameter that is making use of underscores anisotropic_max. Should this one be changed to dashes too while I'm at it :D

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! I missed that. In that case, for the sake of both uniformity and backwards compatibility, let's just use underscores for everything :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted :D

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


Ok(ArgValues {
width,
height,
Expand All @@ -139,6 +144,7 @@ impl ArgValues {
getid,
andrun,
title,
force_srgb_off,
})
}
}
5 changes: 5 additions & 0 deletions src/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ args:
short: t
takes_value: true
help: Sets the window title
- force_srgb_off:
long: force_srgb_off
takes_value: false
required: false
help: Forces SRGB to be off (replicates shadertoy.com color blending)
8 changes: 8 additions & 0 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ pub fn run(av: ArgValues) -> error::Result<()> {
.unwrap()
.init_gfx::<ColorFormat, DepthFormat>();

if av.force_srgb_off {
unsafe {
device.with_gl(|gl| {
gl.Disable(gfx_gl::FRAMEBUFFER_SRGB);
})
}
}

let mut encoder = gfx::Encoder::from(factory.create_command_buffer());

let mut pso = factory
Expand Down