Skip to content

Commit ae9ea48

Browse files
committed
infra: add Meson GL backend option for examples
Introduce meson_options.txt with a gl_backend selector and use it to choose GL vs GLES deps/flags; update the GL target call signature in MultiCanvas for the new API.
1 parent 562bd58 commit ae9ea48

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

meson_options.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
option('gl_backend',
2+
type: 'combo',
3+
choices: ['gl', 'gles'],
4+
value: 'gl',
5+
description: 'Select GL backend for examples (gl, gles)')

src/MultiCanvas.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "Example.h"
2424

25-
#ifdef THORVG_GL_RASTER_SUPPORT
25+
#if defined(TVGEXAMPLE_GL_SUPPORTED) || defined(TVGEXAMPLE_GLES_SUPPORTED)
2626
#include <SDL2/SDL_opengl.h>
2727
#endif
2828

@@ -117,7 +117,7 @@ void runSw()
117117
/* GL Engine Specific Setup */
118118
/************************************************************************/
119119

120-
#ifdef THORVG_GL_RASTER_SUPPORT
120+
#if defined(TVGEXAMPLE_GL_SUPPORTED) || defined(TVGEXAMPLE_GLES_SUPPORTED)
121121

122122
typedef void (*PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
123123
typedef void (*PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
@@ -173,7 +173,7 @@ struct GLFrameBuffer
173173

174174
void runGl()
175175
{
176-
#ifdef THORVG_GL_RASTER_SUPPORT
176+
#if defined(TVGEXAMPLE_GL_SUPPORTED) || defined(TVGEXAMPLE_GLES_SUPPORTED)
177177

178178
#ifdef THORVG_GL_TARGET_GLES
179179
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
@@ -208,7 +208,7 @@ void runGl()
208208
auto canvas = unique_ptr<tvg::GlCanvas>(tvg::GlCanvas::gen());
209209

210210
// Pass the framebuffer id to the GlCanvas
211-
tvgexam::verify(canvas->target(context, glFbo.fbo, SIZE, SIZE, tvg::ColorSpace::ABGR8888S));
211+
tvgexam::verify(canvas->target(nullptr, nullptr, context, glFbo.fbo, SIZE, SIZE, tvg::ColorSpace::ABGR8888S));
212212

213213
content(canvas.get());
214214
if (tvgexam::verify(canvas->draw())) {

src/meson.build

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ examples_dep = [thorvg_dep, dependency('sdl2', required: true)]
44
compiler_flags = ['-DSDL_MAIN_HANDLED']
55

66
# GL or GLES
7+
gl_backend = get_option('gl_backend')
78
gl_dep = dependency('gl', required: false)
89
gles_dep = dependency('glesv2', required: false)
10+
egl_dep = dependency('egl', required: false)
911

10-
if gl_dep.found()
11-
examples_dep += gl_dep
12-
elif gles_dep.found()
13-
examples_dep += gles_dep
14-
compiler_flags += ['-DTVGEXAMPLE_GLES_SUPPORTED']
15-
else
16-
message('Neither OpenGL nor OpenGL ES was found. Skipping GL examples.')
12+
if gl_backend == 'gl'
13+
if gl_dep.found()
14+
examples_dep += gl_dep
15+
compiler_flags += ['-DTVGEXAMPLE_GL_SUPPORTED']
16+
else
17+
message('Requested OpenGL but it was not found. Skipping GL examples.')
18+
endif
19+
elif gl_backend == 'gles'
20+
if gles_dep.found() and egl_dep.found()
21+
examples_dep += [gles_dep, egl_dep]
22+
compiler_flags += ['-DTVGEXAMPLE_GLES_SUPPORTED']
23+
else
24+
message('Requested OpenGL ES but it was not found. Skipping GL examples.')
25+
endif
1726
endif
1827

1928
# WebGPU

0 commit comments

Comments
 (0)