lvgl / lv_lib_tinygl

EXPERIMENTAL - 3D extension for lvgl using TinyGL
MIT License
23 stars 3 forks source link

Update the 3D Graphics library #1

Open Miguel0101 opened 3 years ago

Miguel0101 commented 3 years ago

Will this library be updated in the future?

kisvegabor commented 3 years ago

The development stopped due to strange issues in the library.

We can warm up this topic, of course :slightly_smiling_face:

Miguel0101 commented 3 years ago

The development stopped due to strange issues in the library.

We can warm up this topic, of course

What strange problems?

kisvegabor commented 3 years ago

I debugged for a while but already don't remember exactly. We could render the example models but couldn't add even the simplest custom model.

Miguel0101 commented 3 years ago

I debugged for a while but already don't remember exactly. We could render the example models but couldn't add even the simplest custom model.

Hum, does it reset the old model?

kisvegabor commented 3 years ago

I don't remember the details. :slightly_frowning_face:

Miguel0101 commented 3 years ago

We would have to give the code a brief read.

Miguel0101 commented 3 years ago

https://github.com/lvgl/lv_lib_tinygl/blob/3ac642ebc769be1e0dba4274b8cb41778ff3a067/lv_tinygl_test.c#L53

The file format is .obj. Which app to create a 3D model?

kisvegabor commented 3 years ago

All I know abut this project was discussed here: https://github.com/lvgl/lvgl/issues/16

agentdavo commented 1 month ago

C-Chads version had some extra work https://github.com/C-Chads/tinygl

@erysdren seems to be updating regularly https://github.com/erysdren/TinyGL

I managed to get gears rendering on a sim project

https://github.com/agentdavo/lv_port_pc_vscode/blob/master/main/src/main.c

For 32-bit, I had to write a TinyGL to Canvas colour reordering function.


ZB_copyFrameBufferLVGL32(ZBuffer *zb, lv_color32_t *lv_buf)
{
    uint32_t *q_ptr = (uint32_t *)frameBuffer->pbuf;  // Pointer to TinyGL framebuffer (ARGB8888 format)
    lv_color32_t *p_ptr = lv_buf;                     // Pointer to LVGL buffer (XRGB8888 format)

    int total_pixels = frameBuffer->xsize * frameBuffer->ysize;
    int i;

    // Process 4 pixels at a time
    for (i = 0; i <= total_pixels - 4; i += 4)
    {
        // Pixel 1
        uint32_t pixel1 = q_ptr[i];
        p_ptr[i].red   = (pixel1 >> 16) & 0xFF;
        p_ptr[i].green = (pixel1 >> 8) & 0xFF;
        p_ptr[i].blue  = pixel1 & 0xFF;
        p_ptr[i].alpha = 0xFF;

        // Pixel 2
        uint32_t pixel2 = q_ptr[i + 1];
        p_ptr[i + 1].red   = (pixel2 >> 16) & 0xFF;
        p_ptr[i + 1].green = (pixel2 >> 8) & 0xFF;
        p_ptr[i + 1].blue  = pixel2 & 0xFF;
        p_ptr[i + 1].alpha = 0xFF;

        // Pixel 3
        uint32_t pixel3 = q_ptr[i + 2];
        p_ptr[i + 2].red   = (pixel3 >> 16) & 0xFF;
        p_ptr[i + 2].green = (pixel3 >> 8) & 0xFF;
        p_ptr[i + 2].blue  = pixel3 & 0xFF;
        p_ptr[i + 2].alpha = 0xFF;

        // Pixel 4
        uint32_t pixel4 = q_ptr[i + 3];
        p_ptr[i + 3].red   = (pixel4 >> 16) & 0xFF;
        p_ptr[i + 3].green = (pixel4 >> 8) & 0xFF;
        p_ptr[i + 3].blue  = pixel4 & 0xFF;
        p_ptr[i + 3].alpha = 0xFF;
    }

    // Handle any remaining pixels (if total_pixels is not a multiple of 4)
    for (; i < total_pixels; i++)
    {
        uint32_t pixel = q_ptr[i];
        p_ptr[i].red   = (pixel >> 16) & 0xFF;
        p_ptr[i].green = (pixel >> 8) & 0xFF;
        p_ptr[i].blue  = pixel & 0xFF;
        p_ptr[i].alpha = 0xFF;
    }
}