Skip to content

Commit

Permalink
update third-party libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
y-fujii committed Feb 11, 2021
1 parent 9469c7e commit fe883a0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion memol_cli/src/jack.rs
Expand Up @@ -84,8 +84,8 @@ impl Library {
#[cfg(all(target_family = "windows", target_pointer_width = "32"))]
let path = "libjack.dll";

let lib = libloading::Library::new(path)?;
unsafe {
let lib = libloading::Library::new(path)?;
Ok(Self {
activate: *lib.get(b"jack_activate\0")?,
client_close: *lib.get(b"jack_client_close\0")?,
Expand Down
3 changes: 2 additions & 1 deletion memol_cli/src/notify.rs
Expand Up @@ -16,12 +16,13 @@ pub fn wait_file<T: AsRef<path::Path>>(path: T) -> io::Result<()> {
Some(e) => e,
None => return Err(io::ErrorKind::Other.into()),
};
let path = ffi::CString::new(path).unwrap();

unsafe {
let fd = inotify_init1(IN_CLOEXEC);
let mut fs = fs::File::from_raw_fd(fd);

if inotify_add_watch(fd, ffi::CString::new(path).unwrap().as_ptr(), IN_CLOSE_WRITE) < 0 {
if inotify_add_watch(fd, path.as_ptr(), IN_CLOSE_WRITE) < 0 {
return Err(io::ErrorKind::Other.into());
}

Expand Down
1 change: 1 addition & 0 deletions memol_gui/build.rs
Expand Up @@ -41,6 +41,7 @@ fn main() {
.file("imgui/imgui.cpp")
.file("imgui/imgui_draw.cpp")
.file("imgui/imgui_widgets.cpp")
.file("imgui/imgui_tables.cpp")
.compile("libimgui.a");

println!("cargo:rerun-if-changed=imgui/");
Expand Down
2 changes: 1 addition & 1 deletion memol_gui/imgui
Submodule imgui updated 143 files
2 changes: 1 addition & 1 deletion memol_gui/src/main.rs
Expand Up @@ -119,7 +119,7 @@ fn main() {
let fonts = init_imgui(window.hidpi_factor() as f32);
window.update_font();
if let Some(Ok(img)) = opts.wallpaper.map(image::open) {
let mut img = img.to_rgba();
let mut img = img.to_rgba8();
lighten_image(&mut img, 0.5);
let mut wallpaper = renderer::Texture::new();
unsafe { wallpaper.upload_u32(img.as_ptr(), img.width() as i32, img.height() as i32) };
Expand Down
46 changes: 23 additions & 23 deletions memol_gui/src/renderer.rs
Expand Up @@ -102,29 +102,29 @@ impl Drop for Renderer {
}

const VERT_SHADER_CODE: &'static str = r#"
uniform vec2 Scale;
layout( location = 0 ) in vec2 pos;
layout( location = 1 ) in vec2 uv;
layout( location = 2 ) in vec4 color;
out vec2 frag_uv;
out vec4 frag_color;
void main() {
frag_uv = uv;
frag_color = color;
gl_Position = vec4( Scale * pos + vec2( -1.0, +1.0 ), 0.0, 1.0 );
}
uniform vec2 u_scale;
layout(location = 0) in vec2 a_pos;
layout(location = 1) in vec2 a_uv;
layout(location = 2) in vec4 a_color;
out vec2 m_uv;
out vec4 m_color;
void main() {
m_uv = a_uv;
m_color = a_color;
gl_Position = vec4(u_scale * a_pos + vec2(-1.0, +1.0), 0.0, 1.0);
}
"#;

const FRAG_SHADER_CODE: &'static str = r#"
uniform sampler2D Texture;
in vec2 frag_uv;
in vec4 frag_color;
out vec4 out_color;
void main() {
out_color = frag_color * texture( Texture, frag_uv );
}
uniform sampler2D u_texture;
in vec2 m_uv;
in vec4 m_color;
out vec4 o_color;
void main() {
o_color = m_color * texture(u_texture, m_uv);
}
"#;

unsafe fn compile_shader(ty: u32, code: &[&str]) -> u32 {
Expand Down Expand Up @@ -155,8 +155,8 @@ impl Renderer {
gl::AttachShader(prog, frag);
gl::LinkProgram(prog);
gl::UseProgram(prog);
gl::Uniform1i(gl::GetUniformLocation(prog, "Texture\0".as_ptr() as _), 0);
let loc_scale = gl::GetUniformLocation(prog, "Scale\0".as_ptr() as _);
gl::Uniform1i(gl::GetUniformLocation(prog, "u_texture\0".as_ptr() as _), 0);
let loc_scale = gl::GetUniformLocation(prog, "u_scale\0".as_ptr() as _);

// vertex objects.
let mut vao = 0;
Expand Down Expand Up @@ -206,7 +206,7 @@ impl Renderer {

pub fn sync(&self) {
unsafe {
// seem weird, but it is a workaround for some GPUs.
// seems weird, but it is a workaround for some GPUs.
let sync = gl::FenceSync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0);
gl::Finish();
gl::ClientWaitSync(sync, 0, 100_000_000);
Expand Down

0 comments on commit fe883a0

Please sign in to comment.