Linux之wayland+OpenGL+EGL绘制(十九)(1)

本文详细介绍了如何使用wl_registry和相关接口在Linux环境中进行对象注册与管理,以及shell_surface的事件处理。同时提到了一份面向Linux运维的学习资料,包含了体系化的学习资源和进阶课程。
摘要由CSDN通过智能技术生成

// listeners

static void registry_add_object (void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) {

if (!strcmp(interface,“wl_compositor”)) {

compositor = wl_registry_bind (registry, name, &wl_compositor_interface, 1);

}

else if (!strcmp(interface,“wl_shell”)) {

shell = wl_registry_bind (registry, name, &wl_shell_interface, 1);

}

}

static void registry_remove_object (void *data, struct wl_registry *registry, uint32_t name) {

}

static struct wl_registry_listener registry_listener = {&registry_add_object, &registry_remove_object};

static void shell_surface_ping (void *data, struct wl_shell_surface *shell_surface, uint32_t serial) {

wl_shell_surface_pong (shell_surface, serial);

}

static void shell_surface_configure (void *data, struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width, int32_t height) {

struct window *window = data;

wl_egl_window_resize (window->egl_window, width, height, 0, 0);

}

static void shell_surface_popup_done (void *data, struct wl_shell_surface *shell_surface) {

}

static struct wl_shell_surface_listener shell_surface_listener = {&shell_surface_ping, &shell_surface_configure, &shell_surface_popup_done};

static void create_window (struct window *window, int32_t width, int32_t height) {

eglBindAPI (EGL_OPENGL_API);

EGLint attributes[] = {

EGL_RED_SIZE, 8,

EGL_GREEN_SIZE, 8,

EGL_BLUE_SIZE, 8,

EGL_NONE};

EGLConfig config;

EGLint num_config;

eglChooseConfig (egl_display, attributes, &config, 1, &num_config);

window->egl_context = eglCreateContext (egl_display, config, EGL_NO_CONTEXT, NULL);

window->surface = wl_compositor_create_surface (compositor);

window->shell_surface = wl_shell_get_shell_surface (shell, window->surface);

wl_shell_surface_add_listener (window->shell_surface, &shell_surface_listener, window);

wl_shell_surface_set_toplevel (window->shell_surface);

window->egl_window = wl_egl_window_create (window->surface, width, height);

window->egl_surface = eglCreateWindowSurface (egl_display, config, window->egl_window, NULL);

eglMakeCurrent (egl_display, window->egl_surface, window->egl_surface, window->egl_context);

}

static void delete_window (struct window *window) {

eglDestroySurface (egl_display, window->egl_surface);

wl_egl_window_destroy (window->egl_window);

wl_shell_surface_destroy (window->shell_surface);

wl_surface_destroy (window->surface);

eglDestroyContext (egl_display, window->egl_context);

}

static void draw_window (struct window *window) {

glClearColor (0.0, 1.0, 0.0, 1.0);

glClear (GL_COLOR_BUFFER_BIT);

eglSwapBuffers (egl_display, window->egl_surface);

}

int main () {

display = wl_display_connect (NULL);

struct wl_registry *registry = wl_display_get_registry (display);

wl_registry_add_listener (registry, &registry_listener, NULL);

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前在阿里

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上运维知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

  • 30
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值