aboutsummaryrefslogtreecommitdiff
path: root/docs/integration/driver/opengles.rst
blob: 254e31dd709f9e7c4f40c765c140d748ec9b41c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
===============================
OpenGL ES Display/Inputs driver
===============================

Overview
--------

| The **OpenGL ES** display/input `driver <https://github.com/lvgl/lvgl/src/drivers/opengles>`__ offers support for simulating the LVGL display and keyboard/mouse inputs in an desktop window created via GLFW.
| It is an alternative to **Wayland**, **XCB**, **SDL** or **Qt**.

The main purpose for this driver is for testing/debugging the LVGL application in an **OpenGL** simulation window.

Prerequisites
-------------

The OpenGL driver uses GLEW GLFW to access the OpenGL window manager.

1. Install GLEW and GLFW: ``sudo apt-get install libglew-dev libglfw3-dev``

Configure OpenGL driver
-----------------------

1. Required linked libraries: -lGL -lGLEW -lglfw
2. Enable the OpenGL driver support in lv_conf.h, by cmake compiler define or by KConfig
    .. code:: c

        #define LV_USE_OPENGLES  1

Usage
-----

.. code:: c

    #include "lvgl/lvgl.h"
    #include "lvgl/examples/lv_examples.h"
    #include "lvgl/demos/lv_demos.h"

    int main()
    {
        lv_init();

        lv_display_t * disp = lv_glfw_window_create(480, 272);

        lv_indev_t * mouse = lv_glfw_mouse_create();
        lv_indev_set_group(mouse, lv_group_get_default());
        lv_indev_set_display(mouse, disp);

        lv_display_set_default(disp);

        LV_IMAGE_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
        lv_obj_t * cursor_obj;
        cursor_obj = lv_image_create(lv_screen_active());   /*Create an image object for the cursor */
        lv_image_set_src(cursor_obj, &mouse_cursor_icon);   /*Set the image source*/
        lv_indev_set_cursor(mouse, cursor_obj);             /*Connect the image  object to the driver*/

        lv_demo_widgets();

        while (1)
        {
            uint32_t time_till_next = lv_timer_handler();
            lv_delay_ms(time_till_next);
        }

        return 0;
    }