Skip to content

Commit

Permalink
[feat] get waymirror-egl dmabuf MVP demo working
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerfulPianissimo committed Jul 27, 2024
1 parent e934677 commit 8d410d7
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 94 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions libwayshot/examples/waymirror-egl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ edition = "2021"
[dependencies]
gl = "0.14.0"
gl_loader = "0.1.2"
khronos-egl = { version = "6.0.0", features = ["static"] }
khronos-egl = { version = "6.0.0",features = ["dynamic"] }
thiserror = "1.0.58"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
wayland-backend = { version = "0.3.3", features = ["client_system"] }
wayland-client = { version = "0.31.2" }
wayland-egl = { version = "0.32.0" }
wayland-protocols = { version = "0.31.2", features = ["client"] }
libwayshot={path="../.."}
libwayshot={path="../.."}
libloading="0.8.4"
7 changes: 4 additions & 3 deletions libwayshot/examples/waymirror-egl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::str::FromStr;

pub fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::from_str("trace")?)
.with_max_level(tracing::Level::from_str("error")?)
.with_writer(std::io::stderr)
.init();

Expand Down Expand Up @@ -52,13 +52,14 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
state.init_egl()?;
while state.running {
event_queue.dispatch_pending(&mut state)?;

// event_queue.blocking_dispatch(&mut state)?;
// state.dmabuf_to_egl()
state.draw();
state
.egl
.swap_buffers(state.egl_display.unwrap(), state.egl_surface.unwrap())?;

tracing::event!(tracing::Level::DEBUG, "eglSwapBuffers called");
//tracing::event!(tracing::Level::DEBUG, "eglSwapBuffers called");
}
state.deinit()?;

Expand Down
5 changes: 4 additions & 1 deletion libwayshot/examples/waymirror-egl/src/shaders/frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

precision mediump float;
out vec4 FragColor;
uniform sampler2D uTexture;
in vec2 vTexCoord;

void main() {
FragColor = vec4 ( 1.0, 0.2, 0.0, 1.0 );
vec4 color = texture(uTexture, vTexCoord);
FragColor = vec4 ( 1.0-color.r,1.0-color.g,1.0-color.b, 1.0 );
}
12 changes: 8 additions & 4 deletions libwayshot/examples/waymirror-egl/src/shaders/vert.glsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#version 300 es
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;

layout(location = 0) in vec3 aPos;
out vec2 vTexCoord;

void main() {
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}
void main()
{
gl_Position = vec4(aPos, 1.0);
vTexCoord = vec2(aTexCoord.x, aTexCoord.y);
}
Loading

0 comments on commit 8d410d7

Please sign in to comment.