6 'gstglcontrolbindingproxy.c',
18 'gstgloverlaycompositor.c',
20 'gstglrenderbuffer.c',
22 'gstglshaderstrings.c',
41 'gstglcolorconvert.h',
43 'gstglcontrolbindingproxy.h',
52 'gstgloverlaycompositor.h',
55 'gstglshaderstrings.h',
65 gl_prototype_headers = [
66 'glprototypes/all_functions.h',
67 'glprototypes/base.h',
68 'glprototypes/blending.h',
69 'glprototypes/buffers.h',
70 'glprototypes/debug.h',
71 'glprototypes/eglimage.h',
73 'glprototypes/fixedfunction.h',
74 'glprototypes/gles.h',
75 'glprototypes/gstgl_compat.h',
76 'glprototypes/gstgl_gles2compat.h',
77 'glprototypes/Makefile.am',
78 'glprototypes/opengl.h',
79 'glprototypes/query.h',
80 'glprototypes/README',
81 'glprototypes/shaders.h',
82 'glprototypes/sync.h',
87 gl_wayland_headers = []
92 glconf = configuration_data()
94 gmodule_dep = dependency('gmodule-no-export-2.0')
95 unneeded_dep = dependency('', required : false)
96 if unneeded_dep.found()
97 error ('Found unfindable dependency')
100 # OpenGL/GLES2 libraries
102 # GL platform - EGL, GLX, CGL, WGL, etc
103 gl_platform_deps = []
104 # GL winsys - wayland, X11, Cocoa, win32, etc
106 # other things we need.
110 enabled_gl_platforms = []
111 enabled_gl_winsys = []
113 # parse provided options
114 gl_apis_s = get_option ('with_gl_api')
115 if gl_apis_s == 'auto'
116 need_api_opengl = 'auto'
117 need_api_gles2 = 'auto'
119 need_api_opengl = 'no'
120 need_api_gles2 = 'no'
121 gl_apis = gl_apis_s.split(',')
122 foreach api : gl_apis
124 need_api_opengl = 'yes'
126 need_api_gles2 = 'yes'
128 error('Unsupported GL api provided ' + api)
133 gl_platforms_s = get_option ('with_gl_platform')
134 if gl_platforms_s == 'auto'
135 need_platform_egl = 'auto'
136 need_platform_glx = 'auto'
137 need_platform_cgl = 'auto'
138 need_platform_wgl = 'auto'
139 need_platform_eagl = 'auto'
141 need_platform_egl = 'no'
142 need_platform_glx = 'no'
143 need_platform_cgl = 'no'
144 need_platform_wgl = 'no'
145 need_platform_eagl = 'no'
146 gl_platforms = gl_platforms_s.split(',')
147 foreach platform : gl_platforms
149 need_platform_egl = 'yes'
150 elif platform == 'glx'
151 need_platform_glx = 'yes'
152 # elif platform == 'cgl'
153 # need_platform_cgl = 'yes'
154 # elif platform == 'wgl'
155 # need_platform_wgl = 'yes'
156 # elif platform == 'eagl'
157 # need_platform_eagl = 'yes'
159 error('Unsupported GL platform provided ' + platform)
164 gl_winsys_s = get_option ('with_gl_winsys')
165 if gl_winsys_s == 'auto'
166 need_win_x11 = 'auto'
167 need_win_wayland = 'auto'
168 need_win_win32 = 'auto'
169 need_win_cocoa = 'auto'
170 need_win_eagl = 'auto'
171 need_win_dispmanx = 'auto'
174 need_win_wayland = 'no'
175 need_win_win32 = 'no'
176 need_win_cocoa = 'no'
178 need_win_dispmanx = 'no'
179 gl_winsys = gl_winsys_s.split(',')
180 foreach winsys : gl_winsys
183 elif winsys == 'wayland'
184 need_win_wayland = 'yes'
185 # elif winsys == 'win32'
186 # need_win_win32 = 'yes'
187 # elif winsys == 'cocoa'
188 # need_win_cocoa = 'yes'
189 # elif winsys == 'eagl'
190 # need_win_eagl = 'yes'
191 # elif winsys == 'dispmanx'
192 # need_win_dispmanx = 'yes'
194 error('Unsupported GL winsys provided ' + platform)
199 gl_include_header = '''
201 # pragma GCC diagnostic push
202 # pragma GCC diagnostic ignored "-Wredundant-decls"
204 #ifndef GL_GLEXT_PROTOTYPES
205 #define GL_GLEXT_PROTOTYPES 1
209 # Desktop OpenGL checks
210 gl_dep = unneeded_dep
211 glx_dep = unneeded_dep
212 if need_api_opengl != 'no' and need_platform_glx != 'no'
213 gl_dep = dependency('GL', required : false)
214 if not gl_dep.found()
215 # if host_machine.system() == 'windows'
216 # gl_dep = cc.find_library('opengl32', required : false)
217 # elif host_machine.system() == 'darwin'
218 # gl_dep = cc.find_library('OpenGL', required : false)
220 gl_dep = cc.find_library('GL', required : false)
223 if not gl_dep.found() and need_api_opengl == 'yes'
224 error ('Could not find requested OpenGL library')
229 if need_api_opengl == 'no'
230 gl_dep = unneeded_dep
232 if need_platform_glx == 'no'
233 glx_dep = unneeded_dep
236 opengl_includes = '''
238 # include <OpenGL/OpenGL.h>
239 # include <OpenGL/gl.h>
240 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
241 # define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
242 # include <OpenGL/gl3.h>
246 # if __WIN32__ || _WIN32
247 # include <GL/glext.h>
254 gles2_dep = unneeded_dep
255 if need_api_gles2 != 'no'
256 gles2_dep = dependency('GLESv2', required : false)
257 if not gles2_dep.found()
258 # if host_machine.system() == 'windows'
259 # elif host_machine.system() == 'darwin'
260 # gles2_dep = cc.find_library('GLESv2', required : false)
262 gles2_dep = cc.find_library('GLESv2', required : false)
265 if not gles2_dep.found() and need_api_gles2 == 'yes'
266 error ('Could not find requested OpenGL ES library')
270 gles3_h = gles2_dep.found() and cc.has_header('GLES3/gl3.h', required : false, dependencies : gles2_dep)
273 #ifdef HAVE_IOS /* FIXME */
274 # include <OpenGLES/ES2/gl.h>
275 # include <OpenGLES/ES2/glext.h>
279 # include <GLES3/gl3.h>
280 # include <GLES3/gl3ext.h>'''
283 # include <GLES2/gl2.h>
284 # include <GLES2/gl2ext.h>'''
291 # can we include both gles2 and opengl headers?
292 if gles2_dep.found() and gl_dep.found()
293 gl_include_block = gl_include_header + gles_includes + opengl_includes
294 if not cc.compiles('void f (void) {}', prefix : gl_include_block, dependencies : [gles2_dep, gl_dep] )
295 message ('Cannot include both OpenGL and OpenGL ES headers')
296 if need_gles2 != 'yes'
297 gles2_dep = unneeded_dep
298 elif need_opengl != 'yes'
299 gl_dep = unneeded_dep
301 error('Both OpenGL and OpenGL ES were requested but cannot be included together')
305 gl_include_block = gl_include_header
307 gl_include_block += gles_includes
310 gl_include_block += opengl_includes
314 gl_lib_deps += gles2_dep
315 glconf.set10('GST_GL_HAVE_GLES2', 1)
317 glconf.set10('GST_GL_HAVE_GLES3', 1)
319 enabled_gl_apis += 'gles2'
323 gl_lib_deps += gl_dep
324 glconf.set10('GST_GL_HAVE_OPENGL', 1)
325 enabled_gl_apis += 'opengl'
329 egl_dep = unneeded_dep
330 if need_platform_egl != 'no'
331 egl_dep = dependency('EGL', required : false)
332 if not egl_dep.found()
333 egl_dep = cc.find_library('EGL', required : false)
335 if not egl_dep.found() and need_platform_egl == 'yes'
336 error ('Could not find requested EGL library')
343 'egl/gstglcontext_egl.c',
344 'egl/gstgldisplay_egl.c',
345 'egl/gstglmemoryegl.c',
350 'egl/gstglcontext_egl.h',
351 'egl/gstgldisplay_egl.h',
352 'egl/gstglmemoryegl.h',
354 gl_platform_deps += egl_dep
355 glconf.set10('GST_GL_HAVE_PLATFORM_EGL', 1)
357 if cc.has_header('libdrm/drm_fourcc.h', required : false)
358 gl_misc_deps += gstallocators_dep
359 glconf.set10('GST_GL_HAVE_DMABUF', 1)
364 #include <EGL/eglext.h>
368 enabled_gl_platforms += 'egl'
372 wayland_client_dep = unneeded_dep
373 wayland_cursor_dep = unneeded_dep
374 wayland_egl_dep = unneeded_dep
375 if need_win_wayland != 'no'
376 if need_win_wayland == 'yes'
377 if need_platform_egl == 'no'
378 error('Impossible situation requested: Cannot use Wayland without EGL support')
381 if not egl_dep.found()
382 if need_win_wayland == 'yes'
383 error ('Could not find EGL libraries for wayland')
385 message ('Could not find EGL libraries for wayland')
388 wayland_client_dep = dependency('wayland-client', version : '>= 1.0', required : false)
389 wayland_cursor_dep = dependency('wayland-cursor', version : '>= 1.0', required : false)
390 wayland_egl_dep = dependency('wayland-egl', version : '>= 1.0', required : false)
392 if wayland_client_dep.found() and wayland_cursor_dep.found() and wayland_egl_dep.found()
394 'wayland/gstgldisplay_wayland.c',
395 'wayland/gstglwindow_wayland_egl.c',
396 'wayland/wayland_event_source.c',
398 glconf.set('GST_GL_HAVE_WINDOW_WAYLAND', 1)
399 gl_winsys_deps += [wayland_client_dep, wayland_cursor_dep, wayland_egl_dep]
400 enabled_gl_winsys += 'wayland'
402 if need_win_wayland == 'yes'
403 error ('Could not find requested Wayland libraries')
405 wayland_client_dep = unneeded_dep
406 wayland_cursor_dep = unneeded_dep
407 wayland_egl_dep = unneeded_dep
413 if need_platform_glx == 'yes'
414 if need_win_x11 == 'no'
415 error('Impossible situation requested: Cannot use GLX without X11 support')
416 elif need_api_opengl == 'no'
417 error('Impossible situation requested: Cannot use GLX without the OpenGL library')
421 if need_win_x11 != 'no'
424 'x11/gstgldisplay_x11.c',
425 'x11/gstglwindow_x11.c',
426 'x11/x11_event_source.c',
429 'x11/gstgldisplay_x11.h',
431 glconf.set('GST_GL_HAVE_WINDOW_X11', 1)
432 gl_winsys_deps += x11_dep
433 enabled_gl_winsys += 'x11'
435 if need_platform_glx != 'no' and glx_dep.found()
436 glconf.set('GST_GL_HAVE_PLATFORM_GLX', 1)
438 'x11/gstglcontext_glx.c',
440 # GLX is in the opengl library on linux
441 gl_platform_deps += glx_dep
442 enabled_gl_platforms += 'glx'
444 elif need_win_x11 == 'yes'
445 error ('Could not find requested X11 libraries')
450 if need_platform_wgl == 'yes'
451 if need_win_win32 == 'no'
452 error('Impossible situation requested: Cannot use WGL without the win32 window system')
457 #if need_platform_wgl != 'no' and need_win_win32 != 'no'
458 # gdi_dep = cc.find_library('gdi32', required : false)
460 # if cc.has_header('GL/wglext.h') and gdi_dep.found() and gl_dep.found()
461 # gl_platform_deps += gdi_dep
463 # 'win32/gstglwindow_win32.c',
464 # 'win32/gstglwindow_win32.c',
466 # enabled_gl_winsys += 'win32'
467 # enabled_gl_platforms += 'wgl'
471 if host_machine.system() == 'darwin'
472 # FIXME: how to know if we're on iOS or OS X?
473 # gl_cocoa_headers += [
474 # 'gstglcontext_cocoa.h',
475 # 'gstglcaopengllayer.h',
479 # TODO: Add rest of gl config here.
480 # --with-{egl,gles2,opengl}-module-name
481 # rpi, arm-mali, iOS, OS X, win32 specific support
484 if gl_lib_deps.length() == 0
485 message('No OpenGL API libraries found or requested')
488 if gl_platform_deps.length() == 0
489 message('No OpenGL Platforms found or requested')
492 if gl_winsys_deps.length() == 0
493 message('No OpenGL Window systems found or requested')
498 # find some types that may or may not be defined
499 if cc.has_type('GLeglImageOES', prefix : gl_include_block, dependencies : gl_lib_deps)
500 glconf.set('GST_GL_HAVE_GLEGLIMAGEOES', 1)
502 if cc.has_type('GLchar', prefix : gl_include_block, dependencies : gl_lib_deps)
503 glconf.set('GST_GL_HAVE_GLCHAR', 1)
505 if cc.has_type('GLsizeiptr', prefix : gl_include_block, dependencies : gl_lib_deps)
506 glconf.set('GST_GL_HAVE_GLSIZEIPTR', 1)
508 if cc.has_type('GLintptr', prefix : gl_include_block, dependencies : gl_lib_deps)
509 glconf.set('GST_GL_HAVE_GLINTPTR', 1)
511 if cc.has_type('GLsync', prefix : gl_include_block, dependencies : gl_lib_deps)
512 glconf.set('GST_GL_HAVE_GLSYNC', 1)
514 if cc.has_type('GLuint64', prefix : gl_include_block, dependencies : gl_lib_deps)
515 glconf.set('GST_GL_HAVE_GLUINT64', 1)
517 if cc.has_type('GLint64', prefix : gl_include_block, dependencies : gl_lib_deps)
518 glconf.set('GST_GL_HAVE_GLINT64', 1)
520 if egl_dep.found() and cc.has_type('EGLAttrib', prefix : gl_include_block + egl_includes, dependencies : gl_lib_deps + [egl_dep])
521 glconf.set('GST_GL_HAVE_EGLATTRIB', 1)
524 message('Building libgstgl with GL api: ' + ' '.join(enabled_gl_apis))
525 message('Building libgstgl with GL platform: ' + ' '.join(enabled_gl_platforms))
526 message('Building libgstgl with GL winsys: ' + ' '.join(enabled_gl_winsys))
528 install_headers(gl_headers, subdir : 'gstreamer-1.0/gst/gl')
529 install_headers(gl_cocoa_headers, subdir : 'gstreamer-1.0/gst/gl/cocoa')
530 install_headers(gl_egl_headers, subdir : 'gstreamer-1.0/gst/gl/egl')
531 install_headers(gl_prototype_headers, subdir : 'gstreamer-1.0/gst/gl/glprototypes')
532 install_headers(gl_x11_headers, subdir : 'gstreamer-1.0/gst/gl/x11')
534 configure_file(input : 'gstglconfig.h.meson',
535 output : 'gstglconfig.h',
536 install_dir : get_option('libdir') + '/gstreamer-1.0/include/gst/gl',
537 configuration : glconf)
539 gstgl = library('gstgl-' + api_version,
541 c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'],
542 include_directories : [configinc, libsinc],
543 version : libversion,
544 soversion : soversion,
546 dependencies : [gstbase_dep, gstvideo_dep, gmodule_dep,
547 gl_lib_deps, gl_platform_deps, gl_winsys_deps, gl_misc_deps],
548 # FIXME: This symbol list is generated on Linux, so this is wrong for Windows
549 vs_module_defs: vs_module_defs_dir + 'libgstgl.def',
553 gstgl_dep = declare_dependency(link_with : gstgl,
554 include_directories : [libsinc],
555 dependencies : [gstbase_dep, gstvideo_dep])