Skip to content

Commit 6c880fb

Browse files
committed
LVGL: support all color depths for opengl builds
Signed-off-by: falkTX <[email protected]>
1 parent 9660ac6 commit 6c880fb

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

generic/LVGL.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ struct LVGLWidget<BaseWidget>::PrivateData {
131131

132132
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
133133
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
134-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
135-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
134+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
135+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
136136

137137
static constexpr const float transparent[] = { 0.f, 0.f, 0.f, 0.f };
138138
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, transparent);
@@ -363,13 +363,20 @@ void LVGLWidget<BaseWidget>::onDisplay()
363363
{
364364
#if LV_COLOR_DEPTH == 32
365365
static constexpr const GLenum format = GL_BGRA;
366+
static constexpr const GLenum ftype = GL_UNSIGNED_BYTE;
366367
#elif LV_COLOR_DEPTH == 24
367368
static constexpr const GLenum format = GL_BGR;
369+
static constexpr const GLenum ftype = GL_UNSIGNED_BYTE;
370+
#elif LV_COLOR_DEPTH == 16
371+
static constexpr const GLenum format = GL_RGB;
372+
static constexpr const GLenum ftype = GL_UNSIGNED_SHORT_5_6_5;
373+
#elif LV_COLOR_DEPTH == 8
374+
static constexpr const GLenum format = GL_LUMINANCE;
375+
static constexpr const GLenum ftype = GL_UNSIGNED_BYTE;
368376
#else
369377
#error Unsupported color format
370378
#endif
371379

372-
glPixelStorei(GL_PACK_ALIGNMENT, 1);
373380
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
374381
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
375382

@@ -379,7 +386,7 @@ void LVGLWidget<BaseWidget>::onDisplay()
379386
lvglData->updatedArea.x2 == width &&
380387
lvglData->updatedArea.y2 == height)
381388
{
382-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, lvglData->textureData);
389+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, ftype, lvglData->textureData);
383390
}
384391
// partial size
385392
else
@@ -397,7 +404,7 @@ void LVGLWidget<BaseWidget>::onDisplay()
397404
partial_y,
398405
partial_width,
399406
partial_height,
400-
format, GL_UNSIGNED_BYTE,
407+
format, ftype,
401408
lvglData->textureData + offset);
402409
}
403410

generic/LVGL.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ START_NAMESPACE_DGL
4040

4141
#if defined(DGL_CAIRO) && LV_COLOR_DEPTH != 32
4242
# error LV_COLOR_DEPTH must be 32 for Cairo DPF builds
43-
#elif LV_COLOR_DEPTH != 24 && LV_COLOR_DEPTH != 32
44-
# error LV_COLOR_DEPTH must be 24 or 32 for DPF builds
4543
#endif
4644

4745
#if LV_DEF_REFR_PERIOD != 1

0 commit comments

Comments
 (0)