Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ aclocal.m4
autom4te.cache/
compile
config.guess
config.h.in~
config.sub
configure
depcomp
Expand Down Expand Up @@ -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

54 changes: 38 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

21 changes: 13 additions & 8 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

/* Define to 1 if you have the <EGL/egl.h> header file. */
#undef HAVE_EGL_EGL_H

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the <jpeglib.h> 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 <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H

/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

Expand All @@ -36,6 +36,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if you have the <X11/Xlib.h> header file. */
#undef HAVE_X11_XLIB_H

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR

Expand All @@ -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 */
Expand Down
124 changes: 65 additions & 59 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,52 @@ 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

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],
Expand All @@ -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 <EGL/egl.h>
#include <EGL/eglext.h>
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"

Expand All @@ -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=""

Expand Down Expand Up @@ -210,7 +216,7 @@ if test "x$build_test_pattern" = "xyes"; then
fi
fi

CFLASGS=""
CFLAGS=""
LDFLAGS=""

# ==============================================
Expand All @@ -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
Expand All @@ -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"])
Expand All @@ -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="
Expand All @@ -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

Expand Down
Loading