From b014856aa214bc24b104cf801823513983cf1ac5 Mon Sep 17 00:00:00 2001 From: Bogdan Barbu Date: Thu, 21 May 2026 03:03:59 +0300 Subject: [PATCH] Add EGL support, remove old SH API, update all examples, add new OpenGL/OpenVG interleaving example (raw OpenGL background and foreground border/marker, OpenVG rounded rectangle panel) --- .gitignore | 4 +- README.md | 54 ++- config.h.in | 21 +- configure.in | 124 +++--- examples/Makefile.am | 21 +- examples/Makefile.in | 316 +++++++++++--- examples/test.c | 319 ++++++++++---- examples/test.h | 12 +- examples/test_egl_gl_vg.c | 176 ++++++++ examples/test_pbuffer.c | 106 +++++ examples/test_tiger_shader.c | 84 ++-- include/vg/openvg.h | 4 - src/Makefile.am | 7 +- src/Makefile.in | 165 +++++-- src/shContext.c | 163 ++++--- src/shContext.h | 8 +- src/shEGL.c | 820 +++++++++++++++++++++++++++++++++++ src/shImage.c | 8 +- src/shPaint.c | 26 +- src/shaders.c | 369 +++++++--------- 20 files changed, 2180 insertions(+), 627 deletions(-) create mode 100644 examples/test_egl_gl_vg.c create mode 100644 examples/test_pbuffer.c create mode 100644 src/shEGL.c diff --git a/.gitignore b/.gitignore index a231deb..6d66894 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ aclocal.m4 autom4te.cache/ compile config.guess -config.h.in~ config.sub configure depcomp @@ -37,10 +36,11 @@ examples/test_radial examples/test_tiger examples/test_vgu examples/test_tiger_shader +examples/test_pbuffer +examples/test_egl_gl_vg *.libs *.la *.lo *.o *.deps *.dirstamp - diff --git a/README.md b/README.md index 32698d4..0395464 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ _**Note:** This project is based on https://github.com/tqm-dev/ShivaVG-2_ ### Prerequisites -- OpenGL development libraries and headers should be installed. -- freeglut must be installed for rendering on window system. +- OpenGL and EGL development libraries and headers should be installed. +- X11 development libraries and headers are needed for the example window harness on Unix-like systems. - jpeglib needs to be installed for example programs that use images. ### Compiling @@ -28,10 +28,16 @@ $ cd ShaderVG Under UNIX systems, execute configure and make: ``` $ sh autogen.sh -$ ./configure LIBS="-lGL -lglut -ljpeg" +$ ./configure $ make ``` +ShaderVG installs two libraries: `libOpenVG` contains the OpenVG implementation, +and `libShaderVGEGL` exposes the EGL entry points that bind OpenVG contexts to +real platform EGL displays and surfaces. Client applications should link +`libShaderVGEGL` before the platform EGL library so ShaderVG's OpenVG-aware EGL +entry points are used first. + ### Testing Move to examples directory, execute tests: @@ -70,6 +76,13 @@ $ ./test_tiger_shader An image is drawn in multiply mode with an image pattern fill paint. +#### test_pbuffer + Minimal EGL/OpenVG pbuffer smoke test that clears an offscreen surface + and reads one pixel back. + +#### test_egl_gl_vg + Interleaves raw OpenGL and OpenVG drawing on the same EGL surface. + ## Implementation status #### General @@ -198,26 +211,35 @@ vguComputeWarpQuadToQuad | NOT implemented ## Extensions -### Manipulate the OpenVG context as a temporary replacement for EGL: +### EGL OpenVG context binding -- VGboolean vgCreateContextSH(VGint width, VGint height) +ShaderVG clients create and bind OpenVG contexts through EGL: - Creates an OpenVG context on top of an existing OpenGL context - that should have been manually initialized by the user of the - library. Width and height specify the size of the rendering - surface. No multi-threading support has been implemented yet. - The context is created once per process. +```c +EGLDisplay dpy = eglGetDisplay(native_display); +eglInitialize(dpy, NULL, NULL); +eglBindAPI(EGL_OPENVG_API); -- void vgResizeSurfaceSH(VGint width, VGint height) +EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, + EGL_NONE +}; +eglChooseConfig(dpy, attribs, &config, 1, &count); - Should be called whenever the size of the surface changes (e.g. - the owner window of the OpenGL context is resized). +surface = eglCreateWindowSurface(dpy, config, native_window, NULL); +context = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL); +eglMakeCurrent(dpy, surface, surface, context); -- void vgDestroyContextSH() +vgClear(0, 0, width, height); +eglSwapBuffers(dpy, surface); +``` - Destroys the OpenVG context associated with the calling process. +`libShaderVGEGL` delegates native display, surface, and backing OpenGL context +creation to the platform EGL implementation. ShaderVG only supplies the OpenVG +implementation and the glue needed for `EGL_OPENVG_API` / `EGL_OPENVG_BIT` to +select a ShaderVG OpenVG context. ## License This project is licensed under the GNU Lesser General Public License v2.1 - see the [LICENSE](https://github.com/tqm-dev/ShaderVG/blob/master/COPYING) file for details - diff --git a/config.h.in b/config.h.in index d9c905c..05be91f 100644 --- a/config.h.in +++ b/config.h.in @@ -3,21 +3,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H +/* Define to 1 if you have the header file. */ +#undef HAVE_EGL_EGL_H + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_JPEGLIB_H -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -36,6 +36,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_XLIB_H + /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR @@ -60,10 +63,12 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* The size of `void *', as computed by sizeof. */ +/* The size of 'void *', as computed by sizeof. */ #undef SIZEOF_VOID_P -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C89 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* Version number of package */ diff --git a/configure.in b/configure.in index d38685d..cdd92d3 100644 --- a/configure.in +++ b/configure.in @@ -80,7 +80,9 @@ AC_CHECK_SIZEOF([void *]) # ============================================== # Check for math library -AC_CHECK_LIB([m],[cos]) +MATH_LIBS="" +AC_CHECK_LIB([m],[cos],[MATH_LIBS="-lm"]) +AC_SUBST([MATH_LIBS]) # ============================================== # Platform-specific directories and flags @@ -88,37 +90,42 @@ AC_CHECK_LIB([m],[cos]) case "${host}" in *darwin*) GL_DIR="OpenGL" - GLUT_DIR="GLUT" GL_LIB="-framework OpenGL" - GLUT_LIB="-framework GLUT" CONFIG_CFLAGS="" - CONFIG_LDFLAGS="-framework OpenGL -framework GLUT" + CONFIG_LDFLAGS="-framework OpenGL" CONFIG_LDADD="" ;; *mingw* | *cygwin*) GL_DIR="GL" - GLUT_DIR="GL" GL_LIB="-lGL" - GLUT_FLAGS="-lglut" CONFIG_CFLAGS="" CONFIG_LDFLAGS="" - CONFIG_LDADD="-lglut -lGL" ;; + CONFIG_LDADD="-lGL" ;; *) GL_DIR="GL" - GLUT_DIR="GL" GL_LIB="-lGL" - GLUT_LIB="-lglut" CONFIG_CFLAGS="" CONFIG_LDFLAGS="" - CONFIG_LDADD="-lglut -lGL" ;; + CONFIG_LDADD="-lGL" ;; esac +OPENGL_LIBS="$GL_LIB" +EGL_CFLAGS="" +DLOPEN_LIBS="" +NATIVE_WINDOW_CFLAGS="" +NATIVE_WINDOW_LIBS="" + AC_SUBST([CONFIG_CFLAGS]) AC_SUBST([CONFIG_LDFLAGS]) AC_SUBST([CONFIG_LDADD]) +AC_SUBST([OPENGL_LIBS]) +AC_SUBST([EGL_CFLAGS]) +AC_SUBST([DLOPEN_LIBS]) +AC_SUBST([NATIVE_WINDOW_CFLAGS]) +AC_SUBST([NATIVE_WINDOW_LIBS]) # ============================================== -# Check for OpenGL and GLUT headers +# Check for OpenGL and EGL headers AC_CHECK_HEADERS( [$GL_DIR/gl.h], @@ -129,18 +136,23 @@ AC_CHECK_HEADERS( [has_glu_h="yes"], [has_glu_h="no"]) AC_CHECK_HEADERS( - [$GLUT_DIR/glut.h], - [has_glut_h="yes"], [has_glut_h="no"]) + [EGL/egl.h], + [has_egl_h="yes"], [has_egl_h="no"]) -case "${host}" in -*linux*) - AC_CHECK_HEADERS( - [$GL_DIR/glx.h], - [has_glx_h]="yes", [has_glx_h]="no") ;; -esac +AC_MSG_CHECKING([for EGL/eglext.h]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[#include +#include +int main(void) { return 0; }]])], + [has_eglext_h="yes"; AC_MSG_RESULT([yes])], + [has_eglext_h="no"; AC_MSG_RESULT([no])]) + +AC_CHECK_HEADERS( + [X11/Xlib.h], + [has_x11_h="yes"], [has_x11_h="no"]) # =============================================== -# Check for OpenGL and GLUT libraries +# Check for OpenGL and native window libraries LDFLAGS="$LDFLAGS $GL_LIB" @@ -151,21 +163,15 @@ AC_LINK_IFELSE([ [has_gl="yes"] && [echo "yes"], [has_gl="no"] && [echo "no"]) -case "${host}" in -*linux*) - AC_CHECK_LIB( - [GL], glXGetProcAddress, - [has_glx="yes"], [has_glx="no"]) ;; -esac +AC_CHECK_LIB( + [X11], XOpenDisplay, + [has_x11="yes"; NATIVE_WINDOW_LIBS="-lX11"], + [has_x11="no"]) -LDFLAGS="$LDFLAGS $GLUT_LIB" - -echo -n "checking for GLUT library... " -AC_LINK_IFELSE([ - char glutInit(); - int main(void) {glutInit(); return 0;}], - [has_glut="yes"] && [echo "yes"], - [has_glut="no"] && [echo "no"]) +AC_CHECK_LIB( + [dl], dlopen, + [DLOPEN_LIBS="-ldl"], + [DLOPEN_LIBS=""]) LDFLAGS="" @@ -210,7 +216,7 @@ if test "x$build_test_pattern" = "xyes"; then fi fi -CFLASGS="" +CFLAGS="" LDFLAGS="" # ============================================== @@ -226,15 +232,20 @@ NO_GL_MSG=" Failed linking with GL library! ShaderVG cannot be built without OpenGL library. " -NO_GLX_H_MSG=" +NO_EGL_H_MSG=" + + EGL/egl.h header missing! ShaderVG cannot be built without + EGL headers. +" +NO_X11_H_MSG=" - glx.h header missing! ShaderVG cannot be build without - GLX headers. + X11/Xlib.h header missing! ShaderVG examples cannot be built + without X11 headers. " -NO_GLX_MSG=" +NO_X11_MSG=" - Failed linking with GLX library! ShaderVG cannot be built - without GLX library. + Failed linking with X11 library! ShaderVG examples cannot be built + without X11 library. " if test "x$has_gl_h" = "xno"; then @@ -245,20 +256,14 @@ if test "x$has_gl" = "xno"; then AC_MSG_FAILURE([$NO_GL_MSG]) fi -case "${host}" in -*linux*) - if test "x$has_glx_h" = "xno"; then - AC_MSG_FAILURE([$NO_GLX_H_MSG]) - fi - if test "x$has_glx" = "xno"; then - AC_MSG_FAILURE([$NO_GLX_MSG]) - fi ;; -esac +if test "x$has_egl_h" = "xno"; then + AC_MSG_FAILURE([$NO_EGL_H_MSG]) +fi # ======================================================== # Setup automake conditionals according to configuration -AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$has_glut_h" = "xyes"]) +AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$has_x11_h" = "xyes" -a "x$has_x11" = "xyes"]) AM_CONDITIONAL([BUILD_VGU], [test "x$build_test_vgu" = "xyes"]) AM_CONDITIONAL([BUILD_DASH], [test "x$build_test_dash" = "xyes"]) @@ -280,13 +285,12 @@ examples/Makefile # ============================================= #echo "GL headers present $has_gl_h" -#echo "GLX headers present $has_glx_h" -#echo "GLUT headers present $has_glut_h" +#echo "EGL headers present $has_egl_h" +#echo "X11 headers present $has_x11_h" #echo "JPEG headers present $has_jpeg_h" #echo "" #echo "GL library present $has_gl" -#echo "GLX library present $has_glx" -#echo "GLUT library present $has_glut" +#echo "X11 library present $has_x11" #echo "JPEG library present $has_jpeg" EXAMPLES_LIST=" @@ -303,17 +307,19 @@ ShaderVG will be compiled with the following example programs Pattern paint ${build_test_pattern} Blending ${build_test_blend} Tiger Shader ${build_test_tiger_shader} + Pbuffer smoke yes + EGL/OpenGL/OpenVG interop yes " -if test "x$has_glut_h" = "xno"; then +if test "x$has_x11_h" = "xno"; then echo "ShaderVG example programs will not be built because" - echo "the GLUT headers are missing!" + echo "the X11 headers are missing!" else - if test "x$has_glut" = "xno"; then + if test "x$has_x11" = "xno"; then echo "ShaderVG example programs will not be built because" - echo "linking to GLUT library failed!" + echo "linking to X11 library failed!" else diff --git a/examples/Makefile.am b/examples/Makefile.am index 1332bcb..8726dbf 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,18 +2,19 @@ INCLUDE_VG_DIR = $(top_builddir)/include LIB_VG_DIR = $(top_builddir)/src LIB_VG = ${LIB_VG_DIR}/libOpenVG.la +LIB_EGL = ${LIB_VG_DIR}/libShaderVGEGL.la # Variables which are common to all example programs # (Combine variables passed from configure script with # the local path to uninstalled library) EXAMPLE_SRCS = test.h test.c -EXAMPLE_CF = @CONFIG_CFLAGS@ -I${INCLUDE_VG_DIR} -I${prefix}/include -EXAMPLE_LA = @CONFIG_LDADD@ ${LIB_VG} +EXAMPLE_CF = @CONFIG_CFLAGS@ @EGL_CFLAGS@ @NATIVE_WINDOW_CFLAGS@ -I${INCLUDE_VG_DIR} -I${prefix}/include +EXAMPLE_LA = @CONFIG_LDADD@ @NATIVE_WINDOW_LIBS@ ${LIB_EGL} ${LIB_VG} EXAMPLE_LF = @CONFIG_LDFLAGS@ -L${prefix}/lib EXTRA_DIST = *.jpg *.png -noinst_PROGRAMS = +noinst_PROGRAMS = test_pbuffer test_egl_gl_vg if BUILD_VGU noinst_PROGRAMS += test_vgu @@ -85,6 +86,12 @@ test_blend_SOURCES =\ test_tiger_shader_SOURCES =\ ${EXAMPLE_SRCS} test_tiger_shader.c test_tiger_paths.c +test_pbuffer_SOURCES =\ + test_pbuffer.c + +test_egl_gl_vg_SOURCES =\ + ${EXAMPLE_SRCS} test_egl_gl_vg.c + test_vgu_CFLAGS = ${EXAMPLE_CF} test_vgu_LDADD = ${EXAMPLE_LA} test_vgu_LDFLAGS = ${EXAMPLE_LF} @@ -124,3 +131,11 @@ test_blend_LDFLAGS = ${EXAMPLE_LF} test_tiger_shader_CFLAGS = ${EXAMPLE_CF} test_tiger_shader_LDADD = ${EXAMPLE_LA} test_tiger_shader_LDFLAGS = ${EXAMPLE_LF} + +test_pbuffer_CFLAGS = ${EXAMPLE_CF} +test_pbuffer_LDADD = ${EXAMPLE_LA} +test_pbuffer_LDFLAGS = ${EXAMPLE_LF} + +test_egl_gl_vg_CFLAGS = ${EXAMPLE_CF} +test_egl_gl_vg_LDADD = ${EXAMPLE_LA} +test_egl_gl_vg_LDFLAGS = ${EXAMPLE_LF} diff --git a/examples/Makefile.in b/examples/Makefile.in index 5043153..c98279a 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. +# Makefile.in generated by automake 1.18.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2017 Free Software Foundation, Inc. +# Copyright (C) 1994-2025 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -70,6 +70,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -88,7 +90,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ +noinst_PROGRAMS = test_pbuffer$(EXEEXT) test_egl_gl_vg$(EXEEXT) \ + $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ $(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \ $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \ $(am__EXEEXT_10) @@ -127,7 +130,7 @@ am__objects_1 = test_blend-test.$(OBJEXT) am_test_blend_OBJECTS = $(am__objects_1) \ test_blend-test_blend.$(OBJEXT) test_blend_OBJECTS = $(am_test_blend_OBJECTS) -am__DEPENDENCIES_1 = $(LIB_VG) +am__DEPENDENCIES_1 = $(LIB_EGL) $(LIB_VG) test_blend_DEPENDENCIES = $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -143,16 +146,25 @@ test_dash_DEPENDENCIES = $(am__DEPENDENCIES_1) test_dash_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_dash_CFLAGS) \ $(CFLAGS) $(test_dash_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_3 = test_image-test.$(OBJEXT) -am_test_image_OBJECTS = $(am__objects_3) \ +am__objects_3 = test_egl_gl_vg-test.$(OBJEXT) +am_test_egl_gl_vg_OBJECTS = $(am__objects_3) \ + test_egl_gl_vg-test_egl_gl_vg.$(OBJEXT) +test_egl_gl_vg_OBJECTS = $(am_test_egl_gl_vg_OBJECTS) +test_egl_gl_vg_DEPENDENCIES = $(am__DEPENDENCIES_1) +test_egl_gl_vg_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(test_egl_gl_vg_CFLAGS) $(CFLAGS) $(test_egl_gl_vg_LDFLAGS) \ + $(LDFLAGS) -o $@ +am__objects_4 = test_image-test.$(OBJEXT) +am_test_image_OBJECTS = $(am__objects_4) \ test_image-test_image.$(OBJEXT) test_image_OBJECTS = $(am_test_image_OBJECTS) test_image_DEPENDENCIES = $(am__DEPENDENCIES_1) test_image_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_image_CFLAGS) \ $(CFLAGS) $(test_image_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_4 = test_interpolate-test.$(OBJEXT) -am_test_interpolate_OBJECTS = $(am__objects_4) \ +am__objects_5 = test_interpolate-test.$(OBJEXT) +am_test_interpolate_OBJECTS = $(am__objects_5) \ test_interpolate-test_interpolate.$(OBJEXT) test_interpolate_OBJECTS = $(am_test_interpolate_OBJECTS) test_interpolate_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -160,32 +172,38 @@ test_interpolate_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_interpolate_CFLAGS) $(CFLAGS) \ $(test_interpolate_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_5 = test_linear-test.$(OBJEXT) -am_test_linear_OBJECTS = $(am__objects_5) \ +am__objects_6 = test_linear-test.$(OBJEXT) +am_test_linear_OBJECTS = $(am__objects_6) \ test_linear-test_linear.$(OBJEXT) test_linear_OBJECTS = $(am_test_linear_OBJECTS) test_linear_DEPENDENCIES = $(am__DEPENDENCIES_1) test_linear_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_linear_CFLAGS) \ $(CFLAGS) $(test_linear_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_6 = test_pattern-test.$(OBJEXT) -am_test_pattern_OBJECTS = $(am__objects_6) \ +am__objects_7 = test_pattern-test.$(OBJEXT) +am_test_pattern_OBJECTS = $(am__objects_7) \ test_pattern-test_pattern.$(OBJEXT) test_pattern_OBJECTS = $(am_test_pattern_OBJECTS) test_pattern_DEPENDENCIES = $(am__DEPENDENCIES_1) test_pattern_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_pattern_CFLAGS) \ $(CFLAGS) $(test_pattern_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_7 = test_radial-test.$(OBJEXT) -am_test_radial_OBJECTS = $(am__objects_7) \ +am_test_pbuffer_OBJECTS = test_pbuffer-test_pbuffer.$(OBJEXT) +test_pbuffer_OBJECTS = $(am_test_pbuffer_OBJECTS) +test_pbuffer_DEPENDENCIES = $(am__DEPENDENCIES_1) +test_pbuffer_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_pbuffer_CFLAGS) \ + $(CFLAGS) $(test_pbuffer_LDFLAGS) $(LDFLAGS) -o $@ +am__objects_8 = test_radial-test.$(OBJEXT) +am_test_radial_OBJECTS = $(am__objects_8) \ test_radial-test_radial.$(OBJEXT) test_radial_OBJECTS = $(am_test_radial_OBJECTS) test_radial_DEPENDENCIES = $(am__DEPENDENCIES_1) test_radial_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_radial_CFLAGS) \ $(CFLAGS) $(test_radial_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_8 = test_tiger-test.$(OBJEXT) -am_test_tiger_OBJECTS = $(am__objects_8) \ +am__objects_9 = test_tiger-test.$(OBJEXT) +am_test_tiger_OBJECTS = $(am__objects_9) \ test_tiger-test_tiger.$(OBJEXT) \ test_tiger-test_tiger_paths.$(OBJEXT) test_tiger_OBJECTS = $(am_test_tiger_OBJECTS) @@ -193,8 +211,8 @@ test_tiger_DEPENDENCIES = $(am__DEPENDENCIES_1) test_tiger_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_tiger_CFLAGS) \ $(CFLAGS) $(test_tiger_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_9 = test_tiger_shader-test.$(OBJEXT) -am_test_tiger_shader_OBJECTS = $(am__objects_9) \ +am__objects_10 = test_tiger_shader-test.$(OBJEXT) +am_test_tiger_shader_OBJECTS = $(am__objects_10) \ test_tiger_shader-test_tiger_shader.$(OBJEXT) \ test_tiger_shader-test_tiger_paths.$(OBJEXT) test_tiger_shader_OBJECTS = $(am_test_tiger_shader_OBJECTS) @@ -203,8 +221,8 @@ test_tiger_shader_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(test_tiger_shader_CFLAGS) $(CFLAGS) \ $(test_tiger_shader_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_10 = test_vgu-test.$(OBJEXT) -am_test_vgu_OBJECTS = $(am__objects_10) test_vgu-test_vgu.$(OBJEXT) +am__objects_11 = test_vgu-test.$(OBJEXT) +am_test_vgu_OBJECTS = $(am__objects_11) test_vgu-test_vgu.$(OBJEXT) test_vgu_OBJECTS = $(am_test_vgu_OBJECTS) test_vgu_DEPENDENCIES = $(am__DEPENDENCIES_1) test_vgu_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -224,7 +242,31 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/test_blend-test.Po \ + ./$(DEPDIR)/test_blend-test_blend.Po \ + ./$(DEPDIR)/test_dash-test.Po \ + ./$(DEPDIR)/test_dash-test_dash.Po \ + ./$(DEPDIR)/test_egl_gl_vg-test.Po \ + ./$(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po \ + ./$(DEPDIR)/test_image-test.Po \ + ./$(DEPDIR)/test_image-test_image.Po \ + ./$(DEPDIR)/test_interpolate-test.Po \ + ./$(DEPDIR)/test_interpolate-test_interpolate.Po \ + ./$(DEPDIR)/test_linear-test.Po \ + ./$(DEPDIR)/test_linear-test_linear.Po \ + ./$(DEPDIR)/test_pattern-test.Po \ + ./$(DEPDIR)/test_pattern-test_pattern.Po \ + ./$(DEPDIR)/test_pbuffer-test_pbuffer.Po \ + ./$(DEPDIR)/test_radial-test.Po \ + ./$(DEPDIR)/test_radial-test_radial.Po \ + ./$(DEPDIR)/test_tiger-test.Po \ + ./$(DEPDIR)/test_tiger-test_tiger.Po \ + ./$(DEPDIR)/test_tiger-test_tiger_paths.Po \ + ./$(DEPDIR)/test_tiger_shader-test.Po \ + ./$(DEPDIR)/test_tiger_shader-test_tiger_paths.Po \ + ./$(DEPDIR)/test_tiger_shader-test_tiger_shader.Po \ + ./$(DEPDIR)/test_vgu-test.Po ./$(DEPDIR)/test_vgu-test_vgu.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -245,13 +287,15 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(test_blend_SOURCES) $(test_dash_SOURCES) \ - $(test_image_SOURCES) $(test_interpolate_SOURCES) \ - $(test_linear_SOURCES) $(test_pattern_SOURCES) \ + $(test_egl_gl_vg_SOURCES) $(test_image_SOURCES) \ + $(test_interpolate_SOURCES) $(test_linear_SOURCES) \ + $(test_pattern_SOURCES) $(test_pbuffer_SOURCES) \ $(test_radial_SOURCES) $(test_tiger_SOURCES) \ $(test_tiger_shader_SOURCES) $(test_vgu_SOURCES) DIST_SOURCES = $(test_blend_SOURCES) $(test_dash_SOURCES) \ - $(test_image_SOURCES) $(test_interpolate_SOURCES) \ - $(test_linear_SOURCES) $(test_pattern_SOURCES) \ + $(test_egl_gl_vg_SOURCES) $(test_image_SOURCES) \ + $(test_interpolate_SOURCES) $(test_linear_SOURCES) \ + $(test_pattern_SOURCES) $(test_pbuffer_SOURCES) \ $(test_radial_SOURCES) $(test_tiger_SOURCES) \ $(test_tiger_shader_SOURCES) $(test_vgu_SOURCES) am__can_run_installinfo = \ @@ -276,8 +320,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ @@ -294,20 +336,25 @@ CFLAGS = @CFLAGS@ CONFIG_CFLAGS = @CONFIG_CFLAGS@ CONFIG_LDADD = @CONFIG_LDADD@ CONFIG_LDFLAGS = @CONFIG_LDFLAGS@ -CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ +DLOPEN_LIBS = @DLOPEN_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EGL_CFLAGS = @EGL_CFLAGS@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -325,11 +372,15 @@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ +MATH_LIBS = @MATH_LIBS@ MKDIR_P = @MKDIR_P@ +NATIVE_WINDOW_CFLAGS = @NATIVE_WINDOW_CFLAGS@ +NATIVE_WINDOW_LIBS = @NATIVE_WINDOW_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OPENGL_LIBS = @OPENGL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -356,8 +407,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -404,13 +457,14 @@ top_srcdir = @top_srcdir@ INCLUDE_VG_DIR = $(top_builddir)/include LIB_VG_DIR = $(top_builddir)/src LIB_VG = ${LIB_VG_DIR}/libOpenVG.la +LIB_EGL = ${LIB_VG_DIR}/libShaderVGEGL.la # Variables which are common to all example programs # (Combine variables passed from configure script with # the local path to uninstalled library) EXAMPLE_SRCS = test.h test.c -EXAMPLE_CF = @CONFIG_CFLAGS@ -I${INCLUDE_VG_DIR} -I${prefix}/include -EXAMPLE_LA = @CONFIG_LDADD@ ${LIB_VG} +EXAMPLE_CF = @CONFIG_CFLAGS@ @EGL_CFLAGS@ @NATIVE_WINDOW_CFLAGS@ -I${INCLUDE_VG_DIR} -I${prefix}/include +EXAMPLE_LA = @CONFIG_LDADD@ @NATIVE_WINDOW_LIBS@ ${LIB_EGL} ${LIB_VG} EXAMPLE_LF = @CONFIG_LDFLAGS@ -L${prefix}/lib EXTRA_DIST = *.jpg *.png test_vgu_SOURCES = \ @@ -443,6 +497,12 @@ test_blend_SOURCES = \ test_tiger_shader_SOURCES = \ ${EXAMPLE_SRCS} test_tiger_shader.c test_tiger_paths.c +test_pbuffer_SOURCES = \ + test_pbuffer.c + +test_egl_gl_vg_SOURCES = \ + ${EXAMPLE_SRCS} test_egl_gl_vg.c + test_vgu_CFLAGS = ${EXAMPLE_CF} test_vgu_LDADD = ${EXAMPLE_LA} test_vgu_LDFLAGS = ${EXAMPLE_LF} @@ -473,6 +533,12 @@ test_blend_LDFLAGS = ${EXAMPLE_LF} test_tiger_shader_CFLAGS = ${EXAMPLE_CF} test_tiger_shader_LDADD = ${EXAMPLE_LA} test_tiger_shader_LDFLAGS = ${EXAMPLE_LF} +test_pbuffer_CFLAGS = ${EXAMPLE_CF} +test_pbuffer_LDADD = ${EXAMPLE_LA} +test_pbuffer_LDFLAGS = ${EXAMPLE_LF} +test_egl_gl_vg_CFLAGS = ${EXAMPLE_CF} +test_egl_gl_vg_LDADD = ${EXAMPLE_LA} +test_egl_gl_vg_LDFLAGS = ${EXAMPLE_LF} all: all-am .SUFFIXES: @@ -494,8 +560,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -508,13 +574,8 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list + $(am__rm_f) $(noinst_PROGRAMS) + test -z "$(EXEEXT)" || $(am__rm_f) $(noinst_PROGRAMS:$(EXEEXT)=) test_blend$(EXEEXT): $(test_blend_OBJECTS) $(test_blend_DEPENDENCIES) $(EXTRA_test_blend_DEPENDENCIES) @rm -f test_blend$(EXEEXT) @@ -524,6 +585,10 @@ test_dash$(EXEEXT): $(test_dash_OBJECTS) $(test_dash_DEPENDENCIES) $(EXTRA_test_ @rm -f test_dash$(EXEEXT) $(AM_V_CCLD)$(test_dash_LINK) $(test_dash_OBJECTS) $(test_dash_LDADD) $(LIBS) +test_egl_gl_vg$(EXEEXT): $(test_egl_gl_vg_OBJECTS) $(test_egl_gl_vg_DEPENDENCIES) $(EXTRA_test_egl_gl_vg_DEPENDENCIES) + @rm -f test_egl_gl_vg$(EXEEXT) + $(AM_V_CCLD)$(test_egl_gl_vg_LINK) $(test_egl_gl_vg_OBJECTS) $(test_egl_gl_vg_LDADD) $(LIBS) + test_image$(EXEEXT): $(test_image_OBJECTS) $(test_image_DEPENDENCIES) $(EXTRA_test_image_DEPENDENCIES) @rm -f test_image$(EXEEXT) $(AM_V_CCLD)$(test_image_LINK) $(test_image_OBJECTS) $(test_image_LDADD) $(LIBS) @@ -540,6 +605,10 @@ test_pattern$(EXEEXT): $(test_pattern_OBJECTS) $(test_pattern_DEPENDENCIES) $(EX @rm -f test_pattern$(EXEEXT) $(AM_V_CCLD)$(test_pattern_LINK) $(test_pattern_OBJECTS) $(test_pattern_LDADD) $(LIBS) +test_pbuffer$(EXEEXT): $(test_pbuffer_OBJECTS) $(test_pbuffer_DEPENDENCIES) $(EXTRA_test_pbuffer_DEPENDENCIES) + @rm -f test_pbuffer$(EXEEXT) + $(AM_V_CCLD)$(test_pbuffer_LINK) $(test_pbuffer_OBJECTS) $(test_pbuffer_LDADD) $(LIBS) + test_radial$(EXEEXT): $(test_radial_OBJECTS) $(test_radial_DEPENDENCIES) $(EXTRA_test_radial_DEPENDENCIES) @rm -f test_radial$(EXEEXT) $(AM_V_CCLD)$(test_radial_LINK) $(test_radial_OBJECTS) $(test_radial_LDADD) $(LIBS) @@ -562,28 +631,37 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_blend-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_blend-test_blend.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dash-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dash-test_dash.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image-test_image.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_interpolate-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_interpolate-test_interpolate.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_linear-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_linear-test_linear.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_pattern-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_pattern-test_pattern.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_radial-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_radial-test_radial.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test_tiger.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test_tiger_paths.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test_tiger_paths.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test_tiger_shader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vgu-test.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vgu-test_vgu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_blend-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_blend-test_blend.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dash-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dash-test_dash.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_egl_gl_vg-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_image-test_image.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_interpolate-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_interpolate-test_interpolate.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_linear-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_linear-test_linear.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_pattern-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_pattern-test_pattern.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_pbuffer-test_pbuffer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_radial-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_radial-test_radial.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test_tiger.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger-test_tiger_paths.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test_tiger_paths.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_tiger_shader-test_tiger_shader.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vgu-test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_vgu-test_vgu.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @: >>$@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -662,6 +740,34 @@ test_dash-test_dash.obj: test_dash.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_dash_CFLAGS) $(CFLAGS) -c -o test_dash-test_dash.obj `if test -f 'test_dash.c'; then $(CYGPATH_W) 'test_dash.c'; else $(CYGPATH_W) '$(srcdir)/test_dash.c'; fi` +test_egl_gl_vg-test.o: test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -MT test_egl_gl_vg-test.o -MD -MP -MF $(DEPDIR)/test_egl_gl_vg-test.Tpo -c -o test_egl_gl_vg-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_egl_gl_vg-test.Tpo $(DEPDIR)/test_egl_gl_vg-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test.c' object='test_egl_gl_vg-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -c -o test_egl_gl_vg-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c + +test_egl_gl_vg-test.obj: test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -MT test_egl_gl_vg-test.obj -MD -MP -MF $(DEPDIR)/test_egl_gl_vg-test.Tpo -c -o test_egl_gl_vg-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_egl_gl_vg-test.Tpo $(DEPDIR)/test_egl_gl_vg-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test.c' object='test_egl_gl_vg-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -c -o test_egl_gl_vg-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` + +test_egl_gl_vg-test_egl_gl_vg.o: test_egl_gl_vg.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -MT test_egl_gl_vg-test_egl_gl_vg.o -MD -MP -MF $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Tpo -c -o test_egl_gl_vg-test_egl_gl_vg.o `test -f 'test_egl_gl_vg.c' || echo '$(srcdir)/'`test_egl_gl_vg.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Tpo $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_egl_gl_vg.c' object='test_egl_gl_vg-test_egl_gl_vg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -c -o test_egl_gl_vg-test_egl_gl_vg.o `test -f 'test_egl_gl_vg.c' || echo '$(srcdir)/'`test_egl_gl_vg.c + +test_egl_gl_vg-test_egl_gl_vg.obj: test_egl_gl_vg.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -MT test_egl_gl_vg-test_egl_gl_vg.obj -MD -MP -MF $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Tpo -c -o test_egl_gl_vg-test_egl_gl_vg.obj `if test -f 'test_egl_gl_vg.c'; then $(CYGPATH_W) 'test_egl_gl_vg.c'; else $(CYGPATH_W) '$(srcdir)/test_egl_gl_vg.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Tpo $(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_egl_gl_vg.c' object='test_egl_gl_vg-test_egl_gl_vg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_egl_gl_vg_CFLAGS) $(CFLAGS) -c -o test_egl_gl_vg-test_egl_gl_vg.obj `if test -f 'test_egl_gl_vg.c'; then $(CYGPATH_W) 'test_egl_gl_vg.c'; else $(CYGPATH_W) '$(srcdir)/test_egl_gl_vg.c'; fi` + test_image-test.o: test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_image_CFLAGS) $(CFLAGS) -MT test_image-test.o -MD -MP -MF $(DEPDIR)/test_image-test.Tpo -c -o test_image-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_image-test.Tpo $(DEPDIR)/test_image-test.Po @@ -774,6 +880,20 @@ test_pattern-test_pattern.obj: test_pattern.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pattern_CFLAGS) $(CFLAGS) -c -o test_pattern-test_pattern.obj `if test -f 'test_pattern.c'; then $(CYGPATH_W) 'test_pattern.c'; else $(CYGPATH_W) '$(srcdir)/test_pattern.c'; fi` +test_pbuffer-test_pbuffer.o: test_pbuffer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pbuffer_CFLAGS) $(CFLAGS) -MT test_pbuffer-test_pbuffer.o -MD -MP -MF $(DEPDIR)/test_pbuffer-test_pbuffer.Tpo -c -o test_pbuffer-test_pbuffer.o `test -f 'test_pbuffer.c' || echo '$(srcdir)/'`test_pbuffer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_pbuffer-test_pbuffer.Tpo $(DEPDIR)/test_pbuffer-test_pbuffer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_pbuffer.c' object='test_pbuffer-test_pbuffer.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pbuffer_CFLAGS) $(CFLAGS) -c -o test_pbuffer-test_pbuffer.o `test -f 'test_pbuffer.c' || echo '$(srcdir)/'`test_pbuffer.c + +test_pbuffer-test_pbuffer.obj: test_pbuffer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pbuffer_CFLAGS) $(CFLAGS) -MT test_pbuffer-test_pbuffer.obj -MD -MP -MF $(DEPDIR)/test_pbuffer-test_pbuffer.Tpo -c -o test_pbuffer-test_pbuffer.obj `if test -f 'test_pbuffer.c'; then $(CYGPATH_W) 'test_pbuffer.c'; else $(CYGPATH_W) '$(srcdir)/test_pbuffer.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_pbuffer-test_pbuffer.Tpo $(DEPDIR)/test_pbuffer-test_pbuffer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_pbuffer.c' object='test_pbuffer-test_pbuffer.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_pbuffer_CFLAGS) $(CFLAGS) -c -o test_pbuffer-test_pbuffer.obj `if test -f 'test_pbuffer.c'; then $(CYGPATH_W) 'test_pbuffer.c'; else $(CYGPATH_W) '$(srcdir)/test_pbuffer.c'; fi` + test_radial-test.o: test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_radial_CFLAGS) $(CFLAGS) -MT test_radial-test.o -MD -MP -MF $(DEPDIR)/test_radial-test.Tpo -c -o test_radial-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_radial-test.Tpo $(DEPDIR)/test_radial-test.Po @@ -972,7 +1092,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1030,8 +1153,8 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -1042,7 +1165,31 @@ clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/test_blend-test.Po + -rm -f ./$(DEPDIR)/test_blend-test_blend.Po + -rm -f ./$(DEPDIR)/test_dash-test.Po + -rm -f ./$(DEPDIR)/test_dash-test_dash.Po + -rm -f ./$(DEPDIR)/test_egl_gl_vg-test.Po + -rm -f ./$(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po + -rm -f ./$(DEPDIR)/test_image-test.Po + -rm -f ./$(DEPDIR)/test_image-test_image.Po + -rm -f ./$(DEPDIR)/test_interpolate-test.Po + -rm -f ./$(DEPDIR)/test_interpolate-test_interpolate.Po + -rm -f ./$(DEPDIR)/test_linear-test.Po + -rm -f ./$(DEPDIR)/test_linear-test_linear.Po + -rm -f ./$(DEPDIR)/test_pattern-test.Po + -rm -f ./$(DEPDIR)/test_pattern-test_pattern.Po + -rm -f ./$(DEPDIR)/test_pbuffer-test_pbuffer.Po + -rm -f ./$(DEPDIR)/test_radial-test.Po + -rm -f ./$(DEPDIR)/test_radial-test_radial.Po + -rm -f ./$(DEPDIR)/test_tiger-test.Po + -rm -f ./$(DEPDIR)/test_tiger-test_tiger.Po + -rm -f ./$(DEPDIR)/test_tiger-test_tiger_paths.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test_tiger_paths.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test_tiger_shader.Po + -rm -f ./$(DEPDIR)/test_vgu-test.Po + -rm -f ./$(DEPDIR)/test_vgu-test_vgu.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1088,7 +1235,31 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/test_blend-test.Po + -rm -f ./$(DEPDIR)/test_blend-test_blend.Po + -rm -f ./$(DEPDIR)/test_dash-test.Po + -rm -f ./$(DEPDIR)/test_dash-test_dash.Po + -rm -f ./$(DEPDIR)/test_egl_gl_vg-test.Po + -rm -f ./$(DEPDIR)/test_egl_gl_vg-test_egl_gl_vg.Po + -rm -f ./$(DEPDIR)/test_image-test.Po + -rm -f ./$(DEPDIR)/test_image-test_image.Po + -rm -f ./$(DEPDIR)/test_interpolate-test.Po + -rm -f ./$(DEPDIR)/test_interpolate-test_interpolate.Po + -rm -f ./$(DEPDIR)/test_linear-test.Po + -rm -f ./$(DEPDIR)/test_linear-test_linear.Po + -rm -f ./$(DEPDIR)/test_pattern-test.Po + -rm -f ./$(DEPDIR)/test_pattern-test_pattern.Po + -rm -f ./$(DEPDIR)/test_pbuffer-test_pbuffer.Po + -rm -f ./$(DEPDIR)/test_radial-test.Po + -rm -f ./$(DEPDIR)/test_radial-test_radial.Po + -rm -f ./$(DEPDIR)/test_tiger-test.Po + -rm -f ./$(DEPDIR)/test_tiger-test_tiger.Po + -rm -f ./$(DEPDIR)/test_tiger-test_tiger_paths.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test_tiger_paths.Po + -rm -f ./$(DEPDIR)/test_tiger_shader-test_tiger_shader.Po + -rm -f ./$(DEPDIR)/test_vgu-test.Po + -rm -f ./$(DEPDIR)/test_vgu-test_vgu.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1109,9 +1280,9 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ @@ -1129,3 +1300,10 @@ uninstall-am: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/examples/test.c b/examples/test.c index 53ab81b..6a9e1b2 100644 --- a/examples/test.c +++ b/examples/test.c @@ -1,5 +1,14 @@ #include "test.h" +#include +#include + +#if !defined(WIN32) && !defined(__APPLE__) +# include +# include +# include +#endif + static int testW = 0; static int testH = 0; @@ -13,6 +22,18 @@ static float overcolor[4] = {0,0,0,1}; static CallbackFunc callbacks[TEST_CALLBACK_COUNT]; +#if !defined(WIN32) && !defined(__APPLE__) +static Display *xDisplay = NULL; +static Window xWindow = 0; +static Atom xWmDelete = 0; +#endif + +static EGLDisplay eglDisplay = EGL_NO_DISPLAY; +static EGLSurface eglSurface = EGL_NO_SURFACE; +static EGLContext eglContext = EGL_NO_CONTEXT; +static int testRunning = 1; +static int testRedisplay = 1; + VGPath testCreatePath() { return vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, @@ -143,51 +164,21 @@ void testOverlayString(const char *format, ...) void testDrawString(float x, float y, const char *format, ...) { - int i, len; - va_list ap; - char *text; - float k = 0.15; - - x+=0.5f; - y+=0.5f; - - va_start(ap, format); - len = vsnprintf(NULL, 0, format, ap); - text = (char*)malloc(len+1); - if (!text) {va_end(ap); return;} - vsnprintf(text, len+1, format, ap); - va_end(ap); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); - glDisable(GL_MULTISAMPLE); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glTranslatef(x,y,0); - glScalef(k,k,k); - glLineWidth(1.0f); - - for (i=0; ivisual, AllocNone); + swa.colormap = colormap; + swa.event_mask = ExposureMask | StructureNotifyMask | + KeyPressMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask; + + xWindow = XCreateWindow(xDisplay, RootWindow(xDisplay, screen), + 0, 0, (unsigned int)w, (unsigned int)h, 0, + visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap | CWEventMask, &swa); + XStoreName(xDisplay, xWindow, title); + xWmDelete = XInternAtom(xDisplay, "WM_DELETE_WINDOW", False); + XSetWMProtocols(xDisplay, xWindow, &xWmDelete, 1); + XMapWindow(xDisplay, xWindow); + XFree(visualInfo); + } + + eglSurface = eglCreateWindowSurface(eglDisplay, config, + (EGLNativeWindowType)xWindow, NULL); +#else + fprintf(stderr, "This example harness currently requires X11 EGL\n"); + exit(EXIT_FAILURE); +#endif + + eglContext = eglCreateContext(eglDisplay, config, EGL_NO_CONTEXT, NULL); + if (eglSurface == EGL_NO_SURFACE || + eglContext == EGL_NO_CONTEXT || + !eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) { + fprintf(stderr, "Failed to create or bind EGL OpenVG context (EGL error 0x%x)\n", eglGetError()); + exit(EXIT_FAILURE); + } + + printf("EGL %d.%d client APIs: %s\n", major, minor, + eglQueryString(eglDisplay, EGL_CLIENT_APIS)); + printf("OpenGL renderer: %s\n", glGetString(GL_RENDERER)); + printf("OpenGL version: %s\n", glGetString(GL_VERSION)); + printf("GLSL version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); + atexit(testCleanup); - - vgCreateContextSH(w,h); - + testW = w; testH = h; @@ -386,5 +464,72 @@ void testInit(int argc, char **argv, void testRun() { - glutMainLoop(); +#if !defined(WIN32) && !defined(__APPLE__) + while (testRunning) { + while (XPending(xDisplay) > 0) { + XEvent event; + XNextEvent(xDisplay, &event); + + switch (event.type) { + case ClientMessage: + if ((Atom)event.xclient.data.l[0] == xWmDelete) + testRunning = 0; + break; + + case ConfigureNotify: + if (event.xconfigure.width != testW || + event.xconfigure.height != testH) + testReshape(event.xconfigure.width, event.xconfigure.height); + break; + + case Expose: + testPostRedisplay(); + break; + + case KeyPress: { + KeySym keysym = NoSymbol; + char text[8]; + int len = XLookupString(&event.xkey, text, sizeof(text), &keysym, NULL); + if (keysym == XK_Left) + testSpecialKeyboard(GLUT_KEY_LEFT, event.xkey.x, event.xkey.y); + else if (keysym == XK_Right) + testSpecialKeyboard(GLUT_KEY_RIGHT, event.xkey.x, event.xkey.y); + else if (len > 0) + testKeyboard((unsigned char)text[0], event.xkey.x, event.xkey.y); + } + break; + + case ButtonPress: + testButton(event.xbutton.button, GLUT_DOWN, event.xbutton.x, event.xbutton.y); + break; + + case ButtonRelease: + testButton(event.xbutton.button, GLUT_UP, event.xbutton.x, event.xbutton.y); + break; + + case MotionNotify: + if (event.xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) + testDrag(event.xmotion.x, event.xmotion.y); + else + testMove(event.xmotion.x, event.xmotion.y); + break; + } + } + + if (testRedisplay) { + testRedisplay = 0; + testDisplay(); + } else { + testDisplay(); + } + { + struct timeval delay; + delay.tv_sec = 0; + delay.tv_usec = 16000; + select(0, NULL, NULL, NULL, &delay); + } + } +#else + fprintf(stderr, "testRun is not implemented for this native platform yet\n"); +#endif } diff --git a/examples/test.h b/examples/test.h index 13a6f4b..d2e2852 100644 --- a/examples/test.h +++ b/examples/test.h @@ -10,12 +10,11 @@ #if defined(__APPLE__) # include -# include #else # include -# include #endif +#include #include "GL/glext.h" #include @@ -44,6 +43,14 @@ typedef void (*MoveFunc)(int x, int y); typedef void (*DragFunc)(int x, int y); typedef void (*CleanupFunc)(); +#define GLUT_KEY_LEFT 100 +#define GLUT_KEY_RIGHT 102 +#define GLUT_UP 1 +#define GLUT_DOWN 0 + +void testPostRedisplay(void); +#define glutPostRedisplay testPostRedisplay + VGPath testCreatePath(); void testMoveTo(VGPath p, float x, float y, VGPathAbsRel absrel); void testLineTo(VGPath p, float x, float y, VGPathAbsRel absrel); @@ -79,4 +86,3 @@ void testRun(); VGint testWidth(); VGint testHeight(); - diff --git a/examples/test_egl_gl_vg.c b/examples/test_egl_gl_vg.c new file mode 100644 index 0000000..8ffbf86 --- /dev/null +++ b/examples/test_egl_gl_vg.c @@ -0,0 +1,176 @@ +#include "test.h" + +static VGPath vgPanel; +static VGPaint vgFill; +static VGPaint vgStroke; +static float angle = 0.0f; + +static PFNGLUSEPROGRAMPROC useProgramProc = NULL; +static PFNGLACTIVETEXTUREPROC activeTextureProc = NULL; + +static void loadGLFunctions(void) +{ + if (!useProgramProc) + useProgramProc = (PFNGLUSEPROGRAMPROC)eglGetProcAddress("glUseProgram"); + if (!activeTextureProc) + activeTextureProc = (PFNGLACTIVETEXTUREPROC)eglGetProcAddress("glActiveTexture"); +} + +static void resetGLState(void) +{ + loadGLFunctions(); + + if (useProgramProc) + useProgramProc(0); + + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_STENCIL_TEST); + + if (activeTextureProc) { + activeTextureProc(GL_TEXTURE1); + glDisable(GL_TEXTURE_2D); + activeTextureProc(GL_TEXTURE0); + } + glDisable(GL_TEXTURE_2D); +} + +static void setGLWindowProjection(void) +{ + glViewport(0, 0, testWidth(), testHeight()); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, (GLdouble)testWidth(), 0.0, (GLdouble)testHeight(), -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +static void drawOpenGLBackground(void) +{ + int x; + int y; + + resetGLState(); + setGLWindowProjection(); + + glClearColor(0.06f, 0.07f, 0.09f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + glBegin(GL_QUADS); + glColor3f(0.10f, 0.13f, 0.18f); + glVertex2f(0.0f, 0.0f); + glVertex2f((GLfloat)testWidth(), 0.0f); + glColor3f(0.04f, 0.16f, 0.20f); + glVertex2f((GLfloat)testWidth(), (GLfloat)testHeight()); + glVertex2f(0.0f, (GLfloat)testHeight()); + glEnd(); + + glColor4f(1.0f, 1.0f, 1.0f, 0.18f); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBegin(GL_LINES); + for (x = 0; x <= testWidth(); x += 48) { + glVertex2f((GLfloat)x, 0.0f); + glVertex2f((GLfloat)x, (GLfloat)testHeight()); + } + for (y = 0; y <= testHeight(); y += 48) { + glVertex2f(0.0f, (GLfloat)y); + glVertex2f((GLfloat)testWidth(), (GLfloat)y); + } + glEnd(); + glDisable(GL_BLEND); +} + +static void drawOpenVGPanel(void) +{ + VGfloat fillColor[] = {0.10f, 0.55f, 0.95f, 0.72f}; + VGfloat strokeColor[] = {1.0f, 1.0f, 1.0f, 0.95f}; + + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + vgTranslate(testWidth() * 0.5f, testHeight() * 0.5f); + vgRotate(-angle * 0.4f); + + vgSetParameterfv(vgFill, VG_PAINT_COLOR, 4, fillColor); + vgSetParameterfv(vgStroke, VG_PAINT_COLOR, 4, strokeColor); + vgSetPaint(vgFill, VG_FILL_PATH); + vgSetPaint(vgStroke, VG_STROKE_PATH); + vgSetf(VG_STROKE_LINE_WIDTH, 8.0f); + vgDrawPath(vgPanel, VG_FILL_PATH | VG_STROKE_PATH); +} + +static void drawOpenGLForeground(void) +{ + GLfloat cx = testWidth() * 0.5f; + GLfloat cy = testHeight() * 0.5f; + + resetGLState(); + setGLWindowProjection(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glLineWidth(4.0f); + glColor4f(1.0f, 0.82f, 0.18f, 0.95f); + glBegin(GL_LINE_LOOP); + glVertex2f(32.0f, 32.0f); + glVertex2f((GLfloat)testWidth() - 32.0f, 32.0f); + glVertex2f((GLfloat)testWidth() - 32.0f, (GLfloat)testHeight() - 32.0f); + glVertex2f(32.0f, (GLfloat)testHeight() - 32.0f); + glEnd(); + + glPushMatrix(); + glTranslatef(cx, cy, 0.0f); + glRotatef(angle, 0.0f, 0.0f, 1.0f); + glColor4f(1.0f, 0.38f, 0.18f, 0.88f); + glBegin(GL_TRIANGLES); + glVertex2f(0.0f, 92.0f); + glVertex2f(-22.0f, 34.0f); + glVertex2f(22.0f, 34.0f); + glEnd(); + glPopMatrix(); + + glLineWidth(1.0f); + glDisable(GL_BLEND); +} + +static void display(float interval) +{ + angle += interval * 54.0f; + if (angle > 360.0f) + angle -= 360.0f; + + drawOpenGLBackground(); + drawOpenVGPanel(); + drawOpenGLForeground(); +} + +static void cleanup(void) +{ + vgDestroyPath(vgPanel); + vgDestroyPaint(vgFill); + vgDestroyPaint(vgStroke); +} + +static void createOpenVGContent(void) +{ + vgPanel = testCreatePath(); + vguRoundRect(vgPanel, -170.0f, -105.0f, 340.0f, 210.0f, 46.0f, 46.0f); + + vgFill = vgCreatePaint(); + vgStroke = vgCreatePaint(); +} + +int main(int argc, char **argv) +{ + testInit(argc, argv, 640, 480, "ShaderVG: EGL OpenGL OpenVG Interop"); + testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display); + testCallback(TEST_CALLBACK_CLEANUP, (CallbackFunc)cleanup); + + createOpenVGContent(); + testRun(); + + return EXIT_SUCCESS; +} diff --git a/examples/test_pbuffer.c b/examples/test_pbuffer.c new file mode 100644 index 0000000..496d3de --- /dev/null +++ b/examples/test_pbuffer.c @@ -0,0 +1,106 @@ +/* + * Minimal EGL/OpenVG pbuffer smoke test for ShaderVG. + */ + +#include +#include + +#include +#include + +static int fail_egl(const char *message) +{ + fprintf(stderr, "%s (EGL error 0x%04x)\n", message, eglGetError()); + return 1; +} + +static int fail_vg(const char *message) +{ + fprintf(stderr, "%s (VG error 0x%04x)\n", message, vgGetError()); + return 1; +} + +int main(void) +{ + const EGLint width = 64; + const EGLint height = 64; + EGLDisplay display; + EGLConfig config; + EGLSurface surface; + EGLContext context; + EGLint major, minor, count; + unsigned char *pixels; + int result = 0; + EGLint configAttribs[] = { + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_STENCIL_SIZE, 8, + EGL_NONE + }; + EGLint pbufferAttribs[] = { + EGL_WIDTH, width, + EGL_HEIGHT, height, + EGL_NONE + }; + VGfloat clearColor[] = { 0.2f, 0.4f, 0.7f, 1.0f }; + + display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (display == EGL_NO_DISPLAY) + return fail_egl("eglGetDisplay failed"); + + if (!eglInitialize(display, &major, &minor)) + return fail_egl("eglInitialize failed"); + + if (!eglBindAPI(EGL_OPENVG_API) || + !eglChooseConfig(display, configAttribs, &config, 1, &count) || + count < 1) { + eglTerminate(display); + return fail_egl("EGL OpenVG config selection failed"); + } + + surface = eglCreatePbufferSurface(display, config, pbufferAttribs); + context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL); + if (surface == EGL_NO_SURFACE || + context == EGL_NO_CONTEXT || + !eglMakeCurrent(display, surface, surface, context)) { + if (context != EGL_NO_CONTEXT) + eglDestroyContext(display, context); + if (surface != EGL_NO_SURFACE) + eglDestroySurface(display, surface); + eglTerminate(display); + return fail_egl("EGL OpenVG pbuffer creation failed"); + } + + pixels = (unsigned char*)calloc((size_t)width * (size_t)height * 4u, 1); + if (!pixels) { + result = 1; + goto cleanup; + } + + vgSetfv(VG_CLEAR_COLOR, 4, clearColor); + vgClear(0, 0, width, height); + vgFinish(); + vgReadPixels(pixels, width * 4, VG_sRGBA_8888, 0, 0, width, height); + + if (vgGetError() != VG_NO_ERROR) { + result = fail_vg("OpenVG rendering failed"); + } else if (pixels[3] == 0) { + fprintf(stderr, "OpenVG pbuffer readback produced a transparent pixel\n"); + result = 1; + } else { + printf("EGL/OpenVG pbuffer smoke test passed on EGL %d.%d\n", major, minor); + } + + free(pixels); + +cleanup: + eglDestroyContext(display, context); + eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(display, surface); + eglTerminate(display); + return result; +} diff --git a/examples/test_tiger_shader.c b/examples/test_tiger_shader.c index 0c2a054..5f83673 100644 --- a/examples/test_tiger_shader.c +++ b/examples/test_tiger_shader.c @@ -3,6 +3,10 @@ #include #include +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + #ifndef IMAGE_DIR # define IMAGE_DIR "./" #endif @@ -295,57 +299,45 @@ mat4 *mat4_perspective(float fov, float aspect, float near, * sh_Model * sh_Ortho */ -const char* vgShaderVertexUserTest = R"glsl( - - uniform mat4 myModel; - uniform mat4 myView; - uniform mat4 myPerspective; - out vec3 myNoramal; - out vec3 myFragPos; - - void shMain(){ - - gl_Position = myPerspective * myView * sh_Model * myModel * sh_Vertex; - - myFragPos = (sh_Model * myModel * sh_Vertex).xyz; - - vec4 normalPos = sh_Model * myModel * vec4(sh_Vertex.xy, 1, sh_Vertex.w); - if(normalPos.z < myFragPos.z) - // Flip normal pos (FIXME:Looking for more efficient way ...) - normalPos = sh_Model * myModel * vec4(sh_Vertex.xy, -1, sh_Vertex.w); - myNoramal = normalize(normalPos.xyz - myFragPos); - } - -)glsl"; +const char* vgShaderVertexUserTest = +"uniform mat4 myModel;\n" +"uniform mat4 myView;\n" +"uniform mat4 myPerspective;\n" +"out vec3 myNoramal;\n" +"out vec3 myFragPos;\n" +"\n" +"void shMain(){\n" +" gl_Position = myPerspective * myView * sh_Model * myModel * sh_Vertex;\n" +" myFragPos = (sh_Model * myModel * sh_Vertex).xyz;\n" +" vec4 normalPos = sh_Model * myModel * vec4(sh_Vertex.xy, 1, sh_Vertex.w);\n" +" if(normalPos.z < myFragPos.z)\n" +" normalPos = sh_Model * myModel * vec4(sh_Vertex.xy, -1, sh_Vertex.w);\n" +" myNoramal = normalize(normalPos.xyz - myFragPos);\n" +"}\n"; /* * Built-in input: * sh_Color */ -const char* vgShaderFragmentUserTest = R"glsl( - - vec3 lightPos = vec3(300, 600, 300); - vec3 lightColor = vec3(1.0, 1.0, 1.0); - vec3 cameraPos = vec3(300, 300, 300); - in vec3 myNoramal; - in vec3 myFragPos; - - void shMain(){ - - vec3 lightDir = normalize(lightPos - myFragPos); - vec3 reflectDir = reflect(-lightDir, myNoramal); - vec3 viewDir = normalize(cameraPos - myFragPos); - - float ambientFactor = 0.3; - float diffuseFactor = max(dot(myNoramal, lightDir), 0.0); - float specularFactor = pow(max(dot(viewDir, reflectDir), 0.0), 8); - - vec3 ambient = ambientFactor * lightColor; - vec3 diffuse = diffuseFactor * lightColor; - vec3 specular = specularFactor * lightColor * 0.8; - gl_FragColor = vec4((ambient + diffuse + specular) * sh_Color.rgb, 1.0); - } -)glsl"; +const char* vgShaderFragmentUserTest = +"vec3 lightPos = vec3(300, 600, 300);\n" +"vec3 lightColor = vec3(1.0, 1.0, 1.0);\n" +"vec3 cameraPos = vec3(300, 300, 300);\n" +"in vec3 myNoramal;\n" +"in vec3 myFragPos;\n" +"\n" +"void shMain(){\n" +" vec3 lightDir = normalize(lightPos - myFragPos);\n" +" vec3 reflectDir = reflect(-lightDir, myNoramal);\n" +" vec3 viewDir = normalize(cameraPos - myFragPos);\n" +" float ambientFactor = 0.3;\n" +" float diffuseFactor = max(dot(myNoramal, lightDir), 0.0);\n" +" float specularFactor = pow(max(dot(viewDir, reflectDir), 0.0), 8);\n" +" vec3 ambient = ambientFactor * lightColor;\n" +" vec3 diffuse = diffuseFactor * lightColor;\n" +" vec3 specular = specularFactor * lightColor * 0.8;\n" +" fragColor = vec4((ambient + diffuse + specular) * sh_Color.rgb, 1.0);\n" +"}\n"; void setupShaders() { diff --git a/include/vg/openvg.h b/include/vg/openvg.h index 0d78b72..f75ff36 100644 --- a/include/vg/openvg.h +++ b/include/vg/openvg.h @@ -621,10 +621,6 @@ VG_API_CALL const VGubyte * vgGetString(VGStringID name); #define OVG_SH_blend_src_atop 1 #define OVG_SH_blend_dst_atop 1 -VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height); -VG_API_CALL void vgResizeSurfaceSH(VGint width, VGint height); -VG_API_CALL void vgDestroyContextSH(void); - /* Extensions for ShaderVG */ #define VG_FRAGMENT_SHADER_SH 0 #define VG_VERTEX_SHADER_SH 1 diff --git a/src/Makefile.am b/src/Makefile.am index 88cb47e..432cb7c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -lib_LTLIBRARIES = libOpenVG.la +lib_LTLIBRARIES = libOpenVG.la libShaderVGEGL.la libOpenVG_la_CFLAGS = -pedantic -I$(top_builddir)/include/vg libOpenVG_la_SOURCES =\ shDefs.h\ @@ -24,6 +24,11 @@ libOpenVG_la_SOURCES =\ shContext.c\ shaders.c\ shVgu.c +libOpenVG_la_LIBADD = @OPENGL_LIBS@ @MATH_LIBS@ + +libShaderVGEGL_la_CFLAGS = -pedantic -I$(top_builddir)/include/vg @EGL_CFLAGS@ +libShaderVGEGL_la_SOURCES = shEGL.c +libShaderVGEGL_la_LIBADD = libOpenVG.la @DLOPEN_LIBS@ VG_includedir = $(includedir)/vg VG_include_HEADERS =\ diff --git a/src/Makefile.in b/src/Makefile.in index 69d13a4..b6702c4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. +# Makefile.in generated by automake 1.18.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2017 Free Software Foundation, Inc. +# Copyright (C) 1994-2025 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -71,6 +71,8 @@ am__make_running_with_option = \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +am__rm_f = rm -f $(am__rm_f_notfound) +am__rm_rf = rm -rf $(am__rm_f_notfound) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -122,14 +124,13 @@ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ + { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(VG_includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libOpenVG_la_LIBADD = +libOpenVG_la_DEPENDENCIES = am_libOpenVG_la_OBJECTS = libOpenVG_la-shExtensions.lo \ libOpenVG_la-shArrays.lo libOpenVG_la-shVectors.lo \ libOpenVG_la-shPath.lo libOpenVG_la-shImage.lo \ @@ -145,6 +146,13 @@ am__v_lt_1 = libOpenVG_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libOpenVG_la_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +libShaderVGEGL_la_DEPENDENCIES = libOpenVG.la +am_libShaderVGEGL_la_OBJECTS = libShaderVGEGL_la-shEGL.lo +libShaderVGEGL_la_OBJECTS = $(am_libShaderVGEGL_la_OBJECTS) +libShaderVGEGL_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libShaderVGEGL_la_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -159,7 +167,20 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/libOpenVG_la-shArrays.Plo \ + ./$(DEPDIR)/libOpenVG_la-shContext.Plo \ + ./$(DEPDIR)/libOpenVG_la-shExtensions.Plo \ + ./$(DEPDIR)/libOpenVG_la-shGeometry.Plo \ + ./$(DEPDIR)/libOpenVG_la-shImage.Plo \ + ./$(DEPDIR)/libOpenVG_la-shPaint.Plo \ + ./$(DEPDIR)/libOpenVG_la-shParams.Plo \ + ./$(DEPDIR)/libOpenVG_la-shPath.Plo \ + ./$(DEPDIR)/libOpenVG_la-shPipeline.Plo \ + ./$(DEPDIR)/libOpenVG_la-shVectors.Plo \ + ./$(DEPDIR)/libOpenVG_la-shVgu.Plo \ + ./$(DEPDIR)/libOpenVG_la-shaders.Plo \ + ./$(DEPDIR)/libShaderVGEGL_la-shEGL.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -179,8 +200,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libOpenVG_la_SOURCES) -DIST_SOURCES = $(libOpenVG_la_SOURCES) +SOURCES = $(libOpenVG_la_SOURCES) $(libShaderVGEGL_la_SOURCES) +DIST_SOURCES = $(libOpenVG_la_SOURCES) $(libShaderVGEGL_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -204,8 +225,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ @@ -222,20 +241,25 @@ CFLAGS = @CFLAGS@ CONFIG_CFLAGS = @CONFIG_CFLAGS@ CONFIG_LDADD = @CONFIG_LDADD@ CONFIG_LDFLAGS = @CONFIG_LDFLAGS@ -CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ +DLOPEN_LIBS = @DLOPEN_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ +EGL_CFLAGS = @EGL_CFLAGS@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -253,11 +277,15 @@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ +MATH_LIBS = @MATH_LIBS@ MKDIR_P = @MKDIR_P@ +NATIVE_WINDOW_CFLAGS = @NATIVE_WINDOW_CFLAGS@ +NATIVE_WINDOW_LIBS = @NATIVE_WINDOW_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OPENGL_LIBS = @OPENGL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -284,8 +312,10 @@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ +am__rm_f_notfound = @am__rm_f_notfound@ am__tar = @am__tar@ am__untar = @am__untar@ +am__xargs_n = @am__xargs_n@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -327,7 +357,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -lib_LTLIBRARIES = libOpenVG.la +lib_LTLIBRARIES = libOpenVG.la libShaderVGEGL.la libOpenVG_la_CFLAGS = -pedantic -I$(top_builddir)/include/vg libOpenVG_la_SOURCES = \ shDefs.h\ @@ -354,6 +384,10 @@ libOpenVG_la_SOURCES = \ shaders.c\ shVgu.c +libOpenVG_la_LIBADD = @OPENGL_LIBS@ @MATH_LIBS@ +libShaderVGEGL_la_CFLAGS = -pedantic -I$(top_builddir)/include/vg @EGL_CFLAGS@ +libShaderVGEGL_la_SOURCES = shEGL.c +libShaderVGEGL_la_LIBADD = libOpenVG.la @DLOPEN_LIBS@ VG_includedir = $(includedir)/vg VG_include_HEADERS = \ $(top_builddir)/include/vg/openvg.h\ @@ -380,8 +414,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -418,37 +452,45 @@ uninstall-libLTLIBRARIES: done clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + -$(am__rm_f) $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } + echo rm -f $${locs}; \ + $(am__rm_f) $${locs} libOpenVG.la: $(libOpenVG_la_OBJECTS) $(libOpenVG_la_DEPENDENCIES) $(EXTRA_libOpenVG_la_DEPENDENCIES) $(AM_V_CCLD)$(libOpenVG_la_LINK) -rpath $(libdir) $(libOpenVG_la_OBJECTS) $(libOpenVG_la_LIBADD) $(LIBS) +libShaderVGEGL.la: $(libShaderVGEGL_la_OBJECTS) $(libShaderVGEGL_la_DEPENDENCIES) $(EXTRA_libShaderVGEGL_la_DEPENDENCIES) + $(AM_V_CCLD)$(libShaderVGEGL_la_LINK) -rpath $(libdir) $(libShaderVGEGL_la_OBJECTS) $(libShaderVGEGL_la_LIBADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shArrays.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shContext.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shExtensions.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shGeometry.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shImage.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPaint.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shParams.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPath.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPipeline.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shVectors.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shVgu.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shaders.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shArrays.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shContext.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shExtensions.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shGeometry.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shImage.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPaint.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shParams.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPath.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shPipeline.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shVectors.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shVgu.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libOpenVG_la-shaders.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libShaderVGEGL_la-shEGL.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @: >>$@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -555,6 +597,13 @@ libOpenVG_la-shVgu.lo: shVgu.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libOpenVG_la_CFLAGS) $(CFLAGS) -c -o libOpenVG_la-shVgu.lo `test -f 'shVgu.c' || echo '$(srcdir)/'`shVgu.c +libShaderVGEGL_la-shEGL.lo: shEGL.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libShaderVGEGL_la_CFLAGS) $(CFLAGS) -MT libShaderVGEGL_la-shEGL.lo -MD -MP -MF $(DEPDIR)/libShaderVGEGL_la-shEGL.Tpo -c -o libShaderVGEGL_la-shEGL.lo `test -f 'shEGL.c' || echo '$(srcdir)/'`shEGL.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libShaderVGEGL_la-shEGL.Tpo $(DEPDIR)/libShaderVGEGL_la-shEGL.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='shEGL.c' object='libShaderVGEGL_la-shEGL.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libShaderVGEGL_la_CFLAGS) $(CFLAGS) -c -o libShaderVGEGL_la-shEGL.lo `test -f 'shEGL.c' || echo '$(srcdir)/'`shEGL.c + mostlyclean-libtool: -rm -f *.lo @@ -634,7 +683,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -695,8 +747,8 @@ mostlyclean-generic: clean-generic: distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -$(am__rm_f) $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || $(am__rm_f) $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -707,7 +759,19 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/libOpenVG_la-shArrays.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shContext.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shExtensions.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shGeometry.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shImage.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPaint.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shParams.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPath.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPipeline.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shVectors.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shVgu.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shaders.Plo + -rm -f ./$(DEPDIR)/libShaderVGEGL_la-shEGL.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -753,7 +817,19 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/libOpenVG_la-shArrays.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shContext.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shExtensions.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shGeometry.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shImage.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPaint.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shParams.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPath.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shPipeline.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shVectors.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shVgu.Plo + -rm -f ./$(DEPDIR)/libOpenVG_la-shaders.Plo + -rm -f ./$(DEPDIR)/libShaderVGEGL_la-shEGL.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -774,9 +850,9 @@ uninstall-am: uninstall-VG_includeHEADERS uninstall-libLTLIBRARIES .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-VG_includeHEADERS \ install-am install-data install-data-am install-dvi \ @@ -796,3 +872,10 @@ uninstall-am: uninstall-VG_includeHEADERS uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: + +# Tell GNU make to disable its built-in pattern rules. +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% diff --git a/src/shContext.c b/src/shContext.c index f0244c3..3c9907f 100644 --- a/src/shContext.c +++ b/src/shContext.c @@ -25,87 +25,120 @@ #include #include +void shLoadExtensions(void *c); + /*----------------------------------------------------- - * Simple functions to create a VG context instance - * on top of an existing OpenGL context. - * TODO: There is no mechanics yet to asure the OpenGL - * context exists and to choose which context / window - * to bind to. + * The current VG context is selected by the EGL frontend + * when a ShaderVG-backed EGLContext is made current. *-----------------------------------------------------*/ -static VGContext *g_context = NULL; +#if defined(_MSC_VER) +# define SH_TLS __declspec(thread) +#else +# define SH_TLS __thread +#endif -VG_API_CALL VGboolean vgCreateContextSH(VGint width, VGint height) +static SH_TLS VGContext *g_current_context = NULL; + +static void shResizeSurface(VGContext *context, VGint width, VGint height) { - /* return if already created */ - if (g_context) return VG_TRUE; - - /* create new context */ - SH_NEWOBJ(VGContext, g_context); - if (!g_context) return VG_FALSE; - - /* init surface info */ - g_context->surfaceWidth = width; - g_context->surfaceHeight = height; - - /* setup GL projection */ - glViewport(0,0,width,height); - - /* Setup shader for rendering*/ - g_context->userShaderVertex = NULL; - g_context->userShaderFragment = NULL; + float mat[16]; + float volume; + + if (!context) + return; + + context->surfaceWidth = width; + context->surfaceHeight = height; + + glViewport(0, 0, width, height); + + if (context->glInitialized) { + volume = fmax(width, height) / 2; + shCalcOrtho2D(mat, 0, width, 0, height, -volume, volume); + glUseProgram(context->progDraw); + glUniformMatrix4fv(context->locationDraw.projection, 1, GL_FALSE, mat); + GL_CEHCK_ERROR; + } +} + +static VGboolean shInitContextGL(VGContext *context, VGint width, VGint height) +{ + if (!context) + return VG_FALSE; + + shResizeSurface(context, width, height); + + if (context->glInitialized) + return VG_TRUE; + + shLoadExtensions(context); shInitPiplelineShaders(); - - /* Setup shaders for making color ramp */ shInitRampShaders(); + context->glInitialized = VG_TRUE; + shResizeSurface(context, width, height); return VG_TRUE; } -VG_API_CALL void vgResizeSurfaceSH(VGint width, VGint height) +VGContext* shGetContext() { - VG_GETCONTEXT(VG_NO_RETVAL); - - /* update surface info */ - context->surfaceWidth = width; - context->surfaceHeight = height; - - /* setup GL projection */ - glViewport(0,0,width,height); - - /* Setup projection matrix */ - float mat[16]; - float volume = fmax(width, height) / 2; - shCalcOrtho2D(mat, 0, width, 0, height, -volume, volume); - glUseProgram(context->progDraw); - glUniformMatrix4fv(context->locationDraw.projection, 1, GL_FALSE, mat); - GL_CEHCK_ERROR; - - VG_RETURN(VG_NO_RETVAL); + return g_current_context; } -VG_API_CALL void vgDestroyContextSH() +VGContext* shCreateContext(void) { - /* return if already released */ - if (!g_context) return; - - /* delete context object */ - SH_DELETEOBJ(VGContext, g_context); - g_context = NULL; + VGContext *context = NULL; + SH_NEWOBJ(VGContext, context); + return context; } -VGContext* shGetContext() +void shDestroyContext(VGContext *context) { - SH_ASSERT(g_context); - return g_context; + VGContext *previous = g_current_context; + + if (!context) + return; + + if (context->glInitialized) { + g_current_context = context; + shDeinitPiplelineShaders(); + shDeinitRampShaders(); + context->glInitialized = VG_FALSE; + } + + SH_DELETEOBJ(VGContext, context); + + if (previous == context) + g_current_context = NULL; + else + g_current_context = previous; +} + +VGboolean shSetCurrentContext(VGContext *context, VGint width, VGint height) +{ + g_current_context = context; + + if (!context) + return VG_TRUE; + + return shInitContextGL(context, width, height); +} + +void shClearCurrentContext(void) +{ + g_current_context = NULL; +} + +void shResizeCurrentSurface(VGint width, VGint height) +{ + shResizeSurface(g_current_context, width, height); } /*----------------------------------------------------- * VGContext constructor *-----------------------------------------------------*/ -void shLoadExtensions(void *c); - void VGContext_ctor(VGContext *c) { /* Surface info */ @@ -172,8 +205,15 @@ void VGContext_ctor(VGContext *c) SH_INITOBJ(SHPathArray, c->paths); SH_INITOBJ(SHPaintArray, c->paints); SH_INITOBJ(SHImageArray, c->images); - - shLoadExtensions(c); + + /* GL state is initialized lazily after EGL makes the context current */ + c->progDraw = 0; + c->progColorRamp = 0; + c->userShaderVertex = NULL; + c->userShaderFragment = NULL; + c->vs = 0; + c->fs = 0; + c->glInitialized = VG_FALSE; } /*----------------------------------------------------- @@ -196,6 +236,11 @@ void VGContext_dtor(VGContext *c) for (i=0; iimages.size; ++i) SH_DELETEOBJ(SHImage, c->images.items[i]); + + SH_DEINITOBJ(SHPaint, c->defaultPaint); + SH_DEINITOBJ(SHPathArray, c->paths); + SH_DEINITOBJ(SHPaintArray, c->paints); + SH_DEINITOBJ(SHImageArray, c->images); } /*-------------------------------------------------- diff --git a/src/shContext.h b/src/shContext.h index 916c936..84e22bd 100644 --- a/src/shContext.h +++ b/src/shContext.h @@ -42,7 +42,7 @@ typedef enum typedef struct { - /* Surface info (since no EGL yet) */ + /* Surface info supplied by the EGL frontend */ SHint surfaceWidth; SHint surfaceHeight; @@ -141,6 +141,7 @@ typedef struct const void* userShaderFragment; GLint vs; GLint fs; + VGboolean glInitialized; } VGContext; @@ -152,6 +153,11 @@ SHint shIsValidPaint(VGContext *c, VGHandle h); SHint shIsValidImage(VGContext *c, VGHandle h); SHResourceType shGetResourceType(VGContext *c, VGHandle h); VGContext* shGetContext(); +VGContext* shCreateContext(void); +void shDestroyContext(VGContext *c); +VGboolean shSetCurrentContext(VGContext *c, VGint width, VGint height); +void shClearCurrentContext(void); +void shResizeCurrentSurface(VGint width, VGint height); /*---------------------------------------------------- * TODO: Add mutex locking/unlocking to these macros diff --git a/src/shEGL.c b/src/shEGL.c new file mode 100644 index 0000000..d0b00b2 --- /dev/null +++ b/src/shEGL.c @@ -0,0 +1,820 @@ +/* + * ShaderVG EGL frontend. + * + * This module exposes the EGL calls used by OpenVG clients. It delegates + * native display, surface, and OpenGL context creation to the platform EGL + * provider, while associating ShaderVG VGContext state with contexts that + * clients create after eglBindAPI(EGL_OPENVG_API). + */ + +#include +#include + +#include "openvg.h" +#include "shContext.h" + +#include +#include +#include + +#ifndef EGL_CONTEXT_OPENGL_PROFILE_MASK +# ifdef EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR +# define EGL_CONTEXT_OPENGL_PROFILE_MASK EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR +# endif +#endif + +#ifndef EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT +# ifdef EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR +# define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR +# endif +#endif + +#if defined(_WIN32) +# include +#else +# include +#endif + +#if defined(_MSC_VER) +# define SH_TLS __declspec(thread) +#else +# define SH_TLS __thread +#endif + +#define SH_EGL_DISPLAY_MAGIC 0x53454744u +#define SH_EGL_CONTEXT_MAGIC 0x53454743u +#define SH_EGL_SURFACE_MAGIC 0x53454753u + +typedef struct { + unsigned int magic; + EGLNativeDisplayType nativeDisplay; + EGLDisplay realDisplay; +} SHEGLDisplay; + +typedef struct { + unsigned int magic; + SHEGLDisplay *display; + EGLSurface realSurface; +} SHEGLSurface; + +typedef struct { + unsigned int magic; + SHEGLDisplay *display; + EGLContext realContext; + VGContext *vgContext; + EGLenum api; +} SHEGLContext; + +typedef struct { + PFNEGLGETDISPLAYPROC GetDisplay; + PFNEGLINITIALIZEPROC Initialize; + PFNEGLTERMINATEPROC Terminate; + PFNEGLGETCONFIGSPROC GetConfigs; + PFNEGLCHOOSECONFIGPROC ChooseConfig; + PFNEGLGETCONFIGATTRIBPROC GetConfigAttrib; + PFNEGLCREATEWINDOWSURFACEPROC CreateWindowSurface; + PFNEGLCREATEPBUFFERSURFACEPROC CreatePbufferSurface; + PFNEGLDESTROYSURFACEPROC DestroySurface; + PFNEGLQUERYSURFACEPROC QuerySurface; + PFNEGLBINDAPIPROC BindAPI; + PFNEGLQUERYAPIPROC QueryAPI; + PFNEGLCREATECONTEXTPROC CreateContext; + PFNEGLDESTROYCONTEXTPROC DestroyContext; + PFNEGLMAKECURRENTPROC MakeCurrent; + PFNEGLGETCURRENTCONTEXTPROC GetCurrentContext; + PFNEGLGETCURRENTSURFACEPROC GetCurrentSurface; + PFNEGLGETCURRENTDISPLAYPROC GetCurrentDisplay; + PFNEGLSWAPBUFFERSPROC SwapBuffers; + PFNEGLSWAPINTERVALPROC SwapInterval; + PFNEGLGETERRORPROC GetError; + PFNEGLQUERYSTRINGPROC QueryString; + PFNEGLGETPROCADDRESSPROC GetProcAddress; + PFNEGLRELEASETHREADPROC ReleaseThread; +} SHEGLDispatch; + +static SHEGLDispatch g_egl; +static int g_eglLoaded = 0; + +#if defined(_WIN32) +static HMODULE g_eglLibrary = NULL; +#else +static void *g_eglLibrary = NULL; +#endif + +static SH_TLS EGLint t_error = EGL_SUCCESS; +static SH_TLS EGLenum t_boundApi = EGL_OPENGL_ES_API; +static SH_TLS SHEGLDisplay *t_currentDisplay = NULL; +static SH_TLS SHEGLSurface *t_currentDraw = NULL; +static SH_TLS SHEGLSurface *t_currentRead = NULL; +static SH_TLS SHEGLContext *t_currentContext = NULL; +static SH_TLS char t_clientApis[256]; + +static void shSetEGLError(EGLint error) +{ + t_error = error; +} + +static void *shLoadSymbol(const char *name) +{ +#if defined(_WIN32) + return (void*)GetProcAddress(g_eglLibrary, name); +#else + return dlsym(g_eglLibrary, name); +#endif +} + +static int shLoadRealEGL(void) +{ + if (g_eglLoaded) + return 1; + +#if defined(_WIN32) + g_eglLibrary = LoadLibraryA("libEGL.dll"); + if (!g_eglLibrary) + g_eglLibrary = LoadLibraryA("EGL.dll"); +#else + g_eglLibrary = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL); + if (!g_eglLibrary) + g_eglLibrary = dlopen("libEGL.so", RTLD_LAZY | RTLD_LOCAL); +#endif + + if (!g_eglLibrary) { + shSetEGLError(EGL_NOT_INITIALIZED); + return 0; + } + +#define LOAD_EGL(field, type, symbol) \ + do { \ + union { void *object; type function; } proc; \ + proc.object = shLoadSymbol(symbol); \ + if (!proc.object) { \ + shSetEGLError(EGL_NOT_INITIALIZED); \ + return 0; \ + } \ + g_egl.field = proc.function; \ + } while (0) + + LOAD_EGL(GetDisplay, PFNEGLGETDISPLAYPROC, "eglGetDisplay"); + LOAD_EGL(Initialize, PFNEGLINITIALIZEPROC, "eglInitialize"); + LOAD_EGL(Terminate, PFNEGLTERMINATEPROC, "eglTerminate"); + LOAD_EGL(GetConfigs, PFNEGLGETCONFIGSPROC, "eglGetConfigs"); + LOAD_EGL(ChooseConfig, PFNEGLCHOOSECONFIGPROC, "eglChooseConfig"); + LOAD_EGL(GetConfigAttrib, PFNEGLGETCONFIGATTRIBPROC, "eglGetConfigAttrib"); + LOAD_EGL(CreateWindowSurface, PFNEGLCREATEWINDOWSURFACEPROC, "eglCreateWindowSurface"); + LOAD_EGL(CreatePbufferSurface, PFNEGLCREATEPBUFFERSURFACEPROC, "eglCreatePbufferSurface"); + LOAD_EGL(DestroySurface, PFNEGLDESTROYSURFACEPROC, "eglDestroySurface"); + LOAD_EGL(QuerySurface, PFNEGLQUERYSURFACEPROC, "eglQuerySurface"); + LOAD_EGL(BindAPI, PFNEGLBINDAPIPROC, "eglBindAPI"); + LOAD_EGL(QueryAPI, PFNEGLQUERYAPIPROC, "eglQueryAPI"); + LOAD_EGL(CreateContext, PFNEGLCREATECONTEXTPROC, "eglCreateContext"); + LOAD_EGL(DestroyContext, PFNEGLDESTROYCONTEXTPROC, "eglDestroyContext"); + LOAD_EGL(MakeCurrent, PFNEGLMAKECURRENTPROC, "eglMakeCurrent"); + LOAD_EGL(GetCurrentContext, PFNEGLGETCURRENTCONTEXTPROC, "eglGetCurrentContext"); + LOAD_EGL(GetCurrentSurface, PFNEGLGETCURRENTSURFACEPROC, "eglGetCurrentSurface"); + LOAD_EGL(GetCurrentDisplay, PFNEGLGETCURRENTDISPLAYPROC, "eglGetCurrentDisplay"); + LOAD_EGL(SwapBuffers, PFNEGLSWAPBUFFERSPROC, "eglSwapBuffers"); + LOAD_EGL(GetError, PFNEGLGETERRORPROC, "eglGetError"); + LOAD_EGL(QueryString, PFNEGLQUERYSTRINGPROC, "eglQueryString"); + LOAD_EGL(GetProcAddress, PFNEGLGETPROCADDRESSPROC, "eglGetProcAddress"); + LOAD_EGL(ReleaseThread, PFNEGLRELEASETHREADPROC, "eglReleaseThread"); + + { + union { void *object; PFNEGLSWAPINTERVALPROC function; } proc; + proc.object = shLoadSymbol("eglSwapInterval"); + g_egl.SwapInterval = proc.function; + } + +#undef LOAD_EGL + + g_eglLoaded = 1; + return 1; +} + +static SHEGLDisplay *shDisplay(EGLDisplay dpy) +{ + SHEGLDisplay *display = (SHEGLDisplay*)dpy; + if (!display || display->magic != SH_EGL_DISPLAY_MAGIC) { + shSetEGLError(EGL_BAD_DISPLAY); + return NULL; + } + return display; +} + +static SHEGLSurface *shSurface(EGLSurface surface) +{ + SHEGLSurface *s = (SHEGLSurface*)surface; + if (!s || s->magic != SH_EGL_SURFACE_MAGIC) { + shSetEGLError(EGL_BAD_SURFACE); + return NULL; + } + return s; +} + +static SHEGLContext *shContext(EGLContext context) +{ + SHEGLContext *c = (SHEGLContext*)context; + if (!c || c->magic != SH_EGL_CONTEXT_MAGIC) { + shSetEGLError(EGL_BAD_CONTEXT); + return NULL; + } + return c; +} + +static EGLint *shTranslateConfigAttribs(const EGLint *attribs) +{ + EGLint *out; + int pairs = 0; + int foundRenderable = 0; + int i; + int j = 0; + + if (attribs) { + while (attribs[pairs * 2] != EGL_NONE) + ++pairs; + } + + out = (EGLint*)malloc(sizeof(EGLint) * (pairs * 2 + 3)); + if (!out) + return NULL; + + for (i = 0; i < pairs; ++i) { + EGLint key = attribs[i * 2]; + EGLint value = attribs[i * 2 + 1]; + + out[j++] = key; + if (key == EGL_RENDERABLE_TYPE) { + foundRenderable = 1; + value = (value & ~EGL_OPENVG_BIT) | EGL_OPENGL_BIT; + } + out[j++] = value; + } + + if (!foundRenderable) { + out[j++] = EGL_RENDERABLE_TYPE; + out[j++] = EGL_OPENGL_BIT; + } + + out[j] = EGL_NONE; + return out; +} + +static const EGLint *shContextAttribsForAPI(EGLenum api, const EGLint *attribs) +{ + static const EGLint openGL33Attribs[] = { + EGL_CONTEXT_MAJOR_VERSION, 3, + EGL_CONTEXT_MINOR_VERSION, 3, +#if defined(EGL_CONTEXT_OPENGL_PROFILE_MASK) && defined(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT) + EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT, +#endif + EGL_NONE + }; + + if (api == EGL_OPENVG_API) + return openGL33Attribs; + + return attribs; +} + +static EGLBoolean shQuerySurfaceSize(SHEGLDisplay *display, SHEGLSurface *surface, + EGLint *width, EGLint *height) +{ + if (!surface) { + *width = 0; + *height = 0; + return EGL_TRUE; + } + + if (!g_egl.QuerySurface(display->realDisplay, surface->realSurface, EGL_WIDTH, width)) + return EGL_FALSE; + + if (!g_egl.QuerySurface(display->realDisplay, surface->realSurface, EGL_HEIGHT, height)) + return EGL_FALSE; + + return EGL_TRUE; +} + +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) +{ + SHEGLDisplay *display; + EGLDisplay realDisplay; + + if (!shLoadRealEGL()) + return EGL_NO_DISPLAY; + + realDisplay = g_egl.GetDisplay(display_id); + if (realDisplay == EGL_NO_DISPLAY) + return EGL_NO_DISPLAY; + + display = (SHEGLDisplay*)calloc(1, sizeof(SHEGLDisplay)); + if (!display) { + shSetEGLError(EGL_BAD_ALLOC); + return EGL_NO_DISPLAY; + } + + display->magic = SH_EGL_DISPLAY_MAGIC; + display->nativeDisplay = display_id; + display->realDisplay = realDisplay; + return (EGLDisplay)display; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) +{ + SHEGLDisplay *display; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + return display ? g_egl.Initialize(display->realDisplay, major, minor) : EGL_FALSE; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) +{ + SHEGLDisplay *display; + EGLBoolean result; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + if (!display) + return EGL_FALSE; + result = g_egl.Terminate(display->realDisplay); + if (result) { + display->magic = 0; + free(display); + } + return result; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, + EGLint config_size, EGLint *num_config) +{ + SHEGLDisplay *display; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + return display ? g_egl.GetConfigs(display->realDisplay, configs, config_size, num_config) : EGL_FALSE; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, + EGLConfig *configs, EGLint config_size, + EGLint *num_config) +{ + SHEGLDisplay *display; + EGLint *translated; + EGLBoolean result; + + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + if (!display) + return EGL_FALSE; + + translated = shTranslateConfigAttribs(attrib_list); + if (!translated) { + shSetEGLError(EGL_BAD_ALLOC); + return EGL_FALSE; + } + + result = g_egl.ChooseConfig(display->realDisplay, translated, configs, config_size, num_config); + free(translated); + return result; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, + EGLint attribute, EGLint *value) +{ + SHEGLDisplay *display; + EGLBoolean result; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + if (!display) + return EGL_FALSE; + result = g_egl.GetConfigAttrib(display->realDisplay, config, attribute, value); + if (result && attribute == EGL_RENDERABLE_TYPE && value && (*value & EGL_OPENGL_BIT)) + *value |= EGL_OPENVG_BIT; + return result; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) +{ + EGLenum realApi = api; + + if (!shLoadRealEGL()) + return EGL_FALSE; + + if (api == EGL_OPENVG_API) + realApi = EGL_OPENGL_API; + + if (!g_egl.BindAPI(realApi)) + return EGL_FALSE; + + t_boundApi = api; + return EGL_TRUE; +} + +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void) +{ + if (t_boundApi == EGL_OPENVG_API) + return EGL_OPENVG_API; + + if (!shLoadRealEGL()) + return EGL_NONE; + + return g_egl.QueryAPI(); +} + +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, + EGLNativeWindowType win, + const EGLint *attrib_list) +{ + SHEGLDisplay *display; + SHEGLSurface *surface; + EGLSurface realSurface; + + if (!shLoadRealEGL()) + return EGL_NO_SURFACE; + display = shDisplay(dpy); + if (!display) + return EGL_NO_SURFACE; + + realSurface = g_egl.CreateWindowSurface(display->realDisplay, config, win, attrib_list); + if (realSurface == EGL_NO_SURFACE) + return EGL_NO_SURFACE; + + surface = (SHEGLSurface*)calloc(1, sizeof(SHEGLSurface)); + if (!surface) { + g_egl.DestroySurface(display->realDisplay, realSurface); + shSetEGLError(EGL_BAD_ALLOC); + return EGL_NO_SURFACE; + } + + surface->magic = SH_EGL_SURFACE_MAGIC; + surface->display = display; + surface->realSurface = realSurface; + return (EGLSurface)surface; +} + +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, + const EGLint *attrib_list) +{ + SHEGLDisplay *display; + SHEGLSurface *surface; + EGLSurface realSurface; + + if (!shLoadRealEGL()) + return EGL_NO_SURFACE; + display = shDisplay(dpy); + if (!display) + return EGL_NO_SURFACE; + + realSurface = g_egl.CreatePbufferSurface(display->realDisplay, config, attrib_list); + if (realSurface == EGL_NO_SURFACE) + return EGL_NO_SURFACE; + + surface = (SHEGLSurface*)calloc(1, sizeof(SHEGLSurface)); + if (!surface) { + g_egl.DestroySurface(display->realDisplay, realSurface); + shSetEGLError(EGL_BAD_ALLOC); + return EGL_NO_SURFACE; + } + + surface->magic = SH_EGL_SURFACE_MAGIC; + surface->display = display; + surface->realSurface = realSurface; + return (EGLSurface)surface; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface) +{ + SHEGLDisplay *display; + SHEGLSurface *s; + EGLBoolean result; + + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + s = shSurface(surface); + if (!display || !s) + return EGL_FALSE; + + result = g_egl.DestroySurface(display->realDisplay, s->realSurface); + if (result) { + if (t_currentDraw == s) + t_currentDraw = NULL; + if (t_currentRead == s) + t_currentRead = NULL; + s->magic = 0; + free(s); + } + + return result; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, + EGLint attribute, EGLint *value) +{ + SHEGLDisplay *display; + SHEGLSurface *s; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + s = shSurface(surface); + return (display && s) ? g_egl.QuerySurface(display->realDisplay, s->realSurface, + attribute, value) : EGL_FALSE; +} + +EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, + EGLContext share_context, + const EGLint *attrib_list) +{ + SHEGLDisplay *display; + SHEGLContext *share = NULL; + SHEGLContext *context; + EGLContext realShare = EGL_NO_CONTEXT; + EGLContext realContext; + EGLenum api = t_boundApi; + + if (!shLoadRealEGL()) + return EGL_NO_CONTEXT; + display = shDisplay(dpy); + if (!display) + return EGL_NO_CONTEXT; + + if (share_context != EGL_NO_CONTEXT) { + share = shContext(share_context); + if (!share) + return EGL_NO_CONTEXT; + realShare = share->realContext; + } + + if (api == EGL_OPENVG_API && !g_egl.BindAPI(EGL_OPENGL_API)) + return EGL_NO_CONTEXT; + + realContext = g_egl.CreateContext(display->realDisplay, config, realShare, + shContextAttribsForAPI(api, attrib_list)); + if (realContext == EGL_NO_CONTEXT) + return EGL_NO_CONTEXT; + + context = (SHEGLContext*)calloc(1, sizeof(SHEGLContext)); + if (!context) { + g_egl.DestroyContext(display->realDisplay, realContext); + shSetEGLError(EGL_BAD_ALLOC); + return EGL_NO_CONTEXT; + } + + context->magic = SH_EGL_CONTEXT_MAGIC; + context->display = display; + context->realContext = realContext; + context->api = api; + + if (api == EGL_OPENVG_API) { + context->vgContext = shCreateContext(); + if (!context->vgContext) { + g_egl.DestroyContext(display->realDisplay, realContext); + free(context); + shSetEGLError(EGL_BAD_ALLOC); + return EGL_NO_CONTEXT; + } + } + + return (EGLContext)context; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +{ + SHEGLDisplay *display; + SHEGLContext *context; + EGLBoolean result; + + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + context = shContext(ctx); + if (!display || !context) + return EGL_FALSE; + + if (t_currentContext == context) { + shClearCurrentContext(); + t_currentContext = NULL; + } + + if (context->vgContext) { + shDestroyContext(context->vgContext); + context->vgContext = NULL; + } + + result = g_egl.DestroyContext(display->realDisplay, context->realContext); + if (result) { + context->magic = 0; + free(context); + } + + return result; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, + EGLSurface read, EGLContext ctx) +{ + SHEGLDisplay *display; + SHEGLSurface *drawSurface = NULL; + SHEGLSurface *readSurface = NULL; + SHEGLContext *context = NULL; + EGLSurface realDraw = EGL_NO_SURFACE; + EGLSurface realRead = EGL_NO_SURFACE; + EGLContext realContext = EGL_NO_CONTEXT; + EGLint width = 0; + EGLint height = 0; + + if (!shLoadRealEGL()) + return EGL_FALSE; + + display = shDisplay(dpy); + if (!display) + return EGL_FALSE; + + if (draw != EGL_NO_SURFACE) { + drawSurface = shSurface(draw); + if (!drawSurface) + return EGL_FALSE; + realDraw = drawSurface->realSurface; + } + + if (read != EGL_NO_SURFACE) { + readSurface = shSurface(read); + if (!readSurface) + return EGL_FALSE; + realRead = readSurface->realSurface; + } + + if (ctx != EGL_NO_CONTEXT) { + context = shContext(ctx); + if (!context) + return EGL_FALSE; + realContext = context->realContext; + } + + if (context && context->api == EGL_OPENVG_API && !g_egl.BindAPI(EGL_OPENGL_API)) + return EGL_FALSE; + + if (!g_egl.MakeCurrent(display->realDisplay, realDraw, realRead, realContext)) + return EGL_FALSE; + + t_currentDisplay = display; + t_currentDraw = drawSurface; + t_currentRead = readSurface; + t_currentContext = context; + + if (!context || context->api != EGL_OPENVG_API) { + shClearCurrentContext(); + return EGL_TRUE; + } + + if (!shQuerySurfaceSize(display, drawSurface, &width, &height)) + return EGL_FALSE; + + if (!shSetCurrentContext(context->vgContext, width, height)) { + shSetEGLError(EGL_BAD_ALLOC); + return EGL_FALSE; + } + + return EGL_TRUE; +} + +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) +{ + return t_currentContext ? (EGLContext)t_currentContext : EGL_NO_CONTEXT; +} + +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) +{ + if (readdraw == EGL_READ) + return t_currentRead ? (EGLSurface)t_currentRead : EGL_NO_SURFACE; + if (readdraw == EGL_DRAW) + return t_currentDraw ? (EGLSurface)t_currentDraw : EGL_NO_SURFACE; + shSetEGLError(EGL_BAD_PARAMETER); + return EGL_NO_SURFACE; +} + +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) +{ + return t_currentDisplay ? (EGLDisplay)t_currentDisplay : EGL_NO_DISPLAY; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +{ + SHEGLDisplay *display; + SHEGLSurface *s; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + s = shSurface(surface); + return (display && s) ? g_egl.SwapBuffers(display->realDisplay, s->realSurface) : EGL_FALSE; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + SHEGLDisplay *display; + if (!shLoadRealEGL()) + return EGL_FALSE; + display = shDisplay(dpy); + if (!display || !g_egl.SwapInterval) + return EGL_FALSE; + return g_egl.SwapInterval(display->realDisplay, interval); +} + +EGLAPI EGLint EGLAPIENTRY eglGetError(void) +{ + EGLint error = t_error; + if (error != EGL_SUCCESS) { + t_error = EGL_SUCCESS; + return error; + } + + if (!shLoadRealEGL()) + return t_error; + + return g_egl.GetError(); +} + +EGLAPI const char *EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) +{ + SHEGLDisplay *display = NULL; + const char *real; + + if (!shLoadRealEGL()) + return NULL; + + if (dpy != EGL_NO_DISPLAY) { + display = shDisplay(dpy); + if (!display) + return NULL; + } + + real = g_egl.QueryString(display ? display->realDisplay : EGL_NO_DISPLAY, name); + + if (name == EGL_CLIENT_APIS) { + if (!real || !strstr(real, "OpenVG")) { + snprintf(t_clientApis, sizeof(t_clientApis), "OpenVG%s%s", + real ? " " : "", real ? real : ""); + return t_clientApis; + } + } + + return real; +} + +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) +{ + shClearCurrentContext(); + t_currentDisplay = NULL; + t_currentDraw = NULL; + t_currentRead = NULL; + t_currentContext = NULL; + + if (!shLoadRealEGL()) + return EGL_FALSE; + + return g_egl.ReleaseThread(); +} + +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY +eglGetProcAddress(const char *procname) +{ +#define SH_PROC(name) \ + if (strcmp(procname, "egl" #name) == 0) \ + return (__eglMustCastToProperFunctionPointerType)egl##name + + if (!procname) + return NULL; + + SH_PROC(GetDisplay); + SH_PROC(Initialize); + SH_PROC(Terminate); + SH_PROC(GetConfigs); + SH_PROC(ChooseConfig); + SH_PROC(GetConfigAttrib); + SH_PROC(CreateWindowSurface); + SH_PROC(CreatePbufferSurface); + SH_PROC(DestroySurface); + SH_PROC(QuerySurface); + SH_PROC(BindAPI); + SH_PROC(QueryAPI); + SH_PROC(CreateContext); + SH_PROC(DestroyContext); + SH_PROC(MakeCurrent); + SH_PROC(GetCurrentContext); + SH_PROC(GetCurrentSurface); + SH_PROC(GetCurrentDisplay); + SH_PROC(SwapBuffers); + SH_PROC(SwapInterval); + SH_PROC(GetError); + SH_PROC(QueryString); + SH_PROC(GetProcAddress); + SH_PROC(ReleaseThread); + +#undef SH_PROC + + if (!shLoadRealEGL()) + return NULL; + + return g_egl.GetProcAddress(procname); +} diff --git a/src/shImage.c b/src/shImage.c index f18c20e..1ebbe8b 100644 --- a/src/shImage.c +++ b/src/shImage.c @@ -466,7 +466,7 @@ void SHImage_ctor(SHImage *i) i->data = NULL; i->width = 0; i->height = 0; - glGenTextures(1, &i->texture); + i->texture = 0; } void SHImage_dtor(SHImage *i) @@ -474,7 +474,7 @@ void SHImage_dtor(SHImage *i) if (i->data != NULL) free(i->data); - if (glIsTexture(i->texture)) + if (i->texture != 0 && glIsTexture(i->texture)) glDeleteTextures(1, &i->texture); } @@ -513,6 +513,9 @@ void shUpdateImageTextureSize(SHImage *i) void shUpdateImageTexture(SHImage *i, VGContext *c) { /* Store pixels to texture */ + if (i->texture == 0) + glGenTextures(1, &i->texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, i->texture); glTexImage2D(GL_TEXTURE_2D, 0, i->fd.glintformat, @@ -1233,4 +1236,3 @@ VG_API_CALL void vgBindImageSH(VGImage image, VGImageUnitSH unit){ glEnable(GL_TEXTURE_2D); GL_CEHCK_ERROR; } - diff --git a/src/shPaint.c b/src/shPaint.c index fb28dd4..c935430 100644 --- a/src/shPaint.c +++ b/src/shPaint.c @@ -37,6 +37,19 @@ #define _ARRAY_DEFINE #include "shArrayBase.h" +static void shEnsurePaintTexture(SHPaint *p) +{ + if (p->texture != 0) + return; + + glGenTextures(1, &p->texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glBindTexture(GL_TEXTURE_2D, p->texture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SH_GRADIENT_TEX_WIDTH, SH_GRADIENT_TEX_HEIGHT, 0, + GL_RGBA, GL_FLOAT, NULL); + GL_CEHCK_ERROR; +} + void SHPaint_ctor(SHPaint *p) { @@ -52,13 +65,7 @@ void SHPaint_ctor(SHPaint *p) for (i=0; i<4; ++i) p->linearGradient[i] = 0.0f; for (i=0; i<5; ++i) p->radialGradient[i] = 0.0f; p->pattern = VG_INVALID_HANDLE; - - glGenTextures(1, &p->texture); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBindTexture(GL_TEXTURE_2D, p->texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SH_GRADIENT_TEX_WIDTH, SH_GRADIENT_TEX_HEIGHT, 0, - GL_RGBA, GL_FLOAT, NULL); - GL_CEHCK_ERROR; + p->texture = 0; } void SHPaint_dtor(SHPaint *p) @@ -66,7 +73,7 @@ void SHPaint_dtor(SHPaint *p) SH_DEINITOBJ(SHStopArray, p->instops); SH_DEINITOBJ(SHStopArray, p->stops); - if (glIsTexture(p->texture)) + if (p->texture != 0 && glIsTexture(p->texture)) glDeleteTextures(1, &p->texture); } @@ -182,6 +189,7 @@ void shUpdateColorRampTexture(SHPaint *p) } /* Update texture image */ + shEnsurePaintTexture(p); glBindTexture(GL_TEXTURE_2D, p->texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -350,6 +358,7 @@ void shGenerateStops(SHPaint *p, SHfloat minOffset, SHfloat maxOffset, void shSetGradientTexGLState(SHPaint *p) { + shEnsurePaintTexture(p); glBindTexture(GL_TEXTURE_2D, p->texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -498,4 +507,3 @@ int shLoadOneColorMesh(SHPaint *p) return 1; } - diff --git a/src/shaders.c b/src/shaders.c index a81cdbf..b035313 100644 --- a/src/shaders.c +++ b/src/shaders.c @@ -25,221 +25,159 @@ #include #include -static const char* vgShaderVertexPipeline = R"glsl( - #version 330 - -/*** Input *******************/ - in vec2 pos; - in vec2 textureUV; - uniform mat4 sh_Model; - uniform mat4 sh_Ortho; - uniform mat3 paintInverted; - -/*** Output ******************/ - out vec2 texImageCoord; - out vec2 paintCoord; - -/*** Grobal variables ********************/ - vec4 sh_Vertex; - -/*** Functions ****************************************/ - - // User defined shader - void shMain(void); - -/*** Main thread **************************************************/ - void main() { - - /* Stage 3: Transformation */ - sh_Vertex = vec4(pos, 0, 1); - - /* Extended Stage: User defined shader that affects gl_Position */ - shMain(); - - /* 2D pos in texture space */ - texImageCoord = textureUV; - - /* 2D pos in paint space (Back to paint space) */ - paintCoord = (paintInverted * vec3(pos, 1)).xy; - - } -)glsl"; - -static const char* vgShaderVertexUserDefault = R"glsl( - void shMain(){ gl_Position = sh_Ortho * sh_Model * sh_Vertex; } -)glsl"; - -static const char* vgShaderFragmentPipeline = R"glsl( - - #version 330 - -/*** Enum constans ************************************/ - - #define PAINT_TYPE_COLOR 0x1B00 - #define PAINT_TYPE_LINEAR_GRADIENT 0x1B01 - #define PAINT_TYPE_RADIAL_GRADIENT 0x1B02 - #define PAINT_TYPE_PATTERN 0x1B03 - - #define DRAW_IMAGE_NORMAL 0x1F00 - #define DRAW_IMAGE_MULTIPLY 0x1F01 - - #define DRAW_MODE_PATH 0 - #define DRAW_MODE_IMAGE 1 - -/*** Interpolated *************************************/ - - in vec2 texImageCoord; - in vec2 paintCoord; - -/*** Input ********************************************/ - - // Basic rendering Mode - uniform int drawMode; - // Image - uniform sampler2D imageSampler; - uniform int imageMode; - // Paint - uniform int paintType; - uniform vec4 paintColor; - uniform vec2 paintParams[3]; - // Gradient - uniform sampler2D rampSampler; - // Pattern - uniform sampler2D patternSampler; - // Color transform - uniform vec4 scaleFactorBias[2]; - -/*** Output *******************************************/ - - //out vec4 fragColor; - -/*** Built-in variables for shMain *******************************************/ - - vec4 sh_Color; - -/*** Functions ****************************************/ - - // 9.3.1 Linear Gradients - float linearGradient(vec2 fragCoord, vec2 p0, vec2 p1){ - - float x = fragCoord.x; - float y = fragCoord.y; - float x0 = p0.x; - float y0 = p0.y; - float x1 = p1.x; - float y1 = p1.y; - float dx = x1 - x0; - float dy = y1 - y0; - - return - ( dx * (x - x0) + dy * (y - y0) ) - / ( dx*dx + dy*dy ); - } - - // 9.3.2 Radial Gradients - float radialGradient(vec2 fragCoord, vec2 centerCoord, vec2 focalCoord, float r){ - - float x = fragCoord.x; - float y = fragCoord.y; - float cx = centerCoord.x; - float cy = centerCoord.y; - float fx = focalCoord.x; - float fy = focalCoord.y; - float dx = x - fx; - float dy = y - fy; - float dfx = fx - cx; - float dfy = fy - cy; - - return - ( (dx * dfx + dy * dfy) + sqrt(r*r*(dx*dx + dy*dy) - pow(dx*dfy - dy*dfx, 2.0)) ) - / ( r*r - (dfx*dfx + dfy*dfy) ); - } - - // User defined shader - void shMain(void); - -/*** Main thread *************************************/ - - void main() - { - vec4 col; - - /* Stage 6: Paint Generation */ - switch(paintType){ - case PAINT_TYPE_LINEAR_GRADIENT: - { - vec2 x0 = paintParams[0]; - vec2 x1 = paintParams[1]; - float factor = linearGradient(paintCoord, x0, x1); - col = texture(rampSampler, vec2(factor, 0.5)); - } - break; - case PAINT_TYPE_RADIAL_GRADIENT: - { - vec2 center = paintParams[0]; - vec2 focal = paintParams[1]; - float radius = paintParams[2].x; - float factor = radialGradient(paintCoord, center, focal, radius); - col = texture(rampSampler, vec2(factor, 0.5)); - } - break; - case PAINT_TYPE_PATTERN: - { - float width = paintParams[0].x; - float height = paintParams[0].y; - vec2 texCoord = vec2(paintCoord.x / width, paintCoord.y / height); - col = texture(patternSampler, texCoord); - } - break; - default: - case PAINT_TYPE_COLOR: - col = paintColor; - break; - } - - /* Stage 7: Image Interpolation */ - if(drawMode == DRAW_MODE_IMAGE) { - col = texture(imageSampler, texImageCoord) - * (imageMode == DRAW_IMAGE_MULTIPLY ? col : vec4(1.0, 1.0, 1.0, 1.0)); - } - - /* Stage 8: Color Transformation, Blending, and Antialiasing */ - sh_Color = col * scaleFactorBias[0] + scaleFactorBias[1] ; - - /* Extended Stage: User defined shader that affects gl_FragColor */ - shMain(); - } -)glsl"; - -static const char* vgShaderFragmentUserDefault = R"glsl( - void shMain(){ gl_FragColor = sh_Color; }; -)glsl"; - -static const char* vgShaderVertexColorRamp = R"glsl( - #version 330 - - in vec2 step; - in vec4 stepColor; - out vec4 interpolateColor; - - void main() - { - gl_Position = vec4(step.xy, 0, 1); - interpolateColor = stepColor; - } -)glsl"; - -static const char* vgShaderFragmentColorRamp = R"glsl( - #version 330 - - in vec4 interpolateColor; - out vec4 fragColor; - - void main() - { - fragColor = interpolateColor; - } -)glsl"; +static const char* vgShaderVertexPipeline = +"#version 330\n" +"\n" +"in vec2 pos;\n" +"in vec2 textureUV;\n" +"uniform mat4 sh_Model;\n" +"uniform mat4 sh_Ortho;\n" +"uniform mat3 paintInverted;\n" +"\n" +"out vec2 texImageCoord;\n" +"out vec2 paintCoord;\n" +"\n" +"vec4 sh_Vertex;\n" +"\n" +"void shMain(void);\n" +"\n" +"void main() {\n" +" sh_Vertex = vec4(pos, 0, 1);\n" +" shMain();\n" +" texImageCoord = textureUV;\n" +" paintCoord = (paintInverted * vec3(pos, 1)).xy;\n" +"}\n"; + +static const char* vgShaderVertexUserDefault = +"void shMain(){ gl_Position = sh_Ortho * sh_Model * sh_Vertex; }\n"; + +static const char* vgShaderFragmentPipeline = +"#version 330\n" +"\n" +"#define PAINT_TYPE_COLOR 0x1B00\n" +"#define PAINT_TYPE_LINEAR_GRADIENT 0x1B01\n" +"#define PAINT_TYPE_RADIAL_GRADIENT 0x1B02\n" +"#define PAINT_TYPE_PATTERN 0x1B03\n" +"\n" +"#define DRAW_IMAGE_NORMAL 0x1F00\n" +"#define DRAW_IMAGE_MULTIPLY 0x1F01\n" +"\n" +"#define DRAW_MODE_PATH 0\n" +"#define DRAW_MODE_IMAGE 1\n" +"\n" +"in vec2 texImageCoord;\n" +"in vec2 paintCoord;\n" +"\n" +"uniform int drawMode;\n" +"uniform sampler2D imageSampler;\n" +"uniform int imageMode;\n" +"uniform int paintType;\n" +"uniform vec4 paintColor;\n" +"uniform vec2 paintParams[3];\n" +"uniform sampler2D rampSampler;\n" +"uniform sampler2D patternSampler;\n" +"uniform vec4 scaleFactorBias[2];\n" +"\n" +"out vec4 fragColor;\n" +"vec4 sh_Color;\n" +"\n" +"float linearGradient(vec2 fragCoord, vec2 p0, vec2 p1){\n" +" float x = fragCoord.x;\n" +" float y = fragCoord.y;\n" +" float x0 = p0.x;\n" +" float y0 = p0.y;\n" +" float x1 = p1.x;\n" +" float y1 = p1.y;\n" +" float dx = x1 - x0;\n" +" float dy = y1 - y0;\n" +" return ( dx * (x - x0) + dy * (y - y0) ) / ( dx*dx + dy*dy );\n" +"}\n" +"\n" +"float radialGradient(vec2 fragCoord, vec2 centerCoord, vec2 focalCoord, float r){\n" +" float x = fragCoord.x;\n" +" float y = fragCoord.y;\n" +" float cx = centerCoord.x;\n" +" float cy = centerCoord.y;\n" +" float fx = focalCoord.x;\n" +" float fy = focalCoord.y;\n" +" float dx = x - fx;\n" +" float dy = y - fy;\n" +" float dfx = fx - cx;\n" +" float dfy = fy - cy;\n" +" return ( (dx * dfx + dy * dfy) + sqrt(r*r*(dx*dx + dy*dy) - pow(dx*dfy - dy*dfx, 2.0)) )\n" +" / ( r*r - (dfx*dfx + dfy*dfy) );\n" +"}\n" +"\n" +"void shMain(void);\n" +"\n" +"void main()\n" +"{\n" +" vec4 col;\n" +" switch(paintType){\n" +" case PAINT_TYPE_LINEAR_GRADIENT:\n" +" {\n" +" vec2 x0 = paintParams[0];\n" +" vec2 x1 = paintParams[1];\n" +" float factor = linearGradient(paintCoord, x0, x1);\n" +" col = texture(rampSampler, vec2(factor, 0.5));\n" +" }\n" +" break;\n" +" case PAINT_TYPE_RADIAL_GRADIENT:\n" +" {\n" +" vec2 center = paintParams[0];\n" +" vec2 focal = paintParams[1];\n" +" float radius = paintParams[2].x;\n" +" float factor = radialGradient(paintCoord, center, focal, radius);\n" +" col = texture(rampSampler, vec2(factor, 0.5));\n" +" }\n" +" break;\n" +" case PAINT_TYPE_PATTERN:\n" +" {\n" +" float width = paintParams[0].x;\n" +" float height = paintParams[0].y;\n" +" vec2 texCoord = vec2(paintCoord.x / width, paintCoord.y / height);\n" +" col = texture(patternSampler, texCoord);\n" +" }\n" +" break;\n" +" default:\n" +" case PAINT_TYPE_COLOR:\n" +" col = paintColor;\n" +" break;\n" +" }\n" +" if(drawMode == DRAW_MODE_IMAGE) {\n" +" col = texture(imageSampler, texImageCoord)\n" +" * (imageMode == DRAW_IMAGE_MULTIPLY ? col : vec4(1.0, 1.0, 1.0, 1.0));\n" +" }\n" +" sh_Color = col * scaleFactorBias[0] + scaleFactorBias[1];\n" +" shMain();\n" +"}\n"; + +static const char* vgShaderFragmentUserDefault = +"void shMain(){ fragColor = sh_Color; }\n"; + +static const char* vgShaderVertexColorRamp = +"#version 330\n" +"\n" +"in vec2 step;\n" +"in vec4 stepColor;\n" +"out vec4 interpolateColor;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = vec4(step.xy, 0, 1);\n" +" interpolateColor = stepColor;\n" +"}\n"; + +static const char* vgShaderFragmentColorRamp = +"#version 330\n" +"\n" +"in vec4 interpolateColor;\n" +"out vec4 fragColor;\n" +"\n" +"void main()\n" +"{\n" +" fragColor = interpolateColor;\n" +"}\n"; void shInitPiplelineShaders(void) { @@ -491,4 +429,3 @@ VG_API_CALL void vgUniform4ivSH (VGint location, VGint count, const VGint *value GL_CEHCK_ERROR; } -