Compare commits

..

No commits in common. "5cecec3f7086ab19cda57c5cc7a1d818ba919af6" and "7f6d5069f8b1b4ab2fbcffe3c4d21af06d0936d9" have entirely different histories.

2 changed files with 11 additions and 20 deletions

View File

@ -55,8 +55,6 @@ impl eframe::App for TemplateApp {
// Put your widgets into a `SidePanel`, `TopBottomPanel`, `CentralPanel`, `Window` or `Area`. // Put your widgets into a `SidePanel`, `TopBottomPanel`, `CentralPanel`, `Window` or `Area`.
// For inspiration and more examples, go to https://emilk.github.io/egui // For inspiration and more examples, go to https://emilk.github.io/egui
ctx.request_repaint();
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar: // The top panel is often a good place for a menu bar:

View File

@ -1,6 +1,6 @@
use eframe::glow::{self, PixelUnpackData, TEXTURE0, TEXTURE1, UNSIGNED_BYTE}; use eframe::glow::{self, PixelUnpackData, TEXTURE0, TEXTURE1, UNSIGNED_BYTE};
use glow::HasContext as _; use glow::HasContext as _;
use glow::{NEAREST, TEXTURE_2D, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER}; use glow::{NEAREST, TEXTURE_1D, TEXTURE_2D, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER};
use log; use log;
use std::mem::{size_of, transmute}; use std::mem::{size_of, transmute};
@ -63,7 +63,7 @@ impl Waterfall {
// Bind our texturs // Bind our texturs
gl.active_texture(TEXTURE1); gl.active_texture(TEXTURE1);
check_for_gl_errors(&gl, "Active texture 1"); check_for_gl_errors(&gl, "Active texture 1");
gl.bind_texture(glow::TEXTURE_2D, Some(self.color_lut)); gl.bind_texture(glow::TEXTURE_1D, Some(self.color_lut));
check_for_gl_errors(&gl, "bind lut"); check_for_gl_errors(&gl, "bind lut");
gl.active_texture(TEXTURE0); gl.active_texture(TEXTURE0);
@ -208,22 +208,15 @@ impl Waterfall {
let color_lut = gl let color_lut = gl
.create_texture() .create_texture()
.expect("Waterfall: could not create LUT"); .expect("Waterfall: could not create LUT");
gl.bind_texture(TEXTURE_2D, Some(color_lut)); gl.bind_texture(TEXTURE_1D, Some(color_lut));
check_for_gl_errors(&gl, "Setup Bind LUT"); gl.tex_parameter_i32(TEXTURE_1D, TEXTURE_MIN_FILTER, NEAREST as i32);
gl.tex_parameter_i32(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST as i32); gl.tex_parameter_i32(TEXTURE_1D, TEXTURE_MAG_FILTER, NEAREST as i32);
check_for_gl_errors(&gl, "Set LUT MIN_FILTER"); check_for_gl_errors(&gl, "Set LUT params");
gl.tex_parameter_i32(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST as i32); gl.tex_image_1d(
check_for_gl_errors(&gl, "Set LUT MAG_FILTER"); TEXTURE_1D,
gl.tex_image_2d(
TEXTURE_2D,
0, 0,
if cfg!(target_os = "android") { glow::SRGB as i32,
glow::RGB
} else {
glow::SRGB
} as i32,
256, 256,
1,
0, 0,
glow::RGB, glow::RGB,
UNSIGNED_BYTE, UNSIGNED_BYTE,
@ -257,13 +250,13 @@ impl Waterfall {
// texture sampler // texture sampler
uniform sampler2D texture1; uniform sampler2D texture1;
uniform sampler2D LUT; uniform sampler1D LUT;
uniform float offset; uniform float offset;
void main() void main()
{ {
float val = texture(texture1, vec2(TexCoord.x, TexCoord.y + offset)).x; float val = texture(texture1, vec2(TexCoord.x, TexCoord.y + offset)).x;
FragColor = texture(LUT, vec2(val, 0)); FragColor = texture(LUT, val);
} }
"#, "#,
); );