Hi dear,
there is an example how to implement tinyGL on LVGL?
I see this https://github.com/lvgl/lv_lib_tinygl but maybe one file is missing (test.obj)?
These are the links for test.obj
and test.mtl
. However, we never finished making the model display, so you won’t see anything besides a gray background.
You can, however, try the gears example; that one does work.
wow thank you, try it!
I was able to get a obj model to display, it required getting the location and scale just right in an external CAD program, along with the OpenGL frustrum setup in TinyGL.
Converting the obj on the MCU seems a bit wasteful in some cases. I changed the routine embeddedt added to read the obj from an array instead of the file system, but I think an offline obj->header file coverter would make more sense.
Am I the only person who finds it very difficult to position objects/cameras in 3D using purely code? I’ve had this problem with Three.js/Babylon.js on the web as well. I find it much more intuitive to set initial positions using an editor like Unity/Blender and use code for relative positioning.
Anyone looking for TinyGL still?
I used C-Chads version that had text drawing too.
I had to rearrange the colours before updating the canvas.
Here’s a sample vs code project.
/* Copy TinyGL framebuffer (ARGB8888) to LVGL buffer (XRGB8888), processing 4 pixels at a time */
static void ZB_copyFrameBufferLVGL(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;
}
}