lv_lib_tinygl icon indicating copy to clipboard operation
lv_lib_tinygl copied to clipboard

Update the 3D Graphics library

Open Miguel0101 opened this issue 3 years ago • 8 comments

Will this library be updated in the future?

Miguel0101 avatar Aug 26 '21 00:08 Miguel0101

The development stopped due to strange issues in the library.

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

kisvegabor avatar Aug 26 '21 10:08 kisvegabor

The development stopped due to strange issues in the library.

We can warm up this topic, of course

What strange problems?

Miguel0101 avatar Aug 26 '21 11:08 Miguel0101

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.

kisvegabor avatar Aug 26 '21 11:08 kisvegabor

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?

Miguel0101 avatar Aug 26 '21 11:08 Miguel0101

I don't remember the details. :slightly_frowning_face:

kisvegabor avatar Aug 26 '21 11:08 kisvegabor

We would have to give the code a brief read.

Miguel0101 avatar Aug 26 '21 11:08 Miguel0101

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?

Miguel0101 avatar Aug 31 '21 14:08 Miguel0101

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

kisvegabor avatar Sep 01 '21 09:09 kisvegabor

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

agentdavo avatar Oct 06 '24 18:10 agentdavo