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

}

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);

wl_display_roundtrip (display);

egl_display = eglGetDisplay (display);

eglInitialize (egl_display, NULL, NULL);

struct window window;

create_window (&window, WIDTH, HEIGHT);

while (running) {

wl_display_dispatch_pending (display);

最全的Linux教程,Linux从入门到精通

======================

  1. linux从入门到精通(第2版)

  2. Linux系统移植

  3. Linux驱动开发入门与实战

  4. LINUX 系统移植 第2版

  5. Linux开源网络全栈详解 从DPDK到OpenFlow

华为18级工程师呕心沥血撰写3000页Linux学习笔记教程

第一份《Linux从入门到精通》466页

====================

内容简介

====

本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。

华为18级工程师呕心沥血撰写3000页Linux学习笔记教程

本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。

需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

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

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值