mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Some code cleanup following https://github.com/emilk/egui/pull/888
This commit is contained in:
@@ -185,10 +185,10 @@ impl VAO {
|
||||
}
|
||||
|
||||
/// If returned true no need to emulate vao
|
||||
pub(crate) unsafe fn support_vao(gl: &glow::Context) -> bool {
|
||||
pub(crate) fn supports_vao(gl: &glow::Context) -> bool {
|
||||
let web_sig = "WebGL ";
|
||||
let es_sig = "OpenGL ES ";
|
||||
let version_string = gl.get_parameter_string(glow::VERSION);
|
||||
let version_string = unsafe { gl.get_parameter_string(glow::VERSION) };
|
||||
if let Some(pos) = version_string.rfind(web_sig) {
|
||||
let version_str = &version_string[pos + web_sig.len()..];
|
||||
glow_debug_print(format!(
|
||||
|
||||
@@ -61,9 +61,10 @@ impl Painter {
|
||||
/// Create painter.
|
||||
///
|
||||
/// Set `pp_fb_extent` to the framebuffer size to enable `sRGB` support on OpenGL ES and WebGL.
|
||||
/// Set `shader_prefix` if you want to turn on shader workaround e.g. `"#define EPIPHANY_WORKAROUND\n"`.
|
||||
///
|
||||
/// this fix [Everything is super dark in epiphany](https://github.com/emilk/egui/issues/794)
|
||||
/// Set `shader_prefix` if you want to turn on shader workaround e.g. `"#define APPLY_BRIGHTENING_GAMMA\n"`
|
||||
/// (see <https://github.com/emilk/egui/issues/794>).
|
||||
///
|
||||
/// # Errors
|
||||
/// will return `Err` below cases
|
||||
/// * failed to compile shader
|
||||
@@ -74,7 +75,7 @@ impl Painter {
|
||||
pp_fb_extent: Option<[i32; 2]>,
|
||||
shader_prefix: &str,
|
||||
) -> Result<Painter, String> {
|
||||
let support_vao = unsafe { crate::misc_util::support_vao(gl) };
|
||||
let support_vao = crate::misc_util::supports_vao(gl);
|
||||
let shader_version = ShaderVersion::get(gl);
|
||||
let is_webgl_1 = shader_version == ShaderVersion::Es100;
|
||||
let header = shader_version.version();
|
||||
|
||||
@@ -18,9 +18,9 @@ vec4 srgba_from_linear(vec4 rgba) {
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_sampler, v_tc);
|
||||
|
||||
gl_FragColor = srgba_from_linear(gl_FragColor) / 255.;
|
||||
#ifdef WEBKITGTK_WORKAROUND
|
||||
//this is better than double apply
|
||||
gl_FragColor = vec4(pow(gl_FragColor.rgb,vec3(1.0/2.2)),gl_FragColor.a);
|
||||
gl_FragColor = srgba_from_linear(gl_FragColor) / 255.0;
|
||||
|
||||
#ifdef APPLY_BRIGHTENING_GAMMA
|
||||
gl_FragColor = vec4(pow(gl_FragColor.rgb, vec3(1.0/2.2)), gl_FragColor.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user