Skip to content

Commit a0a40a5

Browse files
authored
Merge pull request glium#2076 from justincredible/srgb-fun
Fix sRGB confusion
2 parents b95779d + 3007162 commit a0a40a5

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@ pub trait Surface {
784784
fn clear(&mut self, rect: Option<&Rect>, color: Option<(f32, f32, f32, f32)>, color_srgb: bool,
785785
depth: Option<f32>, stencil: Option<i32>);
786786

787-
/// Clears the color attachment of the target.
787+
/// Clears the color attachment of the target. The color is converted to sRGB when the target has sRGB format.
788788
fn clear_color(&mut self, red: f32, green: f32, blue: f32, alpha: f32) {
789789
self.clear(None, Some((red, green, blue, alpha)), false, None, None);
790790
}
791791

792-
/// Clears the color attachment of the target. The color is in sRGB format.
792+
/// Clears the color attachment of the target. The color is in sRGB format and is not converted in the target.
793793
fn clear_color_srgb(&mut self, red: f32, green: f32, blue: f32, alpha: f32) {
794794
self.clear(None, Some((red, green, blue, alpha)), true, None, None);
795795
}

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ macro_rules! program {
616616
let __tessellation_evaluation_shader: Option<&str> = None;
617617
let __geometry_shader: Option<&str> = None;
618618
let __fragment_shader: &str = "";
619-
let __outputs_srgb: bool = false;
619+
let __outputs_srgb: bool = true;
620620
let __uses_point_size: bool = false;
621621

622622
$(

src/ops/clear.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ pub fn clear(context: &Context, framebuffer: Option<&ValidatedAttachments<'_>>,
3535
if ctxt.version >= &Version(Api::Gl, 3, 0) || ctxt.extensions.gl_arb_framebuffer_srgb ||
3636
ctxt.extensions.gl_ext_framebuffer_srgb || ctxt.extensions.gl_ext_srgb_write_control
3737
{
38-
if color_srgb && !ctxt.state.enabled_framebuffer_srgb {
38+
if !color_srgb && !ctxt.state.enabled_framebuffer_srgb {
3939
ctxt.gl.Enable(gl::FRAMEBUFFER_SRGB);
4040
ctxt.state.enabled_framebuffer_srgb = true;
4141

42-
} else if !color_srgb && ctxt.state.enabled_framebuffer_srgb {
42+
} else if color_srgb && ctxt.state.enabled_framebuffer_srgb {
4343
ctxt.gl.Disable(gl::FRAMEBUFFER_SRGB);
4444
ctxt.state.enabled_framebuffer_srgb = false;
4545
}

src/program/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ pub enum ProgramCreationInput<'a> {
262262
/// `None`, then you won't be able to use transform feedback.
263263
transform_feedback_varyings: Option<(Vec<String>, TransformFeedbackMode)>,
264264

265-
/// Whether the fragment shader outputs colors in `sRGB` or `RGB`. This is false by default,
266-
/// meaning that the program outputs `RGB`.
265+
/// Whether the fragment shader outputs colors in `sRGB` or `RGB`. This is true by default,
266+
/// meaning that the program is responsible for outputting correct `sRGB` values.
267267
///
268268
/// If this is false, then `GL_FRAMEBUFFER_SRGB` will be enabled when this program is used
269269
/// (if it is supported).
@@ -333,7 +333,7 @@ impl<'a> SpirvProgram<'a> {
333333
tessellation_evaluation_shader: None,
334334
geometry_shader: None,
335335
transform_feedback_varyings: None,
336-
outputs_srgb: false,
336+
outputs_srgb: true,
337337
uses_point_size: false,
338338
}
339339
}
@@ -416,7 +416,7 @@ impl<'a> From<SourceCode<'a>> for ProgramCreationInput<'a> {
416416
geometry_shader,
417417
fragment_shader,
418418
transform_feedback_varyings: None,
419-
outputs_srgb: false,
419+
outputs_srgb: true,
420420
uses_point_size: false,
421421
}
422422
}
@@ -436,7 +436,7 @@ impl<'a> From<Binary> for ProgramCreationInput<'a> {
436436
fn from(binary: Binary) -> ProgramCreationInput<'a> {
437437
ProgramCreationInput::Binary {
438438
data: binary,
439-
outputs_srgb: false,
439+
outputs_srgb: true,
440440
uses_point_size: false,
441441
}
442442
}

src/program/program.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Program {
207207
tessellation_control_shader: None,
208208
tessellation_evaluation_shader: None,
209209
transform_feedback_varyings: None,
210-
outputs_srgb: false,
210+
outputs_srgb: true,
211211
uses_point_size: false,
212212
})
213213
}

0 commit comments

Comments
 (0)