Compare commits
46 Commits
mesa-7.8.1
...
mesa-7.8.1
Author | SHA1 | Date | |
---|---|---|---|
|
e61d717a8d | ||
|
80fd9d4857 | ||
|
07694d5c04 | ||
|
41a730e6ea | ||
|
c123f6d97a | ||
|
1338358a49 | ||
|
5c53f88699 | ||
|
b0ea8bf2a5 | ||
|
f1cf090f71 | ||
|
78e28df182 | ||
|
fdf0edf342 | ||
|
4fb488aaf7 | ||
|
2616619ca3 | ||
|
1ff9e27dff | ||
|
ce030a808a | ||
|
2285f3be75 | ||
|
6d95822808 | ||
|
afb27a4a8e | ||
|
1677600902 | ||
|
e716f020bd | ||
|
b27dfb2945 | ||
|
1fd6df6e13 | ||
|
0cbf364871 | ||
|
e73ff6be7a | ||
|
1cfffc29f6 | ||
|
27da77b49a | ||
|
95b8885da8 | ||
|
7a8e3614f7 | ||
|
3e08d1d854 | ||
|
0d685d41fc | ||
|
8ba378d969 | ||
|
942ec8722d | ||
|
45affda4bf | ||
|
593f7cc315 | ||
|
6d18fd6756 | ||
|
51d4d0a12e | ||
|
a548964959 | ||
|
08b98fac62 | ||
|
65c337e29b | ||
|
5726f2f1b8 | ||
|
2d5c596ca4 | ||
|
48ea93eb88 | ||
|
3e6d5aedf0 | ||
|
cfb4f95bd5 | ||
|
d57aa45dac | ||
|
e6f5ca0fa3 |
66
debian/changelog
vendored
66
debian/changelog
vendored
@@ -1,3 +1,60 @@
|
||||
mesa (7.8.1-2) experimental; urgency=low
|
||||
|
||||
[ Tormod Volden ]
|
||||
* debian/rules: Do not strip the same packages twice
|
||||
|
||||
[ Julien Cristau ]
|
||||
* Stop building the ffb dri driver on sparc, it no longer exists.
|
||||
* Merge changes from 7.7.1-2.
|
||||
|
||||
[ Christopher James Halse Rogers ]
|
||||
* debian/compat:
|
||||
- Bump to v7 for dh_install search path behaviour
|
||||
* debian/rules:
|
||||
- Enable gallium for dri build.
|
||||
- Enable egl for dri build.
|
||||
- Build nouveau, radeon & swrast gallium drivers
|
||||
- Build OpenVG, OpenGL|ES, dri, glx & egl state trackers
|
||||
* debian/libegl1-mesa-dev.install:
|
||||
* debian/libegl1-mesa.install:
|
||||
* debian/libegl1-mesa.symbols:
|
||||
- New libEGL package.
|
||||
* debian/libgles1-mesa-dev.install:
|
||||
* debian/libgles1-mesa.install:
|
||||
* debian/libgles1-mesa.symbols:
|
||||
- New OpenGL|ES v1.x package.
|
||||
* debian/libgles2-mesa-dev.install:
|
||||
* debian/libgles2-mesa.install:
|
||||
* debian/libgles2-mesa.symbols:
|
||||
- New OpenGL|ES v2.x package.
|
||||
* debian/libopenvg1-mesa-dev.install:
|
||||
* debian/libopenvg1-mesa.install:
|
||||
* debian/libopenvg1-mesa.symbols:
|
||||
- New OpenVG package.
|
||||
* debian/libegl1-mesa-drivers-x11.install:
|
||||
- New gallium EGL drivers package.
|
||||
* debian/libegl1-mesa-drivers-kms.install:
|
||||
- New gallium EGL kms driver package.
|
||||
* debian/egl.pc:
|
||||
* debian/vg.pc:
|
||||
* debian/glesv1_cm.pc:
|
||||
* debian/glesv2.pc:
|
||||
- Pull pkg-config files from master and install them in the respective
|
||||
-dev packages.
|
||||
* debian/libgl1-mesa-dri-experimental.install:
|
||||
* debian/libgl1-mesa-dri.install:
|
||||
- “make install” puts classic and gallium drivers in the same path, but
|
||||
builds gallium drivers in the gallium/ subdirectory. Copy the drivers
|
||||
directly from the build path, rather than trying to separate them out
|
||||
post-hock.
|
||||
* debian/control:
|
||||
- Add new packages.
|
||||
- Add new build-depends on libx11-xcb-dev, libxcb-dri2-0-dev,
|
||||
libxcb-xfixes0-dev and python-libxml2 for gallium.
|
||||
- Bump build-depends on dpkg-dev for regex in symbols files.
|
||||
|
||||
-- Julien Cristau <jcristau@debian.org> Fri, 11 Jun 2010 03:19:09 +0200
|
||||
|
||||
mesa (7.8.1-1) experimental; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
@@ -8,6 +65,15 @@ mesa (7.8.1-1) experimental; urgency=low
|
||||
|
||||
-- Brice Goglin <bgoglin@debian.org> Sun, 18 Apr 2010 09:25:39 +0200
|
||||
|
||||
mesa (7.7.1-2) unstable; urgency=low
|
||||
|
||||
* debian/rules: use DEB_HOST_ARCH_CPU instead of DEB_HOST_GNU_CPU. Prompted
|
||||
by Ubuntu which changed the latter to i686, breaking their packages on
|
||||
i386.
|
||||
* Pull from mesa_7_7_branch (commit 8ba378d).
|
||||
|
||||
-- Julien Cristau <jcristau@debian.org> Thu, 20 May 2010 17:34:19 +0200
|
||||
|
||||
mesa (7.7.1-1) unstable; urgency=low
|
||||
|
||||
[ Brice Goglin ]
|
||||
|
2
debian/compat
vendored
2
debian/compat
vendored
@@ -1 +1 @@
|
||||
5
|
||||
7
|
||||
|
260
debian/control
vendored
260
debian/control
vendored
@@ -4,12 +4,13 @@ Priority: optional
|
||||
Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
|
||||
Uploaders: David Nusinow <dnusinow@debian.org>, Brice Goglin <bgoglin@debian.org>
|
||||
Standards-Version: 3.8.4
|
||||
Build-Depends: debhelper (>= 6.0.7), quilt (>= 0.40), pkg-config,
|
||||
Build-Depends: debhelper (>= 7.2.7), quilt (>= 0.40), pkg-config,
|
||||
libdrm-dev (>= 2.4.19) [!hurd-i386], libx11-dev, xutils-dev,
|
||||
x11proto-gl-dev (>= 1.4.11), libxxf86vm-dev,
|
||||
libexpat1-dev, lesstif2-dev, dpkg-dev (>= 1.13.19), libxfixes-dev,
|
||||
libexpat1-dev, lesstif2-dev, dpkg-dev (>= 1.15.6), libxfixes-dev,
|
||||
libxdamage-dev, libxext-dev, autoconf, automake, x11proto-dri2-dev (>= 2.1),
|
||||
linux-libc-dev (>= 2.6.31) [!hurd-i386 !kfreebsd-amd64 !kfreebsd-i386]
|
||||
linux-libc-dev (>= 2.6.31) [!hurd-i386 !kfreebsd-amd64 !kfreebsd-i386],
|
||||
libx11-xcb-dev, libxcb-dri2-0-dev, libxcb-xfixes0-dev, python-libxml2,
|
||||
Vcs-Git: git://git.debian.org/git/pkg-xorg/lib/mesa
|
||||
Vcs-Browser: http://git.debian.org/?p=pkg-xorg/lib/mesa.git
|
||||
Homepage: http://mesa3d.sourceforge.net/
|
||||
@@ -102,6 +103,224 @@ Description: A free implementation of the OpenGL API -- development files
|
||||
a direct rendering-capable library, or one which uses GLX. For that,
|
||||
please see libgl1-mesa-dev.
|
||||
|
||||
Package: libegl1-mesa
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Recommends: libegl1-mesa-drivers-x11
|
||||
Description: A free implementation of the EGL API -- runtime
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains modules to interface with the existing system GLX or
|
||||
DRI2 drivers to provide OpenGL via EGL. The libegl1-mesa-drivers-x11 package
|
||||
provides drivers to provide hardware-accelerated OpenGL|ES and OpenVG support.
|
||||
|
||||
Package: libegl1-mesa-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: any
|
||||
Depends: libegl1-mesa (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- debugging symbols
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains the debugging symbols for the EGL library.
|
||||
|
||||
Package: libegl1-mesa-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libegl1-mesa (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- development files
|
||||
This package contains the development environment required for compiling
|
||||
programs against EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package provides the development environment for compiling programs
|
||||
against the EGL library.
|
||||
|
||||
Package: libegl1-mesa-drivers-x11
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- X11 drivers
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains the drivers required for hardware accelerated rendering
|
||||
of EGL-based graphics libraries, such as OpenGL|ES and OpenVG, in an X11
|
||||
environment.
|
||||
|
||||
Package: libegl1-mesa-drivers-x11-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: any
|
||||
Depends: libegl1-mesa-drivers-x11 (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- X11 driver debugging symbols
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains the debugging symbols for the drivers required for
|
||||
hardware accelerated rendering of EGL-based graphics libraries, such as
|
||||
OpenGL|ES and OpenVG, in an X11 environment.
|
||||
|
||||
Package: libegl1-mesa-drivers-kms
|
||||
Section: libs
|
||||
Architecture: linux-any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- KMS drivers
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains the drivers required for hardware accelerated rendering
|
||||
of EGL-based graphics libraries, such as OpenGL|ES and OpenVG in a raw
|
||||
KMS-framebuffer environment.
|
||||
|
||||
Package: libegl1-mesa-drivers-kms-dbg
|
||||
Section: libs
|
||||
Architecture: linux-any
|
||||
Depends: libegl1-mesa-drivers-kms (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the EGL API -- KMS driver debugging symbols
|
||||
This package contains the EGL native platform graphics interface library.
|
||||
EGL provides a platform-agnostic mechanism for creating rendering surfaces
|
||||
for use with other graphics libraries, such as OpenGL|ES and OpenVG.
|
||||
.
|
||||
This package contains the debugging symbols for the drivers required for
|
||||
hardware accelerated rendering of EGL-based graphics libraries, such as
|
||||
OpenGL|ES and OpenVG in a raw KMS-framebuffer environment.
|
||||
|
||||
Package: libopenvg1-mesa
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the OpenVG API -- runtime
|
||||
This package contains the mesa implementation of the OpenVG 2D acceleration
|
||||
library. OpenVG provides a device independent and vendor-neutral interface
|
||||
for sophisticated 2D graphical applications, while allowing device
|
||||
manufacturers to provide hardware acceleration on devices ranging from wrist
|
||||
watches to full microprocessor-based desktop and server machines.
|
||||
|
||||
Package: libopenvg1-mesa-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: any
|
||||
Depends: libopenvg1-mesa (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the OpenVG API -- debugging symbols
|
||||
This package contains the mesa implementation of the OpenVG 2D acceleration
|
||||
library. OpenVG provides a device independent and vendor-neutral interface
|
||||
for sophisticated 2D graphical applications, while allowing device
|
||||
manufacturers to provide hardware acceleration on devices ranging from wrist
|
||||
watches to full microprocessor-based desktop and server machines.
|
||||
.
|
||||
This package contains the debugging symbols for the OpenVG library.
|
||||
|
||||
Package: libopenvg1-mesa-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libopenvg1-mesa (= ${binary:Version}), libegl1-mesa-dev, ${misc:Depends}
|
||||
Description: A free implementation of the OpenVG API -- development files
|
||||
This package contains the mesa implementation of the OpenVG 2D acceleration
|
||||
library. OpenVG provides a device independent and vendor-neutral interface
|
||||
for sophisticated 2D graphical applications, while allowing device
|
||||
manufacturers to provide hardware acceleration on devices ranging from wrist
|
||||
watches to full microprocessor-based desktop and server machines.
|
||||
.
|
||||
This package contains the development environment required for compiling
|
||||
programs against the OpenVG 2D acceleration library.
|
||||
|
||||
Package: libgles1-mesa
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 1.x API -- runtime
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 1.x provides an API for fixed-function hardware.
|
||||
|
||||
Package: libgles1-mesa-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: any
|
||||
Depends: libgles1-mesa (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 1.x API -- debugging symbols
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 1.x provides an API for fixed-function hardware.
|
||||
.
|
||||
This package contains the debugging symbols for the libGLESv1_CM library.
|
||||
|
||||
Package: libgles1-mesa-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libgles1-mesa (= ${binary:Version}), libegl1-mesa-dev, ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 1.x API -- development files
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 1.x provides an API for fixed-function hardware.
|
||||
.
|
||||
This package provides a development environment for building programs using
|
||||
the OpenGL|ES 1.x APIs.
|
||||
|
||||
Package: libgles2-mesa
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 2.x API -- runtime
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 2.x provides an API for programmable hardware including vertex
|
||||
and fragment shaders.
|
||||
|
||||
Package: libgles2-mesa-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: any
|
||||
Depends: libgles2-mesa (= ${binary:Version}), ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 2.x API -- debugging symbols
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 2.x provides an API for programmable hardware including vertex
|
||||
and fragment shaders.
|
||||
.
|
||||
This package contains the debugging symbols for the libGLESv2 library.
|
||||
|
||||
Package: libgles2-mesa-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libgles2-mesa (= ${binary:Version}), libegl1-mesa-dev, ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL|ES 2.x API -- development files
|
||||
OpenGL|ES is a cross-platform API for full-function 2D and 3D graphics on
|
||||
embedded systems - including consoles, phones, appliances and vehicles.
|
||||
It contains a subset of OpenGL plus a number of extensions for the
|
||||
special needs of embedded systems.
|
||||
.
|
||||
OpenGL|ES 2.x provides an API for programmable hardware including vertex
|
||||
and fragment shaders.
|
||||
.
|
||||
This package provides a development environment for building applications
|
||||
using the OpenGL|ES 2.x APIs.
|
||||
|
||||
Package: libgl1-mesa-glx
|
||||
Section: libs
|
||||
Architecture: any
|
||||
@@ -201,6 +420,41 @@ Description: Debugging symbols for the Mesa DRI modules
|
||||
.
|
||||
This package contains debugging symbols for the DRI modules.
|
||||
|
||||
Package: libgl1-mesa-dri-experimental
|
||||
Section: libs
|
||||
Architecture: linux-any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: A free implementation of the OpenGL API -- Extra DRI modules
|
||||
This version of Mesa provides GLX and DRI capabilities: it is capable of
|
||||
both direct and indirect rendering. For direct rendering, it can use DRI
|
||||
modules from the libgl1-mesa-dri package to accelerate drawing.
|
||||
.
|
||||
This package does not include the OpenGL library itself, only the DRI
|
||||
modules for accelerating direct and indirect rendering. The drivers
|
||||
in this package may provide more features than the drivers in the
|
||||
libgl1-mesa-dri at the cost of less stability.
|
||||
.
|
||||
For a complete description of Mesa, please look at the
|
||||
libgl1-mesa-swx11 package.
|
||||
|
||||
Package: libgl1-mesa-dri-experimental-dbg
|
||||
Section: debug
|
||||
Priority: extra
|
||||
Architecture: linux-any
|
||||
Depends: libgl1-mesa-dri-experimental (= ${binary:Version}), ${misc:Depends}
|
||||
Description: Debugging symbols for the experimental Mesa DRI modules
|
||||
This version of Mesa provides GLX and DRI capabilities: it is capable of
|
||||
both direct and indirect rendering. For direct rendering, it can use DRI
|
||||
modules from the libgl1-mesa-dri package to accelerate drawing.
|
||||
.
|
||||
This package does not include the OpenGL library itself, only the DRI
|
||||
modules for accelerating direct rendering.
|
||||
.
|
||||
For a complete description of Mesa, please look at the
|
||||
libgl1-mesa-swx11 package.
|
||||
.
|
||||
This package contains debugging symbols for the Gallium DRI modules.
|
||||
|
||||
#Package: libgl1-mesa-dri-i686
|
||||
#Section: libs
|
||||
#Priority: extra
|
||||
|
12
debian/egl.pc
vendored
Normal file
12
debian/egl.pc
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=/usr/lib
|
||||
includedir=/usr/include
|
||||
|
||||
Name: egl
|
||||
Description: Mesa EGL library
|
||||
Requires.private: libdrm >= 2.4.15 dri2proto >= 2.1 glproto >= 1.4.11 x11 xext xxf86vm xdamage xfixes
|
||||
Version: 7.8.1
|
||||
Libs: -L${libdir} -lEGL
|
||||
Libs.private: -lm -lpthread -ldl
|
||||
Cflags: -I${includedir}
|
12
debian/glesv1_cm.pc
vendored
Normal file
12
debian/glesv1_cm.pc
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=/usr/lib
|
||||
includedir=/usr/include
|
||||
|
||||
Name: glesv1_cm
|
||||
Description: Mesa OpenGL ES 1.1 CM library
|
||||
Requires.private:
|
||||
Version: 7.8.1
|
||||
Libs: -L${libdir} -lGLESv1_CM
|
||||
Libs.private: -lm -lpthread -ldl
|
||||
Cflags: -I${includedir}
|
12
debian/glesv2.pc
vendored
Normal file
12
debian/glesv2.pc
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=/usr/lib
|
||||
includedir=/usr/include
|
||||
|
||||
Name: glesv2
|
||||
Description: Mesa OpenGL ES 2.0 library
|
||||
Requires.private:
|
||||
Version: 7.8.1
|
||||
Libs: -L${libdir} -lGLESv2
|
||||
Libs.private: -lm -lpthread -ldl
|
||||
Cflags: -I${includedir}
|
4
debian/libegl1-mesa-dev.install
vendored
Normal file
4
debian/libegl1-mesa-dev.install
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
usr/lib/glx/libEGL.so usr/lib
|
||||
usr/include/EGL
|
||||
usr/include/KHR
|
||||
debian/egl.pc usr/lib/pkgconfig
|
1
debian/libegl1-mesa-drivers-kms.install
vendored
Normal file
1
debian/libegl1-mesa-drivers-kms.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
usr/lib/glx/egl/egl_kms_*.so
|
1
debian/libegl1-mesa-drivers-x11.install
vendored
Normal file
1
debian/libegl1-mesa-drivers-x11.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
usr/lib/glx/egl/egl_x11_*.so
|
3
debian/libegl1-mesa.install
vendored
Normal file
3
debian/libegl1-mesa.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
usr/lib/glx/libEGL.so.1* usr/lib
|
||||
usr/lib/glx/egl/egl_dri2.so usr/lib/egl
|
||||
usr/lib/glx/egl/egl_glx.so usr/lib/egl
|
79
debian/libegl1-mesa.symbols
vendored
Normal file
79
debian/libegl1-mesa.symbols
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
libEGL.so.1 libegl1-mesa #MINVER#
|
||||
_eglAddConfig@Base 7.8.1
|
||||
_eglAddNewMode@Base 7.8.1
|
||||
_eglAddScreen@Base 7.8.1
|
||||
_eglBindContext@Base 7.8.1
|
||||
_eglCheckResource@Base 7.8.1
|
||||
_eglCleanupDisplay@Base 7.8.1
|
||||
_eglCompareConfigs@Base 7.8.1
|
||||
_eglConfigFromContextModesRec@Base 7.8.1
|
||||
_eglConfigToContextModesRec@Base 7.8.1
|
||||
_eglDestroyScreen@Base 7.8.1
|
||||
_eglError@Base 7.8.1
|
||||
_eglGetAPIContext@Base 7.8.1
|
||||
_eglGetCurrentContext@Base 7.8.1
|
||||
_eglGetCurrentThread@Base 7.8.1
|
||||
_eglGetProbeCache@Base 7.8.1
|
||||
_eglInitConfig@Base 7.8.1
|
||||
_eglInitContext@Base 7.8.1
|
||||
_eglInitDriverFallbacks@Base 7.8.1
|
||||
_eglInitImage@Base 7.8.1
|
||||
_eglInitScreen@Base 7.8.1
|
||||
_eglInitSurface@Base 7.8.1
|
||||
_eglLog@Base 7.8.1
|
||||
_eglMatchConfig@Base 7.8.1
|
||||
_eglParseConfigAttribList@Base 7.8.1
|
||||
_eglReleaseDisplayResources@Base 7.8.1
|
||||
_eglSetLogLevel@Base 7.8.1
|
||||
_eglSetLogProc@Base 7.8.1
|
||||
_eglSetProbeCache@Base 7.8.1
|
||||
_eglSortConfigs@Base 7.8.1
|
||||
_eglValidateConfig@Base 7.8.1
|
||||
eglBindAPI@Base 7.8.1
|
||||
eglBindTexImage@Base 7.8.1
|
||||
eglChooseConfig@Base 7.8.1
|
||||
eglChooseModeMESA@Base 7.8.1
|
||||
eglCopyBuffers@Base 7.8.1
|
||||
eglCopyContextMESA@Base 7.8.1
|
||||
eglCreateContext@Base 7.8.1
|
||||
eglCreateImageKHR@Base 7.8.1
|
||||
eglCreatePbufferFromClientBuffer@Base 7.8.1
|
||||
eglCreatePbufferSurface@Base 7.8.1
|
||||
eglCreatePixmapSurface@Base 7.8.1
|
||||
eglCreateScreenSurfaceMESA@Base 7.8.1
|
||||
eglCreateWindowSurface@Base 7.8.1
|
||||
eglDestroyContext@Base 7.8.1
|
||||
eglDestroyImageKHR@Base 7.8.1
|
||||
eglDestroySurface@Base 7.8.1
|
||||
eglGetConfigAttrib@Base 7.8.1
|
||||
eglGetConfigs@Base 7.8.1
|
||||
eglGetCurrentContext@Base 7.8.1
|
||||
eglGetCurrentDisplay@Base 7.8.1
|
||||
eglGetCurrentSurface@Base 7.8.1
|
||||
eglGetDisplay@Base 7.8.1
|
||||
eglGetError@Base 7.8.1
|
||||
eglGetModeAttribMESA@Base 7.8.1
|
||||
eglGetModesMESA@Base 7.8.1
|
||||
eglGetProcAddress@Base 7.8.1
|
||||
eglGetScreensMESA@Base 7.8.1
|
||||
eglInitialize@Base 7.8.1
|
||||
eglMakeCurrent@Base 7.8.1
|
||||
eglQueryAPI@Base 7.8.1
|
||||
eglQueryContext@Base 7.8.1
|
||||
eglQueryModeStringMESA@Base 7.8.1
|
||||
eglQueryScreenMESA@Base 7.8.1
|
||||
eglQueryScreenModeMESA@Base 7.8.1
|
||||
eglQueryScreenSurfaceMESA@Base 7.8.1
|
||||
eglQueryString@Base 7.8.1
|
||||
eglQuerySurface@Base 7.8.1
|
||||
eglReleaseTexImage@Base 7.8.1
|
||||
eglReleaseThread@Base 7.8.1
|
||||
eglScreenPositionMESA@Base 7.8.1
|
||||
eglShowScreenSurfaceMESA@Base 7.8.1
|
||||
eglSurfaceAttrib@Base 7.8.1
|
||||
eglSwapBuffers@Base 7.8.1
|
||||
eglSwapInterval@Base 7.8.1
|
||||
eglTerminate@Base 7.8.1
|
||||
eglWaitClient@Base 7.8.1
|
||||
eglWaitGL@Base 7.8.1
|
||||
eglWaitNative@Base 7.8.1
|
1
debian/libgl1-mesa-dri-experimental.install
vendored
Normal file
1
debian/libgl1-mesa-dri-experimental.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build/dri/glx/gallium/nouveau_dri.so usr/lib/dri
|
2
debian/libgl1-mesa-dri.install
vendored
2
debian/libgl1-mesa-dri.install
vendored
@@ -1 +1 @@
|
||||
usr/lib/dri/*.so
|
||||
build/dri/glx/*_dri.so usr/lib/dri/
|
||||
|
3
debian/libgles1-mesa-dev.install
vendored
Normal file
3
debian/libgles1-mesa-dev.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
usr/glx/libGLESv1_CM.so usr/lib
|
||||
usr/include/GLES
|
||||
debian/glesv1_cm.pc usr/lib/pkgconfig
|
1
debian/libgles1-mesa.install
vendored
Normal file
1
debian/libgles1-mesa.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
usr/glx/libGLESv1_CM.so.1* usr/lib
|
265
debian/libgles1-mesa.symbols
vendored
Normal file
265
debian/libgles1-mesa.symbols
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
libGLESv1_CM.so.1 libgles1-mesa #MINVER#
|
||||
# _glapi_* are internal GL dispatch symbols. They should probably be hidden
|
||||
(regex)"^_glapi_.*@Base$" 7.8.1
|
||||
# These are optimised assembly versions of functions, accessed through a
|
||||
# dispatch table. They're arch-specific, and should probably be hidden.
|
||||
(regex|optional=mesa internal ASM optimized functions)"^_mesa_.*@Base$" 7.8.1
|
||||
_glthread_GetID@Base 7.8.1
|
||||
glActiveTexture@Base 7.8.1
|
||||
glAlphaFunc@Base 7.8.1
|
||||
glAlphaFuncx@Base 7.8.1
|
||||
glAlphaFuncxOES@Base 7.8.1
|
||||
glBindBuffer@Base 7.8.1
|
||||
glBindFramebufferOES@Base 7.8.1
|
||||
glBindRenderbufferOES@Base 7.8.1
|
||||
glBindTexture@Base 7.8.1
|
||||
glBlendEquationOES@Base 7.8.1
|
||||
glBlendEquationSeparateOES@Base 7.8.1
|
||||
glBlendFunc@Base 7.8.1
|
||||
glBlendFuncSeparateOES@Base 7.8.1
|
||||
glBufferData@Base 7.8.1
|
||||
glBufferSubData@Base 7.8.1
|
||||
glCheckFramebufferStatusOES@Base 7.8.1
|
||||
glClear@Base 7.8.1
|
||||
glClearColor@Base 7.8.1
|
||||
glClearColorx@Base 7.8.1
|
||||
glClearColorxOES@Base 7.8.1
|
||||
glClearDepthf@Base 7.8.1
|
||||
glClearDepthfOES@Base 7.8.1
|
||||
glClearDepthx@Base 7.8.1
|
||||
glClearDepthxOES@Base 7.8.1
|
||||
glClearStencil@Base 7.8.1
|
||||
glClientActiveTexture@Base 7.8.1
|
||||
glClipPlanef@Base 7.8.1
|
||||
glClipPlanefOES@Base 7.8.1
|
||||
glClipPlanex@Base 7.8.1
|
||||
glClipPlanexOES@Base 7.8.1
|
||||
glColor4f@Base 7.8.1
|
||||
glColor4ub@Base 7.8.1
|
||||
glColor4x@Base 7.8.1
|
||||
glColor4xOES@Base 7.8.1
|
||||
glColorMask@Base 7.8.1
|
||||
glColorPointer@Base 7.8.1
|
||||
glCompressedTexImage2D@Base 7.8.1
|
||||
glCompressedTexSubImage2D@Base 7.8.1
|
||||
glCopyTexImage2D@Base 7.8.1
|
||||
glCopyTexSubImage2D@Base 7.8.1
|
||||
glCullFace@Base 7.8.1
|
||||
glDeleteBuffers@Base 7.8.1
|
||||
glDeleteFramebuffersOES@Base 7.8.1
|
||||
glDeleteRenderbuffersOES@Base 7.8.1
|
||||
glDeleteTextures@Base 7.8.1
|
||||
glDepthFunc@Base 7.8.1
|
||||
glDepthMask@Base 7.8.1
|
||||
glDepthRangef@Base 7.8.1
|
||||
glDepthRangefOES@Base 7.8.1
|
||||
glDepthRangex@Base 7.8.1
|
||||
glDepthRangexOES@Base 7.8.1
|
||||
glDisable@Base 7.8.1
|
||||
glDisableClientState@Base 7.8.1
|
||||
glDrawArrays@Base 7.8.1
|
||||
glDrawElements@Base 7.8.1
|
||||
glDrawTexfOES@Base 7.8.1
|
||||
glDrawTexfvOES@Base 7.8.1
|
||||
glDrawTexiOES@Base 7.8.1
|
||||
glDrawTexivOES@Base 7.8.1
|
||||
glDrawTexsOES@Base 7.8.1
|
||||
glDrawTexsvOES@Base 7.8.1
|
||||
glDrawTexxOES@Base 7.8.1
|
||||
glDrawTexxvOES@Base 7.8.1
|
||||
glEGLImageTargetRenderbufferStorageOES@Base 7.8.1
|
||||
glEGLImageTargetTexture2DOES@Base 7.8.1
|
||||
glEnable@Base 7.8.1
|
||||
glEnableClientState@Base 7.8.1
|
||||
glFinish@Base 7.8.1
|
||||
glFlush@Base 7.8.1
|
||||
glFogf@Base 7.8.1
|
||||
glFogfv@Base 7.8.1
|
||||
glFogx@Base 7.8.1
|
||||
glFogxOES@Base 7.8.1
|
||||
glFogxv@Base 7.8.1
|
||||
glFogxvOES@Base 7.8.1
|
||||
glFramebufferRenderbufferOES@Base 7.8.1
|
||||
glFramebufferTexture2DOES@Base 7.8.1
|
||||
glFrontFace@Base 7.8.1
|
||||
glFrustumf@Base 7.8.1
|
||||
glFrustumfOES@Base 7.8.1
|
||||
glFrustumx@Base 7.8.1
|
||||
glFrustumxOES@Base 7.8.1
|
||||
glGenBuffers@Base 7.8.1
|
||||
glGenFramebuffersOES@Base 7.8.1
|
||||
glGenRenderbuffersOES@Base 7.8.1
|
||||
glGenTextures@Base 7.8.1
|
||||
glGenerateMipmapOES@Base 7.8.1
|
||||
glGetBooleanv@Base 7.8.1
|
||||
glGetBufferParameteriv@Base 7.8.1
|
||||
glGetBufferPointervOES@Base 7.8.1
|
||||
glGetClipPlanef@Base 7.8.1
|
||||
glGetClipPlanefOES@Base 7.8.1
|
||||
glGetClipPlanex@Base 7.8.1
|
||||
glGetClipPlanexOES@Base 7.8.1
|
||||
glGetError@Base 7.8.1
|
||||
glGetFixedv@Base 7.8.1
|
||||
glGetFixedvOES@Base 7.8.1
|
||||
glGetFloatv@Base 7.8.1
|
||||
glGetFramebufferAttachmentParameterivOES@Base 7.8.1
|
||||
glGetIntegerv@Base 7.8.1
|
||||
glGetLightfv@Base 7.8.1
|
||||
glGetLightxv@Base 7.8.1
|
||||
glGetLightxvOES@Base 7.8.1
|
||||
glGetMaterialfv@Base 7.8.1
|
||||
glGetMaterialxv@Base 7.8.1
|
||||
glGetMaterialxvOES@Base 7.8.1
|
||||
glGetPointerv@Base 7.8.1
|
||||
glGetRenderbufferParameterivOES@Base 7.8.1
|
||||
glGetString@Base 7.8.1
|
||||
glGetTexEnvfv@Base 7.8.1
|
||||
glGetTexEnviv@Base 7.8.1
|
||||
glGetTexEnvxv@Base 7.8.1
|
||||
glGetTexEnvxvOES@Base 7.8.1
|
||||
glGetTexGenfvOES@Base 7.8.1
|
||||
glGetTexGenivOES@Base 7.8.1
|
||||
glGetTexGenxvOES@Base 7.8.1
|
||||
glGetTexParameterfv@Base 7.8.1
|
||||
glGetTexParameteriv@Base 7.8.1
|
||||
glGetTexParameterxv@Base 7.8.1
|
||||
glGetTexParameterxvOES@Base 7.8.1
|
||||
glHint@Base 7.8.1
|
||||
glIsBuffer@Base 7.8.1
|
||||
glIsEnabled@Base 7.8.1
|
||||
glIsFramebufferOES@Base 7.8.1
|
||||
glIsRenderbufferOES@Base 7.8.1
|
||||
glIsTexture@Base 7.8.1
|
||||
glLightModelf@Base 7.8.1
|
||||
glLightModelfv@Base 7.8.1
|
||||
glLightModelx@Base 7.8.1
|
||||
glLightModelxOES@Base 7.8.1
|
||||
glLightModelxv@Base 7.8.1
|
||||
glLightModelxvOES@Base 7.8.1
|
||||
glLightf@Base 7.8.1
|
||||
glLightfv@Base 7.8.1
|
||||
glLightx@Base 7.8.1
|
||||
glLightxOES@Base 7.8.1
|
||||
glLightxv@Base 7.8.1
|
||||
glLightxvOES@Base 7.8.1
|
||||
glLineWidth@Base 7.8.1
|
||||
glLineWidthx@Base 7.8.1
|
||||
glLineWidthxOES@Base 7.8.1
|
||||
glLoadIdentity@Base 7.8.1
|
||||
glLoadMatrixf@Base 7.8.1
|
||||
glLoadMatrixx@Base 7.8.1
|
||||
glLoadMatrixxOES@Base 7.8.1
|
||||
glLogicOp@Base 7.8.1
|
||||
glMapBufferOES@Base 7.8.1
|
||||
glMaterialf@Base 7.8.1
|
||||
glMaterialfv@Base 7.8.1
|
||||
glMaterialx@Base 7.8.1
|
||||
glMaterialxOES@Base 7.8.1
|
||||
glMaterialxv@Base 7.8.1
|
||||
glMaterialxvOES@Base 7.8.1
|
||||
glMatrixMode@Base 7.8.1
|
||||
glMultMatrixf@Base 7.8.1
|
||||
glMultMatrixx@Base 7.8.1
|
||||
glMultMatrixxOES@Base 7.8.1
|
||||
glMultiDrawArraysEXT@Base 7.8.1
|
||||
glMultiDrawElementsEXT@Base 7.8.1
|
||||
glMultiTexCoord4f@Base 7.8.1
|
||||
glMultiTexCoord4x@Base 7.8.1
|
||||
glMultiTexCoord4xOES@Base 7.8.1
|
||||
glNormal3f@Base 7.8.1
|
||||
glNormal3x@Base 7.8.1
|
||||
glNormal3xOES@Base 7.8.1
|
||||
glNormalPointer@Base 7.8.1
|
||||
glOrthof@Base 7.8.1
|
||||
glOrthofOES@Base 7.8.1
|
||||
glOrthox@Base 7.8.1
|
||||
glOrthoxOES@Base 7.8.1
|
||||
glPixelStorei@Base 7.8.1
|
||||
glPointParameterf@Base 7.8.1
|
||||
glPointParameterfv@Base 7.8.1
|
||||
glPointParameterx@Base 7.8.1
|
||||
glPointParameterxOES@Base 7.8.1
|
||||
glPointParameterxv@Base 7.8.1
|
||||
glPointParameterxvOES@Base 7.8.1
|
||||
glPointSize@Base 7.8.1
|
||||
glPointSizePointerOES@Base 7.8.1
|
||||
glPointSizex@Base 7.8.1
|
||||
glPointSizexOES@Base 7.8.1
|
||||
glPolygonOffset@Base 7.8.1
|
||||
glPolygonOffsetx@Base 7.8.1
|
||||
glPolygonOffsetxOES@Base 7.8.1
|
||||
glPopMatrix@Base 7.8.1
|
||||
glPushMatrix@Base 7.8.1
|
||||
glQueryMatrixxOES@Base 7.8.1
|
||||
glReadPixels@Base 7.8.1
|
||||
glRenderbufferStorageOES@Base 7.8.1
|
||||
glRotatef@Base 7.8.1
|
||||
glRotatex@Base 7.8.1
|
||||
glRotatexOES@Base 7.8.1
|
||||
glSampleCoverage@Base 7.8.1
|
||||
glSampleCoveragex@Base 7.8.1
|
||||
glSampleCoveragexOES@Base 7.8.1
|
||||
glScalef@Base 7.8.1
|
||||
glScalex@Base 7.8.1
|
||||
glScalexOES@Base 7.8.1
|
||||
glScissor@Base 7.8.1
|
||||
glShadeModel@Base 7.8.1
|
||||
glStencilFunc@Base 7.8.1
|
||||
glStencilMask@Base 7.8.1
|
||||
glStencilOp@Base 7.8.1
|
||||
glTexCoordPointer@Base 7.8.1
|
||||
glTexEnvf@Base 7.8.1
|
||||
glTexEnvfv@Base 7.8.1
|
||||
glTexEnvi@Base 7.8.1
|
||||
glTexEnviv@Base 7.8.1
|
||||
glTexEnvx@Base 7.8.1
|
||||
glTexEnvxOES@Base 7.8.1
|
||||
glTexEnvxv@Base 7.8.1
|
||||
glTexEnvxvOES@Base 7.8.1
|
||||
glTexGenfOES@Base 7.8.1
|
||||
glTexGenfvOES@Base 7.8.1
|
||||
glTexGeniOES@Base 7.8.1
|
||||
glTexGenivOES@Base 7.8.1
|
||||
glTexGenxOES@Base 7.8.1
|
||||
glTexGenxvOES@Base 7.8.1
|
||||
glTexImage2D@Base 7.8.1
|
||||
glTexParameterf@Base 7.8.1
|
||||
glTexParameterfv@Base 7.8.1
|
||||
glTexParameteri@Base 7.8.1
|
||||
glTexParameteriv@Base 7.8.1
|
||||
glTexParameterx@Base 7.8.1
|
||||
glTexParameterxOES@Base 7.8.1
|
||||
glTexParameterxv@Base 7.8.1
|
||||
glTexParameterxvOES@Base 7.8.1
|
||||
glTexSubImage2D@Base 7.8.1
|
||||
glTranslatef@Base 7.8.1
|
||||
glTranslatex@Base 7.8.1
|
||||
glTranslatexOES@Base 7.8.1
|
||||
glUnmapBufferOES@Base 7.8.1
|
||||
glVertexPointer@Base 7.8.1
|
||||
glViewport@Base 7.8.1
|
||||
# These are internal gallium statetracker symbols.
|
||||
# They should probably be hidden
|
||||
st_api_OpenGL_ES1@Base 7.8.1
|
||||
st_bind_teximage@Base 7.8.1
|
||||
st_bind_texture_surface@Base 7.8.1
|
||||
st_copy_context_state@Base 7.8.1
|
||||
st_create_context@Base 7.8.1
|
||||
st_create_framebuffer@Base 7.8.1
|
||||
st_destroy_context@Base 7.8.1
|
||||
st_finish@Base 7.8.1
|
||||
st_flush@Base 7.8.1
|
||||
st_framebuffer_private@Base 7.8.1
|
||||
st_get_current@Base 7.8.1
|
||||
st_get_framebuffer_dimensions@Base 7.8.1
|
||||
st_get_framebuffer_surface@Base 7.8.1
|
||||
st_get_framebuffer_texture@Base 7.8.1
|
||||
st_get_proc_address@Base 7.8.1
|
||||
st_make_current@Base 7.8.1
|
||||
st_notify_swapbuffers@Base 7.8.1
|
||||
st_release_teximage@Base 7.8.1
|
||||
st_resize_framebuffer@Base 7.8.1
|
||||
st_set_framebuffer_surface@Base 7.8.1
|
||||
st_swapbuffers@Base 7.8.1
|
||||
st_unbind_texture_surface@Base 7.8.1
|
||||
st_unreference_framebuffer@Base 7.8.1
|
3
debian/libgles2-mesa-dev.install
vendored
Normal file
3
debian/libgles2-mesa-dev.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
usr/glx/libGLESv2.so usr/lib
|
||||
usr/include/GLES2
|
||||
debian/glesv2.pc usr/lib/pkgconfig
|
1
debian/libgles2-mesa.install
vendored
Normal file
1
debian/libgles2-mesa.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
usr/glx/libGLESv2.so.2* usr/lib
|
189
debian/libgles2-mesa.symbols
vendored
Normal file
189
debian/libgles2-mesa.symbols
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
libGLESv2.so.2 libgles2-mesa #MINVER#
|
||||
# _glapi_* are internal GL dispatch symbols. They should probably be hidden.
|
||||
(regex)"^_glapi_.*@Base$" 7.8.1
|
||||
# These are optimised assembly versions of functions, accessed through a
|
||||
# dispatch table. They're arch-specific, and should probably be hidden.
|
||||
(regex|optional=mesa internal ASM optimized functions)"^_mesa_.*@Base$" 7.8.1
|
||||
_glthread_GetID@Base 7.8.1
|
||||
glActiveTexture@Base 7.8.1
|
||||
glAttachShader@Base 7.8.1
|
||||
glBindAttribLocation@Base 7.8.1
|
||||
glBindBuffer@Base 7.8.1
|
||||
glBindFramebuffer@Base 7.8.1
|
||||
glBindRenderbuffer@Base 7.8.1
|
||||
glBindTexture@Base 7.8.1
|
||||
glBlendColor@Base 7.8.1
|
||||
glBlendEquation@Base 7.8.1
|
||||
glBlendEquationSeparate@Base 7.8.1
|
||||
glBlendFunc@Base 7.8.1
|
||||
glBlendFuncSeparate@Base 7.8.1
|
||||
glBufferData@Base 7.8.1
|
||||
glBufferSubData@Base 7.8.1
|
||||
glCheckFramebufferStatus@Base 7.8.1
|
||||
glClear@Base 7.8.1
|
||||
glClearColor@Base 7.8.1
|
||||
glClearDepthf@Base 7.8.1
|
||||
glClearStencil@Base 7.8.1
|
||||
glColorMask@Base 7.8.1
|
||||
glCompileShader@Base 7.8.1
|
||||
glCompressedTexImage2D@Base 7.8.1
|
||||
glCompressedTexImage3DOES@Base 7.8.1
|
||||
glCompressedTexSubImage2D@Base 7.8.1
|
||||
glCompressedTexSubImage3DOES@Base 7.8.1
|
||||
glCopyTexImage2D@Base 7.8.1
|
||||
glCopyTexSubImage2D@Base 7.8.1
|
||||
glCopyTexSubImage3DOES@Base 7.8.1
|
||||
glCreateProgram@Base 7.8.1
|
||||
glCreateShader@Base 7.8.1
|
||||
glCullFace@Base 7.8.1
|
||||
glDeleteBuffers@Base 7.8.1
|
||||
glDeleteFramebuffers@Base 7.8.1
|
||||
glDeleteProgram@Base 7.8.1
|
||||
glDeleteRenderbuffers@Base 7.8.1
|
||||
glDeleteShader@Base 7.8.1
|
||||
glDeleteTextures@Base 7.8.1
|
||||
glDepthFunc@Base 7.8.1
|
||||
glDepthMask@Base 7.8.1
|
||||
glDepthRangef@Base 7.8.1
|
||||
glDetachShader@Base 7.8.1
|
||||
glDisable@Base 7.8.1
|
||||
glDisableVertexAttribArray@Base 7.8.1
|
||||
glDrawArrays@Base 7.8.1
|
||||
glDrawElements@Base 7.8.1
|
||||
glEGLImageTargetRenderbufferStorageOES@Base 7.8.1
|
||||
glEGLImageTargetTexture2DOES@Base 7.8.1
|
||||
glEnable@Base 7.8.1
|
||||
glEnableVertexAttribArray@Base 7.8.1
|
||||
glFinish@Base 7.8.1
|
||||
glFlush@Base 7.8.1
|
||||
glFramebufferRenderbuffer@Base 7.8.1
|
||||
glFramebufferTexture2D@Base 7.8.1
|
||||
glFramebufferTexture3DOES@Base 7.8.1
|
||||
glFrontFace@Base 7.8.1
|
||||
glGenBuffers@Base 7.8.1
|
||||
glGenFramebuffers@Base 7.8.1
|
||||
glGenRenderbuffers@Base 7.8.1
|
||||
glGenTextures@Base 7.8.1
|
||||
glGenerateMipmap@Base 7.8.1
|
||||
glGetActiveAttrib@Base 7.8.1
|
||||
glGetActiveUniform@Base 7.8.1
|
||||
glGetAttachedShaders@Base 7.8.1
|
||||
glGetAttribLocation@Base 7.8.1
|
||||
glGetBooleanv@Base 7.8.1
|
||||
glGetBufferParameteriv@Base 7.8.1
|
||||
glGetBufferPointervOES@Base 7.8.1
|
||||
glGetError@Base 7.8.1
|
||||
glGetFloatv@Base 7.8.1
|
||||
glGetFramebufferAttachmentParameteriv@Base 7.8.1
|
||||
glGetIntegerv@Base 7.8.1
|
||||
glGetProgramBinaryOES@Base 7.8.1
|
||||
glGetProgramInfoLog@Base 7.8.1
|
||||
glGetProgramiv@Base 7.8.1
|
||||
glGetRenderbufferParameteriv@Base 7.8.1
|
||||
glGetShaderInfoLog@Base 7.8.1
|
||||
glGetShaderPrecisionFormat@Base 7.8.1
|
||||
glGetShaderSource@Base 7.8.1
|
||||
glGetShaderiv@Base 7.8.1
|
||||
glGetString@Base 7.8.1
|
||||
glGetTexParameterfv@Base 7.8.1
|
||||
glGetTexParameteriv@Base 7.8.1
|
||||
glGetUniformLocation@Base 7.8.1
|
||||
glGetUniformfv@Base 7.8.1
|
||||
glGetUniformiv@Base 7.8.1
|
||||
glGetVertexAttribPointerv@Base 7.8.1
|
||||
glGetVertexAttribfv@Base 7.8.1
|
||||
glGetVertexAttribiv@Base 7.8.1
|
||||
glHint@Base 7.8.1
|
||||
glIsBuffer@Base 7.8.1
|
||||
glIsEnabled@Base 7.8.1
|
||||
glIsFramebuffer@Base 7.8.1
|
||||
glIsProgram@Base 7.8.1
|
||||
glIsRenderbuffer@Base 7.8.1
|
||||
glIsShader@Base 7.8.1
|
||||
glIsTexture@Base 7.8.1
|
||||
glLineWidth@Base 7.8.1
|
||||
glLinkProgram@Base 7.8.1
|
||||
glMapBufferOES@Base 7.8.1
|
||||
glMultiDrawArraysEXT@Base 7.8.1
|
||||
glMultiDrawElementsEXT@Base 7.8.1
|
||||
glPixelStorei@Base 7.8.1
|
||||
glPolygonOffset@Base 7.8.1
|
||||
glProgramBinaryOES@Base 7.8.1
|
||||
glReadPixels@Base 7.8.1
|
||||
glReleaseShaderCompiler@Base 7.8.1
|
||||
glRenderbufferStorage@Base 7.8.1
|
||||
glSampleCoverage@Base 7.8.1
|
||||
glScissor@Base 7.8.1
|
||||
glShaderBinary@Base 7.8.1
|
||||
glShaderSource@Base 7.8.1
|
||||
glStencilFunc@Base 7.8.1
|
||||
glStencilFuncSeparate@Base 7.8.1
|
||||
glStencilMask@Base 7.8.1
|
||||
glStencilMaskSeparate@Base 7.8.1
|
||||
glStencilOp@Base 7.8.1
|
||||
glStencilOpSeparate@Base 7.8.1
|
||||
glTexImage2D@Base 7.8.1
|
||||
glTexImage3DOES@Base 7.8.1
|
||||
glTexParameterf@Base 7.8.1
|
||||
glTexParameterfv@Base 7.8.1
|
||||
glTexParameteri@Base 7.8.1
|
||||
glTexParameteriv@Base 7.8.1
|
||||
glTexSubImage2D@Base 7.8.1
|
||||
glTexSubImage3DOES@Base 7.8.1
|
||||
glUniform1f@Base 7.8.1
|
||||
glUniform1fv@Base 7.8.1
|
||||
glUniform1i@Base 7.8.1
|
||||
glUniform1iv@Base 7.8.1
|
||||
glUniform2f@Base 7.8.1
|
||||
glUniform2fv@Base 7.8.1
|
||||
glUniform2i@Base 7.8.1
|
||||
glUniform2iv@Base 7.8.1
|
||||
glUniform3f@Base 7.8.1
|
||||
glUniform3fv@Base 7.8.1
|
||||
glUniform3i@Base 7.8.1
|
||||
glUniform3iv@Base 7.8.1
|
||||
glUniform4f@Base 7.8.1
|
||||
glUniform4fv@Base 7.8.1
|
||||
glUniform4i@Base 7.8.1
|
||||
glUniform4iv@Base 7.8.1
|
||||
glUniformMatrix2fv@Base 7.8.1
|
||||
glUniformMatrix3fv@Base 7.8.1
|
||||
glUniformMatrix4fv@Base 7.8.1
|
||||
glUnmapBufferOES@Base 7.8.1
|
||||
glUseProgram@Base 7.8.1
|
||||
glValidateProgram@Base 7.8.1
|
||||
glVertexAttrib1f@Base 7.8.1
|
||||
glVertexAttrib1fv@Base 7.8.1
|
||||
glVertexAttrib2f@Base 7.8.1
|
||||
glVertexAttrib2fv@Base 7.8.1
|
||||
glVertexAttrib3f@Base 7.8.1
|
||||
glVertexAttrib3fv@Base 7.8.1
|
||||
glVertexAttrib4f@Base 7.8.1
|
||||
glVertexAttrib4fv@Base 7.8.1
|
||||
glVertexAttribPointer@Base 7.8.1
|
||||
glViewport@Base 7.8.1
|
||||
# These are internal gallium statetracker symbols.
|
||||
# They should probably be hidden
|
||||
st_api_OpenGL_ES2@Base 7.8.1
|
||||
st_bind_teximage@Base 7.8.1
|
||||
st_bind_texture_surface@Base 7.8.1
|
||||
st_copy_context_state@Base 7.8.1
|
||||
st_create_context@Base 7.8.1
|
||||
st_create_framebuffer@Base 7.8.1
|
||||
st_destroy_context@Base 7.8.1
|
||||
st_finish@Base 7.8.1
|
||||
st_flush@Base 7.8.1
|
||||
st_framebuffer_private@Base 7.8.1
|
||||
st_get_current@Base 7.8.1
|
||||
st_get_framebuffer_dimensions@Base 7.8.1
|
||||
st_get_framebuffer_surface@Base 7.8.1
|
||||
st_get_framebuffer_texture@Base 7.8.1
|
||||
st_get_proc_address@Base 7.8.1
|
||||
st_make_current@Base 7.8.1
|
||||
st_notify_swapbuffers@Base 7.8.1
|
||||
st_release_teximage@Base 7.8.1
|
||||
st_resize_framebuffer@Base 7.8.1
|
||||
st_set_framebuffer_surface@Base 7.8.1
|
||||
st_swapbuffers@Base 7.8.1
|
||||
st_unbind_texture_surface@Base 7.8.1
|
||||
st_unreference_framebuffer@Base 7.8.1
|
3
debian/libopenvg1-mesa-dev.install
vendored
Normal file
3
debian/libopenvg1-mesa-dev.install
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
usr/glx/libOpenVG.so usr/lib
|
||||
usr/include/VG
|
||||
debian/vg.pc usr/lib/pkgconfig
|
1
debian/libopenvg1-mesa.install
vendored
Normal file
1
debian/libopenvg1-mesa.install
vendored
Normal file
@@ -0,0 +1 @@
|
||||
usr/glx/libOpenVG.so.1* usr/lib
|
106
debian/libopenvg1-mesa.symbols
vendored
Normal file
106
debian/libopenvg1-mesa.symbols
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
libOpenVG.so.1 libopenvg1-mesa #MINVER#
|
||||
st_api_OpenVG@Base 7.8.1
|
||||
st_bind_texture_surface@Base 7.8.1
|
||||
st_copy_context_state@Base 7.8.1
|
||||
st_create_context@Base 7.8.1
|
||||
st_create_framebuffer@Base 7.8.1
|
||||
st_destroy_context@Base 7.8.1
|
||||
st_finish@Base 7.8.1
|
||||
st_flush@Base 7.8.1
|
||||
st_framebuffer_private@Base 7.8.1
|
||||
st_get_current@Base 7.8.1
|
||||
st_get_framebuffer_dimensions@Base 7.8.1
|
||||
st_get_framebuffer_surface@Base 7.8.1
|
||||
st_get_framebuffer_texture@Base 7.8.1
|
||||
st_get_proc_address@Base 7.8.1
|
||||
st_make_current@Base 7.8.1
|
||||
st_notify_swapbuffers@Base 7.8.1
|
||||
st_notify_swapbuffers_complete@Base 7.8.1
|
||||
st_resize_framebuffer@Base 7.8.1
|
||||
st_set_framebuffer_surface@Base 7.8.1
|
||||
st_unbind_texture_surface@Base 7.8.1
|
||||
st_unreference_framebuffer@Base 7.8.1
|
||||
vgAppendPath@Base 7.8.1
|
||||
vgAppendPathData@Base 7.8.1
|
||||
vgChildImage@Base 7.8.1
|
||||
vgClear@Base 7.8.1
|
||||
vgClearImage@Base 7.8.1
|
||||
vgClearPath@Base 7.8.1
|
||||
vgColorMatrix@Base 7.8.1
|
||||
vgConvolve@Base 7.8.1
|
||||
vgCopyImage@Base 7.8.1
|
||||
vgCopyPixels@Base 7.8.1
|
||||
vgCreateImage@Base 7.8.1
|
||||
vgCreatePaint@Base 7.8.1
|
||||
vgCreatePath@Base 7.8.1
|
||||
vgDestroyImage@Base 7.8.1
|
||||
vgDestroyPaint@Base 7.8.1
|
||||
vgDestroyPath@Base 7.8.1
|
||||
vgDrawImage@Base 7.8.1
|
||||
vgDrawPath@Base 7.8.1
|
||||
vgFinish@Base 7.8.1
|
||||
vgFlush@Base 7.8.1
|
||||
vgGaussianBlur@Base 7.8.1
|
||||
vgGetColor@Base 7.8.1
|
||||
vgGetError@Base 7.8.1
|
||||
vgGetImageSubData@Base 7.8.1
|
||||
vgGetMatrix@Base 7.8.1
|
||||
vgGetPaint@Base 7.8.1
|
||||
vgGetParameterVectorSize@Base 7.8.1
|
||||
vgGetParameterf@Base 7.8.1
|
||||
vgGetParameterfv@Base 7.8.1
|
||||
vgGetParameteri@Base 7.8.1
|
||||
vgGetParameteriv@Base 7.8.1
|
||||
vgGetParent@Base 7.8.1
|
||||
vgGetPathCapabilities@Base 7.8.1
|
||||
vgGetPixels@Base 7.8.1
|
||||
vgGetString@Base 7.8.1
|
||||
vgGetVectorSize@Base 7.8.1
|
||||
vgGetf@Base 7.8.1
|
||||
vgGetfv@Base 7.8.1
|
||||
vgGeti@Base 7.8.1
|
||||
vgGetiv@Base 7.8.1
|
||||
vgHardwareQuery@Base 7.8.1
|
||||
vgImageSubData@Base 7.8.1
|
||||
vgInterpolatePath@Base 7.8.1
|
||||
vgLoadIdentity@Base 7.8.1
|
||||
vgLoadMatrix@Base 7.8.1
|
||||
vgLookup@Base 7.8.1
|
||||
vgLookupSingle@Base 7.8.1
|
||||
vgMask@Base 7.8.1
|
||||
vgModifyPathCoords@Base 7.8.1
|
||||
vgMultMatrix@Base 7.8.1
|
||||
vgPaintPattern@Base 7.8.1
|
||||
vgPathBounds@Base 7.8.1
|
||||
vgPathLength@Base 7.8.1
|
||||
vgPathTransformedBounds@Base 7.8.1
|
||||
vgPointAlongPath@Base 7.8.1
|
||||
vgReadPixels@Base 7.8.1
|
||||
vgRemovePathCapabilities@Base 7.8.1
|
||||
vgRotate@Base 7.8.1
|
||||
vgScale@Base 7.8.1
|
||||
vgSeparableConvolve@Base 7.8.1
|
||||
vgSetColor@Base 7.8.1
|
||||
vgSetPaint@Base 7.8.1
|
||||
vgSetParameterf@Base 7.8.1
|
||||
vgSetParameterfv@Base 7.8.1
|
||||
vgSetParameteri@Base 7.8.1
|
||||
vgSetParameteriv@Base 7.8.1
|
||||
vgSetPixels@Base 7.8.1
|
||||
vgSetf@Base 7.8.1
|
||||
vgSetfv@Base 7.8.1
|
||||
vgSeti@Base 7.8.1
|
||||
vgSetiv@Base 7.8.1
|
||||
vgShear@Base 7.8.1
|
||||
vgTransformPath@Base 7.8.1
|
||||
vgTranslate@Base 7.8.1
|
||||
vgWritePixels@Base 7.8.1
|
||||
vguArc@Base 7.8.1
|
||||
vguComputeWarpQuadToQuad@Base 7.8.1
|
||||
vguComputeWarpQuadToSquare@Base 7.8.1
|
||||
vguComputeWarpSquareToQuad@Base 7.8.1
|
||||
vguEllipse@Base 7.8.1
|
||||
vguLine@Base 7.8.1
|
||||
vguPolygon@Base 7.8.1
|
||||
vguRect@Base 7.8.1
|
||||
vguRoundRect@Base 7.8.1
|
91
debian/rules
vendored
91
debian/rules
vendored
@@ -21,7 +21,7 @@ DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
|
||||
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
|
||||
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
|
||||
DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)
|
||||
DEB_BUILD_DIR ?= $(CURDIR)/build
|
||||
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
|
||||
confflags += --build=$(DEB_HOST_GNU_TYPE)
|
||||
@@ -49,67 +49,93 @@ BUILD_STAMPS = $(addprefix $(STAMP)-build-, $(CONFIGS))
|
||||
QUILT_STAMPFN = $(STAMP_DIR)/patch
|
||||
include /usr/share/quilt/quilt.make
|
||||
|
||||
# temporary until we figure out what to build
|
||||
confflags += --disable-gallium
|
||||
|
||||
confflags-common = \
|
||||
--disable-egl \
|
||||
--disable-glu \
|
||||
--disable-glut \
|
||||
--disable-glw \
|
||||
CFLAGS="$(CFLAGS)"
|
||||
|
||||
DRI_DRIVERS = swrast
|
||||
GALLIUM_DRIVERS = --enable-gallium-swrast
|
||||
# Mesa 7.8 doesn't build a gallium swrast DRI driver
|
||||
# This is built in git, and will be built in 7.9
|
||||
HAVE_GALLIUM_DRI_DRIVERS = no
|
||||
HAVE_KMS = no
|
||||
EGL_DISPLAYS = x11
|
||||
|
||||
# hurd doesn't do direct rendering
|
||||
ifeq ($(DEB_HOST_ARCH_OS), hurd)
|
||||
DIRECT_RENDERING = --disable-driglx-direct
|
||||
else
|
||||
DIRECT_RENDERING = --enable-driglx-direct
|
||||
|
||||
ifeq ($(DEB_HOST_ARCH_OS), linux)
|
||||
# Gallium drivers require libdrm-{nouveau,radeon}, only available on Linux
|
||||
GALLIUM_DRIVERS += --enable-gallium-nouveau --enable-gallium-radeon
|
||||
HAVE_GALLIUM_DRI_DRIVERS = yes
|
||||
# Although the KMS egl drivers will probably build on kfreebsd & hurd
|
||||
# only linux actually has KMS drivers implemented at this point.
|
||||
HAVE_KMS = yes
|
||||
endif
|
||||
|
||||
ifeq ($(DEB_HOST_ARCH), lpia)
|
||||
DRI_DRIVERS += i915 i965
|
||||
GALLIUM_DRIVERS += --enable-gallium-intel
|
||||
else ifneq ($(DEB_HOST_ARCH), s390)
|
||||
DRI_DRIVERS += mach64 mga r128 r200 r300 r600 radeon savage tdfx
|
||||
ifeq ($(DEB_HOST_GNU_CPU), i486)
|
||||
ifeq ($(DEB_HOST_ARCH_CPU), i386)
|
||||
DRI_DRIVERS += i810 i915 i965 sis unichrome
|
||||
else ifeq ($(DEB_HOST_GNU_CPU), x86_64)
|
||||
GALLIUM_DRIVERS += --enable-gallium-intel
|
||||
else ifeq ($(DEB_HOST_ARCH_CPU), amd64)
|
||||
DRI_DRIVERS += i915 i965 sis unichrome
|
||||
else ifeq ($(DEB_HOST_ARCH), sparc)
|
||||
DRI_DRIVERS += ffb
|
||||
else ifeq ($(DEB_HOST_ARCH), sparc64)
|
||||
DRI_DRIVERS += ffb
|
||||
GALLIUM_DRIVERS += --enable-gallium-intel
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_KMS), yes)
|
||||
EGL_DISPLAYS += kms
|
||||
endif
|
||||
|
||||
confflags-dri = \
|
||||
--with-driver=dri \
|
||||
--with-dri-drivers="$(DRI_DRIVERS)" \
|
||||
--with-demos=xdemos \
|
||||
--libdir=/usr/lib/glx \
|
||||
--with-dri-driverdir=/usr/lib/dri \
|
||||
--with-egl-displays="$(EGL_DISPLAYS)" \
|
||||
--enable-glx-tls \
|
||||
$(GALLIUM_DRIVERS) \
|
||||
--with-state-trackers=egl,es,glx,dri,vega \
|
||||
$(DIRECT_RENDERING) \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--with-demos= \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa-static = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--enable-static \
|
||||
--with-demos= \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa16 = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--with-osmesa-bits=16 \
|
||||
--with-demos= \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa16-static = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--with-osmesa-bits=16 \
|
||||
--enable-static \
|
||||
@@ -117,12 +143,16 @@ confflags-osmesa16-static = \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa32 = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--with-osmesa-bits=32 \
|
||||
--with-demos= \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-osmesa32-static = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=osmesa \
|
||||
--with-osmesa-bits=32 \
|
||||
--enable-static \
|
||||
@@ -130,6 +160,8 @@ confflags-osmesa32-static = \
|
||||
$(confflags-common)
|
||||
|
||||
confflags-swx11+glu = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=xlib \
|
||||
--disable-gl-osmesa \
|
||||
--with-demos= \
|
||||
@@ -139,6 +171,8 @@ confflags-swx11+glu = \
|
||||
CFLAGS="$(CFLAGS)"
|
||||
|
||||
confflags-swx11+glu-static = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=xlib \
|
||||
--disable-gl-osmesa \
|
||||
--enable-static \
|
||||
@@ -149,6 +183,8 @@ confflags-swx11+glu-static = \
|
||||
CFLAGS="$(CFLAGS)"
|
||||
|
||||
confflags-swx11+glu-i386-i686 = \
|
||||
--disable-egl \
|
||||
--disable-gallium \
|
||||
--with-driver=xlib \
|
||||
--disable-gl-osmesa \
|
||||
--with-demos= \
|
||||
@@ -192,7 +228,7 @@ install: build
|
||||
# Add here commands to install the package into debian/tmp
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
set -e; for config in $(CONFIGS); do \
|
||||
$(MAKE) -C $(DEB_BUILD_DIR)/$$config DESTDIR=$(CURDIR)/debian/tmp install; \
|
||||
@@ -222,18 +258,43 @@ binary-indep: install
|
||||
binary-arch: install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs -s
|
||||
dh_installchangelogs -s -XChangeLog
|
||||
dh_installchangelogs -pmesa-common-dev ChangeLog
|
||||
dh_installdocs -s
|
||||
dh_installexamples -s
|
||||
dh_install -s --sourcedir=debian/tmp --list-missing
|
||||
# Classic DRI and Gallium DRI are mixed up together here
|
||||
# Remove the whole tree to avoid false-positives in --list-missing, and
|
||||
# install the right files manually.
|
||||
rm -r debian/tmp/usr/lib/dri
|
||||
# Radeon searches for r{200,300,600}_dri only, but the gallium driver
|
||||
# is (at the moment) radeong_dri. Rename it to r300_dri, as it
|
||||
# fails to support r600.
|
||||
mv build/dri/glx/gallium/radeong_dri.so \
|
||||
build/dri/glx/gallium/r300_dri.so
|
||||
# Intel i965 Gallium appears to do nothing more than generate GPU
|
||||
# lockups. Kill it with fire. i915 is apparently useful.
|
||||
-rm build/dri/glx/gallium/i965_dri.so
|
||||
-rm debian/tmp/usr/lib/glx/egl/egl_*_i965.so
|
||||
|
||||
dh_install -s --list-missing
|
||||
dh_installman -s
|
||||
dh_lintian -s
|
||||
dh_link -s
|
||||
dh_strip -plibgl1-mesa-swx11 --dbg-package=libgl1-mesa-swx11-dbg
|
||||
dh_strip -plibgl1-mesa-glx --dbg-package=libgl1-mesa-glx-dbg
|
||||
dh_strip -plibgl1-mesa-dri --dbg-package=libgl1-mesa-dri-dbg
|
||||
dh_strip -s
|
||||
ifeq ($(HAVE_GALLIUM_DRI_DRIVERS), yes)
|
||||
dh_strip -plibgl1-mesa-dri-experimental --dbg-package=libgl1-mesa-dri-experimental-dbg
|
||||
endif
|
||||
dh_strip -plibopenvg1-mesa --dbg-package=libopenvg1-mesa-dbg
|
||||
dh_strip -plibegl1-mesa --dbg-package=libegl1-mesa-dbg
|
||||
dh_strip -plibgles1-mesa --dbg-package=libgles1-mesa-dbg
|
||||
dh_strip -plibgles2-mesa --dbg-package=libgles2-mesa-dbg
|
||||
dh_strip -plibegl1-mesa-drivers-x11 --dbg-package=libegl1-mesa-drivers-x11-dbg
|
||||
ifeq ($(HAVE_KMS), yes)
|
||||
dh_strip -plibegl1-mesa-drivers-kms --dbg-package=libegl1-mesa-drivers-kms-dbg
|
||||
endif
|
||||
dh_strip -s --remaining-packages
|
||||
dh_compress -s
|
||||
dh_fixperms -s
|
||||
dh_makeshlibs -s
|
||||
|
12
debian/vg.pc
vendored
Normal file
12
debian/vg.pc
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=/usr/lib
|
||||
includedir=/usr/include
|
||||
|
||||
Name: vg
|
||||
Description: Mesa OpenVG 1.0 library
|
||||
Requires.private:
|
||||
Version: 7.8.1
|
||||
Libs: -L${libdir} -lOpenVG
|
||||
Libs.private:
|
||||
Cflags: -I${includedir}
|
686
include/VG/openvg.h
Normal file
686
include/VG/openvg.h
Normal file
@@ -0,0 +1,686 @@
|
||||
/* $Revision: 6822 $ on $Date:: 2008-10-30 05:14:19 -0400 #$ */
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*
|
||||
* OpenVG 1.0.1 Reference Implementation
|
||||
* -------------------------------------
|
||||
*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and /or associated documentation files
|
||||
* (the "Materials "), to deal in the Materials without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Materials,
|
||||
* and to permit persons to whom the Materials are furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
|
||||
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*
|
||||
*//**
|
||||
* \file
|
||||
* \brief OpenVG 1.0.1 API.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _OPENVG_H
|
||||
#define _OPENVG_H
|
||||
|
||||
#include <VG/vgplatform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OPENVG_VERSION_1_0 1
|
||||
#define OPENVG_VERSION_1_0_1 1
|
||||
|
||||
#ifndef VG_MAXSHORT
|
||||
#define VG_MAXSHORT 0x7FFF
|
||||
#endif
|
||||
|
||||
#ifndef VG_MAXINT
|
||||
#define VG_MAXINT 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
#ifndef VG_MAX_ENUM
|
||||
#define VG_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
typedef long VGHandle;
|
||||
|
||||
typedef VGHandle VGPath;
|
||||
typedef VGHandle VGImage;
|
||||
typedef VGHandle VGPaint;
|
||||
|
||||
#define VG_INVALID_HANDLE ((VGHandle)0)
|
||||
|
||||
typedef enum {
|
||||
VG_FALSE = 0,
|
||||
VG_TRUE = 1,
|
||||
|
||||
VG_BOOLEAN_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGboolean;
|
||||
|
||||
typedef enum {
|
||||
VG_NO_ERROR = 0,
|
||||
VG_BAD_HANDLE_ERROR = 0x1000,
|
||||
VG_ILLEGAL_ARGUMENT_ERROR = 0x1001,
|
||||
VG_OUT_OF_MEMORY_ERROR = 0x1002,
|
||||
VG_PATH_CAPABILITY_ERROR = 0x1003,
|
||||
VG_UNSUPPORTED_IMAGE_FORMAT_ERROR = 0x1004,
|
||||
VG_UNSUPPORTED_PATH_FORMAT_ERROR = 0x1005,
|
||||
VG_IMAGE_IN_USE_ERROR = 0x1006,
|
||||
VG_NO_CONTEXT_ERROR = 0x1007,
|
||||
|
||||
VG_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGErrorCode;
|
||||
|
||||
typedef enum {
|
||||
/* Mode settings */
|
||||
VG_MATRIX_MODE = 0x1100,
|
||||
VG_FILL_RULE = 0x1101,
|
||||
VG_IMAGE_QUALITY = 0x1102,
|
||||
VG_RENDERING_QUALITY = 0x1103,
|
||||
VG_BLEND_MODE = 0x1104,
|
||||
VG_IMAGE_MODE = 0x1105,
|
||||
|
||||
/* Scissoring rectangles */
|
||||
VG_SCISSOR_RECTS = 0x1106,
|
||||
|
||||
/* Stroke parameters */
|
||||
VG_STROKE_LINE_WIDTH = 0x1110,
|
||||
VG_STROKE_CAP_STYLE = 0x1111,
|
||||
VG_STROKE_JOIN_STYLE = 0x1112,
|
||||
VG_STROKE_MITER_LIMIT = 0x1113,
|
||||
VG_STROKE_DASH_PATTERN = 0x1114,
|
||||
VG_STROKE_DASH_PHASE = 0x1115,
|
||||
VG_STROKE_DASH_PHASE_RESET = 0x1116,
|
||||
|
||||
/* Edge fill color for VG_TILE_FILL tiling mode */
|
||||
VG_TILE_FILL_COLOR = 0x1120,
|
||||
|
||||
/* Color for vgClear */
|
||||
VG_CLEAR_COLOR = 0x1121,
|
||||
|
||||
/* Enable/disable alpha masking and scissoring */
|
||||
VG_MASKING = 0x1130,
|
||||
VG_SCISSORING = 0x1131,
|
||||
|
||||
/* Pixel layout information */
|
||||
VG_PIXEL_LAYOUT = 0x1140,
|
||||
VG_SCREEN_LAYOUT = 0x1141,
|
||||
|
||||
/* Source format selection for image filters */
|
||||
VG_FILTER_FORMAT_LINEAR = 0x1150,
|
||||
VG_FILTER_FORMAT_PREMULTIPLIED = 0x1151,
|
||||
|
||||
/* Destination write enable mask for image filters */
|
||||
VG_FILTER_CHANNEL_MASK = 0x1152,
|
||||
|
||||
/* Implementation limits (read-only) */
|
||||
VG_MAX_SCISSOR_RECTS = 0x1160,
|
||||
VG_MAX_DASH_COUNT = 0x1161,
|
||||
VG_MAX_KERNEL_SIZE = 0x1162,
|
||||
VG_MAX_SEPARABLE_KERNEL_SIZE = 0x1163,
|
||||
VG_MAX_COLOR_RAMP_STOPS = 0x1164,
|
||||
VG_MAX_IMAGE_WIDTH = 0x1165,
|
||||
VG_MAX_IMAGE_HEIGHT = 0x1166,
|
||||
VG_MAX_IMAGE_PIXELS = 0x1167,
|
||||
VG_MAX_IMAGE_BYTES = 0x1168,
|
||||
VG_MAX_FLOAT = 0x1169,
|
||||
VG_MAX_GAUSSIAN_STD_DEVIATION = 0x116A,
|
||||
|
||||
VG_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGParamType;
|
||||
|
||||
typedef enum {
|
||||
VG_RENDERING_QUALITY_NONANTIALIASED = 0x1200,
|
||||
VG_RENDERING_QUALITY_FASTER = 0x1201,
|
||||
VG_RENDERING_QUALITY_BETTER = 0x1202, /* Default */
|
||||
|
||||
VG_RENDERING_QUALITY_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGRenderingQuality;
|
||||
|
||||
typedef enum {
|
||||
VG_PIXEL_LAYOUT_UNKNOWN = 0x1300,
|
||||
VG_PIXEL_LAYOUT_RGB_VERTICAL = 0x1301,
|
||||
VG_PIXEL_LAYOUT_BGR_VERTICAL = 0x1302,
|
||||
VG_PIXEL_LAYOUT_RGB_HORIZONTAL = 0x1303,
|
||||
VG_PIXEL_LAYOUT_BGR_HORIZONTAL = 0x1304,
|
||||
|
||||
VG_PIXEL_LAYOUT_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPixelLayout;
|
||||
|
||||
typedef enum {
|
||||
VG_MATRIX_PATH_USER_TO_SURFACE = 0x1400,
|
||||
VG_MATRIX_IMAGE_USER_TO_SURFACE = 0x1401,
|
||||
VG_MATRIX_FILL_PAINT_TO_USER = 0x1402,
|
||||
VG_MATRIX_STROKE_PAINT_TO_USER = 0x1403,
|
||||
|
||||
VG_MATRIX_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGMatrixMode;
|
||||
|
||||
typedef enum {
|
||||
VG_CLEAR_MASK = 0x1500,
|
||||
VG_FILL_MASK = 0x1501,
|
||||
VG_SET_MASK = 0x1502,
|
||||
VG_UNION_MASK = 0x1503,
|
||||
VG_INTERSECT_MASK = 0x1504,
|
||||
VG_SUBTRACT_MASK = 0x1505,
|
||||
|
||||
VG_MASK_OPERATION_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGMaskOperation;
|
||||
|
||||
#define VG_PATH_FORMAT_STANDARD 0
|
||||
|
||||
typedef enum {
|
||||
VG_PATH_DATATYPE_S_8 = 0,
|
||||
VG_PATH_DATATYPE_S_16 = 1,
|
||||
VG_PATH_DATATYPE_S_32 = 2,
|
||||
VG_PATH_DATATYPE_F = 3,
|
||||
|
||||
VG_PATH_DATATYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathDatatype;
|
||||
|
||||
typedef enum {
|
||||
VG_ABSOLUTE = 0,
|
||||
VG_RELATIVE = 1,
|
||||
|
||||
VG_PATH_ABS_REL_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathAbsRel;
|
||||
|
||||
typedef enum {
|
||||
VG_CLOSE_PATH = ( 0 << 1),
|
||||
VG_MOVE_TO = ( 1 << 1),
|
||||
VG_LINE_TO = ( 2 << 1),
|
||||
VG_HLINE_TO = ( 3 << 1),
|
||||
VG_VLINE_TO = ( 4 << 1),
|
||||
VG_QUAD_TO = ( 5 << 1),
|
||||
VG_CUBIC_TO = ( 6 << 1),
|
||||
VG_SQUAD_TO = ( 7 << 1),
|
||||
VG_SCUBIC_TO = ( 8 << 1),
|
||||
VG_SCCWARC_TO = ( 9 << 1),
|
||||
VG_SCWARC_TO = (10 << 1),
|
||||
VG_LCCWARC_TO = (11 << 1),
|
||||
VG_LCWARC_TO = (12 << 1),
|
||||
|
||||
VG_PATH_SEGMENT_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathSegment;
|
||||
|
||||
typedef enum {
|
||||
VG_MOVE_TO_ABS = VG_MOVE_TO | VG_ABSOLUTE,
|
||||
VG_MOVE_TO_REL = VG_MOVE_TO | VG_RELATIVE,
|
||||
VG_LINE_TO_ABS = VG_LINE_TO | VG_ABSOLUTE,
|
||||
VG_LINE_TO_REL = VG_LINE_TO | VG_RELATIVE,
|
||||
VG_HLINE_TO_ABS = VG_HLINE_TO | VG_ABSOLUTE,
|
||||
VG_HLINE_TO_REL = VG_HLINE_TO | VG_RELATIVE,
|
||||
VG_VLINE_TO_ABS = VG_VLINE_TO | VG_ABSOLUTE,
|
||||
VG_VLINE_TO_REL = VG_VLINE_TO | VG_RELATIVE,
|
||||
VG_QUAD_TO_ABS = VG_QUAD_TO | VG_ABSOLUTE,
|
||||
VG_QUAD_TO_REL = VG_QUAD_TO | VG_RELATIVE,
|
||||
VG_CUBIC_TO_ABS = VG_CUBIC_TO | VG_ABSOLUTE,
|
||||
VG_CUBIC_TO_REL = VG_CUBIC_TO | VG_RELATIVE,
|
||||
VG_SQUAD_TO_ABS = VG_SQUAD_TO | VG_ABSOLUTE,
|
||||
VG_SQUAD_TO_REL = VG_SQUAD_TO | VG_RELATIVE,
|
||||
VG_SCUBIC_TO_ABS = VG_SCUBIC_TO | VG_ABSOLUTE,
|
||||
VG_SCUBIC_TO_REL = VG_SCUBIC_TO | VG_RELATIVE,
|
||||
VG_SCCWARC_TO_ABS = VG_SCCWARC_TO | VG_ABSOLUTE,
|
||||
VG_SCCWARC_TO_REL = VG_SCCWARC_TO | VG_RELATIVE,
|
||||
VG_SCWARC_TO_ABS = VG_SCWARC_TO | VG_ABSOLUTE,
|
||||
VG_SCWARC_TO_REL = VG_SCWARC_TO | VG_RELATIVE,
|
||||
VG_LCCWARC_TO_ABS = VG_LCCWARC_TO | VG_ABSOLUTE,
|
||||
VG_LCCWARC_TO_REL = VG_LCCWARC_TO | VG_RELATIVE,
|
||||
VG_LCWARC_TO_ABS = VG_LCWARC_TO | VG_ABSOLUTE,
|
||||
VG_LCWARC_TO_REL = VG_LCWARC_TO | VG_RELATIVE,
|
||||
|
||||
VG_PATH_COMMAND_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathCommand;
|
||||
|
||||
typedef enum {
|
||||
VG_PATH_CAPABILITY_APPEND_FROM = (1 << 0),
|
||||
VG_PATH_CAPABILITY_APPEND_TO = (1 << 1),
|
||||
VG_PATH_CAPABILITY_MODIFY = (1 << 2),
|
||||
VG_PATH_CAPABILITY_TRANSFORM_FROM = (1 << 3),
|
||||
VG_PATH_CAPABILITY_TRANSFORM_TO = (1 << 4),
|
||||
VG_PATH_CAPABILITY_INTERPOLATE_FROM = (1 << 5),
|
||||
VG_PATH_CAPABILITY_INTERPOLATE_TO = (1 << 6),
|
||||
VG_PATH_CAPABILITY_PATH_LENGTH = (1 << 7),
|
||||
VG_PATH_CAPABILITY_POINT_ALONG_PATH = (1 << 8),
|
||||
VG_PATH_CAPABILITY_TANGENT_ALONG_PATH = (1 << 9),
|
||||
VG_PATH_CAPABILITY_PATH_BOUNDS = (1 << 10),
|
||||
VG_PATH_CAPABILITY_PATH_TRANSFORMED_BOUNDS = (1 << 11),
|
||||
VG_PATH_CAPABILITY_ALL = (1 << 12) - 1,
|
||||
|
||||
VG_PATH_CAPABILITIES_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathCapabilities;
|
||||
|
||||
typedef enum {
|
||||
VG_PATH_FORMAT = 0x1600,
|
||||
VG_PATH_DATATYPE = 0x1601,
|
||||
VG_PATH_SCALE = 0x1602,
|
||||
VG_PATH_BIAS = 0x1603,
|
||||
VG_PATH_NUM_SEGMENTS = 0x1604,
|
||||
VG_PATH_NUM_COORDS = 0x1605,
|
||||
|
||||
VG_PATH_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathParamType;
|
||||
|
||||
typedef enum {
|
||||
VG_CAP_BUTT = 0x1700,
|
||||
VG_CAP_ROUND = 0x1701,
|
||||
VG_CAP_SQUARE = 0x1702,
|
||||
|
||||
VG_CAP_STYLE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGCapStyle;
|
||||
|
||||
typedef enum {
|
||||
VG_JOIN_MITER = 0x1800,
|
||||
VG_JOIN_ROUND = 0x1801,
|
||||
VG_JOIN_BEVEL = 0x1802,
|
||||
|
||||
VG_JOIN_STYLE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGJoinStyle;
|
||||
|
||||
typedef enum {
|
||||
VG_EVEN_ODD = 0x1900,
|
||||
VG_NON_ZERO = 0x1901,
|
||||
|
||||
VG_FILL_RULE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGFillRule;
|
||||
|
||||
typedef enum {
|
||||
VG_STROKE_PATH = (1 << 0),
|
||||
VG_FILL_PATH = (1 << 1),
|
||||
|
||||
VG_PAINT_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPaintMode;
|
||||
|
||||
typedef enum {
|
||||
/* Color paint parameters */
|
||||
VG_PAINT_TYPE = 0x1A00,
|
||||
VG_PAINT_COLOR = 0x1A01,
|
||||
VG_PAINT_COLOR_RAMP_SPREAD_MODE = 0x1A02,
|
||||
VG_PAINT_COLOR_RAMP_PREMULTIPLIED = 0x1A07,
|
||||
VG_PAINT_COLOR_RAMP_STOPS = 0x1A03,
|
||||
|
||||
/* Linear gradient paint parameters */
|
||||
VG_PAINT_LINEAR_GRADIENT = 0x1A04,
|
||||
|
||||
/* Radial gradient paint parameters */
|
||||
VG_PAINT_RADIAL_GRADIENT = 0x1A05,
|
||||
|
||||
/* Pattern paint parameters */
|
||||
VG_PAINT_PATTERN_TILING_MODE = 0x1A06,
|
||||
|
||||
VG_PAINT_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPaintParamType;
|
||||
|
||||
typedef enum {
|
||||
VG_PAINT_TYPE_COLOR = 0x1B00,
|
||||
VG_PAINT_TYPE_LINEAR_GRADIENT = 0x1B01,
|
||||
VG_PAINT_TYPE_RADIAL_GRADIENT = 0x1B02,
|
||||
VG_PAINT_TYPE_PATTERN = 0x1B03,
|
||||
|
||||
VG_PAINT_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPaintType;
|
||||
|
||||
typedef enum {
|
||||
VG_COLOR_RAMP_SPREAD_PAD = 0x1C00,
|
||||
VG_COLOR_RAMP_SPREAD_REPEAT = 0x1C01,
|
||||
VG_COLOR_RAMP_SPREAD_REFLECT = 0x1C02,
|
||||
|
||||
VG_COLOR_RAMP_SPREAD_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGColorRampSpreadMode;
|
||||
|
||||
typedef enum {
|
||||
VG_TILE_FILL = 0x1D00,
|
||||
VG_TILE_PAD = 0x1D01,
|
||||
VG_TILE_REPEAT = 0x1D02,
|
||||
VG_TILE_REFLECT = 0x1D03,
|
||||
|
||||
VG_TILING_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGTilingMode;
|
||||
|
||||
typedef enum {
|
||||
/* RGB{A,X} channel ordering */
|
||||
VG_sRGBX_8888 = 0,
|
||||
VG_sRGBA_8888 = 1,
|
||||
VG_sRGBA_8888_PRE = 2,
|
||||
VG_sRGB_565 = 3,
|
||||
VG_sRGBA_5551 = 4,
|
||||
VG_sRGBA_4444 = 5,
|
||||
VG_sL_8 = 6,
|
||||
VG_lRGBX_8888 = 7,
|
||||
VG_lRGBA_8888 = 8,
|
||||
VG_lRGBA_8888_PRE = 9,
|
||||
VG_lL_8 = 10,
|
||||
VG_A_8 = 11,
|
||||
VG_BW_1 = 12,
|
||||
|
||||
/* {A,X}RGB channel ordering */
|
||||
VG_sXRGB_8888 = 0 | (1 << 6),
|
||||
VG_sARGB_8888 = 1 | (1 << 6),
|
||||
VG_sARGB_8888_PRE = 2 | (1 << 6),
|
||||
VG_sARGB_1555 = 4 | (1 << 6),
|
||||
VG_sARGB_4444 = 5 | (1 << 6),
|
||||
VG_lXRGB_8888 = 7 | (1 << 6),
|
||||
VG_lARGB_8888 = 8 | (1 << 6),
|
||||
VG_lARGB_8888_PRE = 9 | (1 << 6),
|
||||
|
||||
/* BGR{A,X} channel ordering */
|
||||
VG_sBGRX_8888 = 0 | (1 << 7),
|
||||
VG_sBGRA_8888 = 1 | (1 << 7),
|
||||
VG_sBGRA_8888_PRE = 2 | (1 << 7),
|
||||
VG_sBGR_565 = 3 | (1 << 7),
|
||||
VG_sBGRA_5551 = 4 | (1 << 7),
|
||||
VG_sBGRA_4444 = 5 | (1 << 7),
|
||||
VG_lBGRX_8888 = 7 | (1 << 7),
|
||||
VG_lBGRA_8888 = 8 | (1 << 7),
|
||||
VG_lBGRA_8888_PRE = 9 | (1 << 7),
|
||||
|
||||
/* {A,X}BGR channel ordering */
|
||||
VG_sXBGR_8888 = 0 | (1 << 6) | (1 << 7),
|
||||
VG_sABGR_8888 = 1 | (1 << 6) | (1 << 7),
|
||||
VG_sABGR_8888_PRE = 2 | (1 << 6) | (1 << 7),
|
||||
VG_sABGR_1555 = 4 | (1 << 6) | (1 << 7),
|
||||
VG_sABGR_4444 = 5 | (1 << 6) | (1 << 7),
|
||||
VG_lXBGR_8888 = 7 | (1 << 6) | (1 << 7),
|
||||
VG_lABGR_8888 = 8 | (1 << 6) | (1 << 7),
|
||||
VG_lABGR_8888_PRE = 9 | (1 << 6) | (1 << 7),
|
||||
|
||||
VG_IMAGE_FORMAT_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageFormat;
|
||||
|
||||
typedef enum {
|
||||
VG_IMAGE_QUALITY_NONANTIALIASED = (1 << 0),
|
||||
VG_IMAGE_QUALITY_FASTER = (1 << 1),
|
||||
VG_IMAGE_QUALITY_BETTER = (1 << 2),
|
||||
|
||||
VG_IMAGE_QUALITY_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageQuality;
|
||||
|
||||
typedef enum {
|
||||
VG_IMAGE_FORMAT = 0x1E00,
|
||||
VG_IMAGE_WIDTH = 0x1E01,
|
||||
VG_IMAGE_HEIGHT = 0x1E02,
|
||||
|
||||
VG_IMAGE_PARAM_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageParamType;
|
||||
|
||||
typedef enum {
|
||||
VG_DRAW_IMAGE_NORMAL = 0x1F00,
|
||||
VG_DRAW_IMAGE_MULTIPLY = 0x1F01,
|
||||
VG_DRAW_IMAGE_STENCIL = 0x1F02,
|
||||
|
||||
VG_IMAGE_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageMode;
|
||||
|
||||
typedef enum {
|
||||
VG_RED = (1 << 3),
|
||||
VG_GREEN = (1 << 2),
|
||||
VG_BLUE = (1 << 1),
|
||||
VG_ALPHA = (1 << 0),
|
||||
|
||||
VG_IMAGE_CHANNEL_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageChannel;
|
||||
|
||||
typedef enum {
|
||||
VG_BLEND_SRC = 0x2000,
|
||||
VG_BLEND_SRC_OVER = 0x2001,
|
||||
VG_BLEND_DST_OVER = 0x2002,
|
||||
VG_BLEND_SRC_IN = 0x2003,
|
||||
VG_BLEND_DST_IN = 0x2004,
|
||||
VG_BLEND_MULTIPLY = 0x2005,
|
||||
VG_BLEND_SCREEN = 0x2006,
|
||||
VG_BLEND_DARKEN = 0x2007,
|
||||
VG_BLEND_LIGHTEN = 0x2008,
|
||||
VG_BLEND_ADDITIVE = 0x2009,
|
||||
|
||||
VG_BLEND_MODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGBlendMode;
|
||||
|
||||
typedef enum {
|
||||
VG_IMAGE_FORMAT_QUERY = 0x2100,
|
||||
VG_PATH_DATATYPE_QUERY = 0x2101,
|
||||
|
||||
VG_HARDWARE_QUERY_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGHardwareQueryType;
|
||||
|
||||
typedef enum {
|
||||
VG_HARDWARE_ACCELERATED = 0x2200,
|
||||
VG_HARDWARE_UNACCELERATED = 0x2201,
|
||||
|
||||
VG_HARDWARE_QUERY_RESULT_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGHardwareQueryResult;
|
||||
|
||||
typedef enum {
|
||||
VG_VENDOR = 0x2300,
|
||||
VG_RENDERER = 0x2301,
|
||||
VG_VERSION = 0x2302,
|
||||
VG_EXTENSIONS = 0x2303,
|
||||
|
||||
VG_STRING_ID_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGStringID;
|
||||
|
||||
/* Function Prototypes */
|
||||
|
||||
#ifndef VG_API_CALL
|
||||
# error VG_API_CALL must be defined
|
||||
#endif
|
||||
|
||||
#ifndef VG_API_ENTRY
|
||||
# error VG_API_ENTRY must be defined
|
||||
#endif
|
||||
|
||||
#ifndef VG_API_EXIT
|
||||
# error VG_API_EXIT must be defined
|
||||
#endif
|
||||
|
||||
VG_API_CALL VGErrorCode VG_API_ENTRY vgGetError(void) VG_API_EXIT;
|
||||
|
||||
VG_API_CALL void VG_API_ENTRY vgFlush(void) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgFinish(void) VG_API_EXIT;
|
||||
|
||||
/* Getters and Setters */
|
||||
VG_API_CALL void VG_API_ENTRY vgSetf (VGParamType type, VGfloat value) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSeti (VGParamType type, VGint value) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetfv(VGParamType type, VGint count,
|
||||
const VGfloat * values) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetiv(VGParamType type, VGint count,
|
||||
const VGint * values) VG_API_EXIT;
|
||||
|
||||
VG_API_CALL VGfloat VG_API_ENTRY vgGetf(VGParamType type) VG_API_EXIT;
|
||||
VG_API_CALL VGint VG_API_ENTRY vgGeti(VGParamType type) VG_API_EXIT;
|
||||
VG_API_CALL VGint VG_API_ENTRY vgGetVectorSize(VGParamType type) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetfv(VGParamType type, VGint count, VGfloat * values) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetiv(VGParamType type, VGint count, VGint * values) VG_API_EXIT;
|
||||
|
||||
VG_API_CALL void VG_API_ENTRY vgSetParameterf(VGHandle object,
|
||||
VGint paramType,
|
||||
VGfloat value) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetParameteri(VGHandle object,
|
||||
VGint paramType,
|
||||
VGint value) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetParameterfv(VGHandle object,
|
||||
VGint paramType,
|
||||
VGint count, const VGfloat * values) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetParameteriv(VGHandle object,
|
||||
VGint paramType,
|
||||
VGint count, const VGint * values) VG_API_EXIT;
|
||||
|
||||
VG_API_CALL VGfloat VG_API_ENTRY vgGetParameterf(VGHandle object,
|
||||
VGint paramType) VG_API_EXIT;
|
||||
VG_API_CALL VGint VG_API_ENTRY vgGetParameteri(VGHandle object,
|
||||
VGint paramType);
|
||||
VG_API_CALL VGint VG_API_ENTRY vgGetParameterVectorSize(VGHandle object,
|
||||
VGint paramType) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetParameterfv(VGHandle object,
|
||||
VGint paramType,
|
||||
VGint count, VGfloat * values) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetParameteriv(VGHandle object,
|
||||
VGint paramType,
|
||||
VGint count, VGint * values) VG_API_EXIT;
|
||||
|
||||
/* Matrix Manipulation */
|
||||
VG_API_CALL void VG_API_ENTRY vgLoadIdentity(void) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgLoadMatrix(const VGfloat * m) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetMatrix(VGfloat * m) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgMultMatrix(const VGfloat * m) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgTranslate(VGfloat tx, VGfloat ty) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgScale(VGfloat sx, VGfloat sy) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgShear(VGfloat shx, VGfloat shy) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgRotate(VGfloat angle) VG_API_EXIT;
|
||||
|
||||
/* Masking and Clearing */
|
||||
VG_API_CALL void VG_API_ENTRY vgMask(VGImage mask, VGMaskOperation operation,
|
||||
VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgClear(VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
|
||||
|
||||
/* Paths */
|
||||
VG_API_CALL VGPath VG_API_ENTRY vgCreatePath(VGint pathFormat,
|
||||
VGPathDatatype datatype,
|
||||
VGfloat scale, VGfloat bias,
|
||||
VGint segmentCapacityHint,
|
||||
VGint coordCapacityHint,
|
||||
VGbitfield capabilities) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgClearPath(VGPath path, VGbitfield capabilities) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgDestroyPath(VGPath path) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgRemovePathCapabilities(VGPath path,
|
||||
VGbitfield capabilities) VG_API_EXIT;
|
||||
VG_API_CALL VGbitfield VG_API_ENTRY vgGetPathCapabilities(VGPath path) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgAppendPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgAppendPathData(VGPath dstPath,
|
||||
VGint numSegments,
|
||||
const VGubyte * pathSegments,
|
||||
const void * pathData) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgModifyPathCoords(VGPath dstPath, VGint startIndex,
|
||||
VGint numSegments,
|
||||
const void * pathData) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgTransformPath(VGPath dstPath, VGPath srcPath) VG_API_EXIT;
|
||||
VG_API_CALL VGboolean VG_API_ENTRY vgInterpolatePath(VGPath dstPath,
|
||||
VGPath startPath,
|
||||
VGPath endPath,
|
||||
VGfloat amount) VG_API_EXIT;
|
||||
VG_API_CALL VGfloat VG_API_ENTRY vgPathLength(VGPath path,
|
||||
VGint startSegment, VGint numSegments) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgPointAlongPath(VGPath path,
|
||||
VGint startSegment, VGint numSegments,
|
||||
VGfloat distance,
|
||||
VGfloat * x, VGfloat * y,
|
||||
VGfloat * tangentX, VGfloat * tangentY) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgPathBounds(VGPath path,
|
||||
VGfloat * minX, VGfloat * minY,
|
||||
VGfloat * width, VGfloat * height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgPathTransformedBounds(VGPath path,
|
||||
VGfloat * minX, VGfloat * minY,
|
||||
VGfloat * width, VGfloat * height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgDrawPath(VGPath path, VGbitfield paintModes) VG_API_EXIT;
|
||||
|
||||
/* Paint */
|
||||
VG_API_CALL VGPaint VG_API_ENTRY vgCreatePaint(void) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgDestroyPaint(VGPaint paint) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetPaint(VGPaint paint, VGbitfield paintModes) VG_API_EXIT;
|
||||
VG_API_CALL VGPaint VG_API_ENTRY vgGetPaint(VGPaintMode paintMode) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetColor(VGPaint paint, VGuint rgba) VG_API_EXIT;
|
||||
VG_API_CALL VGuint VG_API_ENTRY vgGetColor(VGPaint paint) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgPaintPattern(VGPaint paint, VGImage pattern) VG_API_EXIT;
|
||||
|
||||
/* Images */
|
||||
VG_API_CALL VGImage VG_API_ENTRY vgCreateImage(VGImageFormat format,
|
||||
VGint width, VGint height,
|
||||
VGbitfield allowedQuality) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgDestroyImage(VGImage image) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgClearImage(VGImage image,
|
||||
VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgImageSubData(VGImage image,
|
||||
const void * data, VGint dataStride,
|
||||
VGImageFormat dataFormat,
|
||||
VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetImageSubData(VGImage image,
|
||||
void * data, VGint dataStride,
|
||||
VGImageFormat dataFormat,
|
||||
VGint x, VGint y,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL VGImage VG_API_ENTRY vgChildImage(VGImage parent,
|
||||
VGint x, VGint y, VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL VGImage VG_API_ENTRY vgGetParent(VGImage image) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgCopyImage(VGImage dst, VGint dx, VGint dy,
|
||||
VGImage src, VGint sx, VGint sy,
|
||||
VGint width, VGint height,
|
||||
VGboolean dither) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgDrawImage(VGImage image) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSetPixels(VGint dx, VGint dy,
|
||||
VGImage src, VGint sx, VGint sy,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgWritePixels(const void * data, VGint dataStride,
|
||||
VGImageFormat dataFormat,
|
||||
VGint dx, VGint dy,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGetPixels(VGImage dst, VGint dx, VGint dy,
|
||||
VGint sx, VGint sy,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgReadPixels(void * data, VGint dataStride,
|
||||
VGImageFormat dataFormat,
|
||||
VGint sx, VGint sy,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgCopyPixels(VGint dx, VGint dy,
|
||||
VGint sx, VGint sy,
|
||||
VGint width, VGint height) VG_API_EXIT;
|
||||
|
||||
/* Image Filters */
|
||||
VG_API_CALL void VG_API_ENTRY vgColorMatrix(VGImage dst, VGImage src,
|
||||
const VGfloat * matrix) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgConvolve(VGImage dst, VGImage src,
|
||||
VGint kernelWidth, VGint kernelHeight,
|
||||
VGint shiftX, VGint shiftY,
|
||||
const VGshort * kernel,
|
||||
VGfloat scale,
|
||||
VGfloat bias,
|
||||
VGTilingMode tilingMode) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgSeparableConvolve(VGImage dst, VGImage src,
|
||||
VGint kernelWidth,
|
||||
VGint kernelHeight,
|
||||
VGint shiftX, VGint shiftY,
|
||||
const VGshort * kernelX,
|
||||
const VGshort * kernelY,
|
||||
VGfloat scale,
|
||||
VGfloat bias,
|
||||
VGTilingMode tilingMode) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgGaussianBlur(VGImage dst, VGImage src,
|
||||
VGfloat stdDeviationX,
|
||||
VGfloat stdDeviationY,
|
||||
VGTilingMode tilingMode) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgLookup(VGImage dst, VGImage src,
|
||||
const VGubyte * redLUT,
|
||||
const VGubyte * greenLUT,
|
||||
const VGubyte * blueLUT,
|
||||
const VGubyte * alphaLUT,
|
||||
VGboolean outputLinear,
|
||||
VGboolean outputPremultiplied) VG_API_EXIT;
|
||||
VG_API_CALL void VG_API_ENTRY vgLookupSingle(VGImage dst, VGImage src,
|
||||
const VGuint * lookupTable,
|
||||
VGImageChannel sourceChannel,
|
||||
VGboolean outputLinear,
|
||||
VGboolean outputPremultiplied) VG_API_EXIT;
|
||||
|
||||
/* Hardware Queries */
|
||||
VG_API_CALL VGHardwareQueryResult VG_API_ENTRY vgHardwareQuery(VGHardwareQueryType key,
|
||||
VGint setting) VG_API_EXIT;
|
||||
|
||||
/* Renderer and Extension Information */
|
||||
VG_API_CALL const VGubyte * VG_API_ENTRY vgGetString(VGStringID name) VG_API_EXIT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _OPENVG_H */
|
233
include/VG/vgext.h
Normal file
233
include/VG/vgext.h
Normal file
@@ -0,0 +1,233 @@
|
||||
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*
|
||||
* VG extensions Reference Implementation
|
||||
* -------------------------------------
|
||||
*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and /or associated documentation files
|
||||
* (the "Materials "), to deal in the Materials without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Materials,
|
||||
* and to permit persons to whom the Materials are furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
|
||||
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*
|
||||
*//**
|
||||
* \file
|
||||
* \brief VG extensions
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#ifndef _VGEXT_H
|
||||
#define _VGEXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <VG/vgu.h>
|
||||
|
||||
#ifndef VG_API_ENTRYP
|
||||
# define VG_API_ENTRYP VG_API_ENTRY*
|
||||
#endif
|
||||
|
||||
#ifndef VGU_API_ENTRYP
|
||||
# define VGU_API_ENTRYP VGU_API_ENTRY*
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------------
|
||||
* KHR extensions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum {
|
||||
|
||||
#ifndef VG_KHR_iterative_average_blur
|
||||
VG_MAX_AVERAGE_BLUR_DIMENSION_KHR = 0x116B,
|
||||
VG_AVERAGE_BLUR_DIMENSION_RESOLUTION_KHR = 0x116C,
|
||||
VG_MAX_AVERAGE_BLUR_ITERATIONS_KHR = 0x116D,
|
||||
#endif
|
||||
|
||||
VG_PARAM_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGParamTypeKHR;
|
||||
|
||||
#ifndef VG_KHR_EGL_image
|
||||
#define VG_KHR_EGL_image 1
|
||||
/* VGEGLImageKHR is an opaque handle to an EGLImage */
|
||||
typedef void* VGeglImageKHR;
|
||||
|
||||
#ifdef VG_VGEXT_PROTOTYPES
|
||||
VG_API_CALL VGImage VG_API_ENTRY vgCreateEGLImageTargetKHR(VGeglImageKHR image);
|
||||
#endif
|
||||
typedef VGImage (VG_API_ENTRYP PFNVGCREATEEGLIMAGETARGETKHRPROC) (VGeglImageKHR image);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VG_KHR_iterative_average_blur
|
||||
#define VG_KHR_iterative_average_blur 1
|
||||
|
||||
#ifdef VG_VGEXT_PROTOTYPES
|
||||
VG_API_CALL void vgIterativeAverageBlurKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
|
||||
#endif
|
||||
typedef void (VG_API_ENTRYP PFNVGITERATIVEAVERAGEBLURKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGTilingMode tilingMode);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VG_KHR_advanced_blending
|
||||
#define VG_KHR_advanced_blending 1
|
||||
|
||||
typedef enum {
|
||||
VG_BLEND_OVERLAY_KHR = 0x2010,
|
||||
VG_BLEND_HARDLIGHT_KHR = 0x2011,
|
||||
VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
|
||||
VG_BLEND_SOFTLIGHT_KHR = 0x2013,
|
||||
VG_BLEND_COLORDODGE_KHR = 0x2014,
|
||||
VG_BLEND_COLORBURN_KHR = 0x2015,
|
||||
VG_BLEND_DIFFERENCE_KHR = 0x2016,
|
||||
VG_BLEND_SUBTRACT_KHR = 0x2017,
|
||||
VG_BLEND_INVERT_KHR = 0x2018,
|
||||
VG_BLEND_EXCLUSION_KHR = 0x2019,
|
||||
VG_BLEND_LINEARDODGE_KHR = 0x201a,
|
||||
VG_BLEND_LINEARBURN_KHR = 0x201b,
|
||||
VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
|
||||
VG_BLEND_LINEARLIGHT_KHR = 0x201d,
|
||||
VG_BLEND_PINLIGHT_KHR = 0x201e,
|
||||
VG_BLEND_HARDMIX_KHR = 0x201f,
|
||||
VG_BLEND_CLEAR_KHR = 0x2020,
|
||||
VG_BLEND_DST_KHR = 0x2021,
|
||||
VG_BLEND_SRC_OUT_KHR = 0x2022,
|
||||
VG_BLEND_DST_OUT_KHR = 0x2023,
|
||||
VG_BLEND_SRC_ATOP_KHR = 0x2024,
|
||||
VG_BLEND_DST_ATOP_KHR = 0x2025,
|
||||
VG_BLEND_XOR_KHR = 0x2026,
|
||||
|
||||
VG_BLEND_MODE_KHR_FORCE_SIZE= VG_MAX_ENUM
|
||||
} VGBlendModeKHR;
|
||||
#endif
|
||||
|
||||
#ifndef VG_KHR_parametric_filter
|
||||
#define VG_KHR_parametric_filter 1
|
||||
|
||||
typedef enum {
|
||||
VG_PF_OBJECT_VISIBLE_FLAG_KHR = (1 << 0),
|
||||
VG_PF_KNOCKOUT_FLAG_KHR = (1 << 1),
|
||||
VG_PF_OUTER_FLAG_KHR = (1 << 2),
|
||||
VG_PF_INNER_FLAG_KHR = (1 << 3),
|
||||
|
||||
VG_PF_TYPE_KHR_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPfTypeKHR;
|
||||
|
||||
typedef enum {
|
||||
VGU_IMAGE_IN_USE_ERROR = 0xF010,
|
||||
|
||||
VGU_ERROR_CODE_KHR_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGUErrorCodeKHR;
|
||||
|
||||
#ifdef VG_VGEXT_PROTOTYPES
|
||||
VG_API_CALL void VG_API_ENTRY vgParametricFilterKHR(VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguDropShadowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA) ;
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientGlowKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguGradientBevelKHR(VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
|
||||
#endif
|
||||
typedef void (VG_API_ENTRYP PFNVGPARAMETRICFILTERKHRPROC) (VGImage dst,VGImage src,VGImage blur,VGfloat strength,VGfloat offsetX,VGfloat offsetY,VGbitfield filterFlags,VGPaint highlightPaint,VGPaint shadowPaint);
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUDROPSHADOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint shadowColorRGBA);
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint glowColorRGBA);
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint highlightColorRGBA,VGuint shadowColorRGBA);
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTGLOWKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* glowColorRampStops);
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUGRADIENTBEVELKHRPROC) (VGImage dst,VGImage src,VGfloat dimX,VGfloat dimY,VGuint iterative,VGfloat strength,VGfloat distance,VGfloat angle,VGbitfield filterFlags,VGbitfield allowedQuality,VGuint stopsCount,const VGfloat* bevelColorRampStops);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------
|
||||
* NDS extensions
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef VG_NDS_paint_generation
|
||||
#define VG_NDS_paint_generation 1
|
||||
|
||||
typedef enum {
|
||||
VG_PAINT_COLOR_RAMP_LINEAR_NDS = 0x1A10,
|
||||
VG_COLOR_MATRIX_NDS = 0x1A11,
|
||||
VG_PAINT_COLOR_TRANSFORM_LINEAR_NDS = 0x1A12,
|
||||
|
||||
VG_PAINT_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPaintParamTypeNds;
|
||||
|
||||
typedef enum {
|
||||
VG_DRAW_IMAGE_COLOR_MATRIX_NDS = 0x1F10,
|
||||
|
||||
VG_IMAGE_MODE_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGImageModeNds;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VG_NDS_projective_geometry
|
||||
#define VG_NDS_projective_geometry 1
|
||||
|
||||
typedef enum {
|
||||
VG_CLIP_MODE_NDS = 0x1180,
|
||||
VG_CLIP_LINES_NDS = 0x1181,
|
||||
VG_MAX_CLIP_LINES_NDS = 0x1182,
|
||||
|
||||
VG_PARAM_TYPE_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGParamTypeNds;
|
||||
|
||||
typedef enum {
|
||||
VG_CLIPMODE_NONE_NDS = 0x3000,
|
||||
VG_CLIPMODE_CLIP_CLOSED_NDS = 0x3001,
|
||||
VG_CLIPMODE_CLIP_OPEN_NDS = 0x3002,
|
||||
VG_CLIPMODE_CULL_NDS = 0x3003,
|
||||
|
||||
VG_CLIPMODE_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGClipModeNds;
|
||||
|
||||
typedef enum {
|
||||
VG_RQUAD_TO_NDS = ( 13 << 1 ),
|
||||
VG_RCUBIC_TO_NDS = ( 14 << 1 ),
|
||||
|
||||
VG_PATH_SEGMENT_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathSegmentNds;
|
||||
|
||||
typedef enum {
|
||||
VG_RQUAD_TO_ABS_NDS = (VG_RQUAD_TO_NDS | VG_ABSOLUTE),
|
||||
VG_RQUAD_TO_REL_NDS = (VG_RQUAD_TO_NDS | VG_RELATIVE),
|
||||
VG_RCUBIC_TO_ABS_NDS = (VG_RCUBIC_TO_NDS | VG_ABSOLUTE),
|
||||
VG_RCUBIC_TO_REL_NDS = (VG_RCUBIC_TO_NDS | VG_RELATIVE),
|
||||
|
||||
VG_PATH_COMMAND_NDS_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGPathCommandNds;
|
||||
|
||||
#ifdef VG_VGEXT_PROTOTYPES
|
||||
VG_API_CALL void VG_API_ENTRY vgProjectiveMatrixNDS(VGboolean enable) ;
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguTransformClipLineNDS(const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
|
||||
#endif
|
||||
typedef void (VG_API_ENTRYP PFNVGPROJECTIVEMATRIXNDSPROC) (VGboolean enable) ;
|
||||
typedef VGUErrorCode (VGU_API_ENTRYP PFNVGUTRANSFORMCLIPLINENDSPROC) (const VGfloat Ain,const VGfloat Bin,const VGfloat Cin,const VGfloat* matrix,const VGboolean inverse,VGfloat* Aout,VGfloat* Bout,VGfloat* Cout);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _VGEXT_H */
|
111
include/VG/vgplatform.h
Normal file
111
include/VG/vgplatform.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*
|
||||
* VG platform specific header Reference Implementation
|
||||
* ----------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and /or associated documentation files
|
||||
* (the "Materials "), to deal in the Materials without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Materials,
|
||||
* and to permit persons to whom the Materials are furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
|
||||
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*
|
||||
*//**
|
||||
* \file
|
||||
* \brief VG platform specific header
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _VGPLATFORM_H
|
||||
#define _VGPLATFORM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
|
||||
# define VG_API_CALL __attribute__((visibility("default")))
|
||||
# define VGU_API_CALL __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifndef VG_API_CALL
|
||||
#if defined(OPENVG_STATIC_LIBRARY)
|
||||
# define VG_API_CALL
|
||||
#else
|
||||
# if defined(_WIN32) || defined(__VC32__) /* Win32 */
|
||||
# if defined (OPENVG_DLL_EXPORTS)
|
||||
# define VG_API_CALL __declspec(dllexport)
|
||||
# else
|
||||
# define VG_API_CALL __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define VG_API_CALL extern
|
||||
# endif /* defined(_WIN32) ||... */
|
||||
#endif /* defined OPENVG_STATIC_LIBRARY */
|
||||
#endif /* ifndef VG_API_CALL */
|
||||
|
||||
#ifndef VGU_API_CALL
|
||||
#if defined(OPENVG_STATIC_LIBRARY)
|
||||
# define VGU_API_CALL
|
||||
#else
|
||||
# if defined(_WIN32) || defined(__VC32__) /* Win32 */
|
||||
# if defined (OPENVG_DLL_EXPORTS)
|
||||
# define VGU_API_CALL __declspec(dllexport)
|
||||
# else
|
||||
# define VGU_API_CALL __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define VGU_API_CALL extern
|
||||
# endif /* defined(_WIN32) ||... */
|
||||
#endif /* defined OPENVG_STATIC_LIBRARY */
|
||||
#endif /* ifndef VGU_API_CALL */
|
||||
|
||||
|
||||
#ifndef VG_API_ENTRY
|
||||
#define VG_API_ENTRY
|
||||
#endif
|
||||
|
||||
#ifndef VG_API_EXIT
|
||||
#define VG_API_EXIT
|
||||
#endif
|
||||
|
||||
#ifndef VGU_API_ENTRY
|
||||
#define VGU_API_ENTRY
|
||||
#endif
|
||||
|
||||
#ifndef VGU_API_EXIT
|
||||
#define VGU_API_EXIT
|
||||
#endif
|
||||
|
||||
typedef float VGfloat;
|
||||
typedef signed char VGbyte;
|
||||
typedef unsigned char VGubyte;
|
||||
typedef signed short VGshort;
|
||||
typedef signed int VGint;
|
||||
typedef unsigned int VGuint;
|
||||
typedef unsigned int VGbitfield;
|
||||
|
||||
#ifndef VG_VGEXT_PROTOTYPES
|
||||
#define VG_VGEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* _VGPLATFORM_H */
|
130
include/VG/vgu.h
Normal file
130
include/VG/vgu.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/* $Revision: 6810 $ on $Date:: 2008-10-29 10:31:37 -0400 #$ */
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*
|
||||
* VGU 1.0.1 Reference Implementation
|
||||
* -------------------------------------
|
||||
*
|
||||
* Copyright (c) 2008 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and /or associated documentation files
|
||||
* (the "Materials "), to deal in the Materials without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Materials,
|
||||
* and to permit persons to whom the Materials are furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
|
||||
* THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*
|
||||
*//**
|
||||
* \file
|
||||
* \brief VGU 1.0.1 API.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _VGU_H
|
||||
#define _VGU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#define VGU_VERSION_1_0 1
|
||||
|
||||
#ifndef VGU_API_CALL
|
||||
# error VGU_API_CALL must be defined
|
||||
#endif
|
||||
|
||||
#ifndef VGU_API_ENTRY
|
||||
# error VGU_API_ENTRY must be defined
|
||||
#endif
|
||||
|
||||
#ifndef VGU_API_EXIT
|
||||
# error VGU_API_EXIT must be defined
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum {
|
||||
VGU_NO_ERROR = 0,
|
||||
VGU_BAD_HANDLE_ERROR = 0xF000,
|
||||
VGU_ILLEGAL_ARGUMENT_ERROR = 0xF001,
|
||||
VGU_OUT_OF_MEMORY_ERROR = 0xF002,
|
||||
VGU_PATH_CAPABILITY_ERROR = 0xF003,
|
||||
VGU_BAD_WARP_ERROR = 0xF004,
|
||||
|
||||
VGU_ERROR_CODE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGUErrorCode;
|
||||
|
||||
typedef enum {
|
||||
VGU_ARC_OPEN = 0xF100,
|
||||
VGU_ARC_CHORD = 0xF101,
|
||||
VGU_ARC_PIE = 0xF102,
|
||||
|
||||
VGU_ARC_TYPE_FORCE_SIZE = VG_MAX_ENUM
|
||||
} VGUArcType;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguLine(VGPath path,
|
||||
VGfloat x0, VGfloat y0,
|
||||
VGfloat x1, VGfloat y1) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguPolygon(VGPath path,
|
||||
const VGfloat * points, VGint count,
|
||||
VGboolean closed) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRect(VGPath path,
|
||||
VGfloat x, VGfloat y,
|
||||
VGfloat width, VGfloat height) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguRoundRect(VGPath path,
|
||||
VGfloat x, VGfloat y,
|
||||
VGfloat width, VGfloat height,
|
||||
VGfloat arcWidth, VGfloat arcHeight) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguEllipse(VGPath path,
|
||||
VGfloat cx, VGfloat cy,
|
||||
VGfloat width, VGfloat height) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguArc(VGPath path,
|
||||
VGfloat x, VGfloat y,
|
||||
VGfloat width, VGfloat height,
|
||||
VGfloat startAngle, VGfloat angleExtent,
|
||||
VGUArcType arcType) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToSquare(VGfloat sx0, VGfloat sy0,
|
||||
VGfloat sx1, VGfloat sy1,
|
||||
VGfloat sx2, VGfloat sy2,
|
||||
VGfloat sx3, VGfloat sy3,
|
||||
VGfloat * matrix) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpSquareToQuad(VGfloat dx0, VGfloat dy0,
|
||||
VGfloat dx1, VGfloat dy1,
|
||||
VGfloat dx2, VGfloat dy2,
|
||||
VGfloat dx3, VGfloat dy3,
|
||||
VGfloat * matrix) VGU_API_EXIT;
|
||||
|
||||
VGU_API_CALL VGUErrorCode VGU_API_ENTRY vguComputeWarpQuadToQuad(VGfloat dx0, VGfloat dy0,
|
||||
VGfloat dx1, VGfloat dy1,
|
||||
VGfloat dx2, VGfloat dy2,
|
||||
VGfloat dx3, VGfloat dy3,
|
||||
VGfloat sx0, VGfloat sy0,
|
||||
VGfloat sx1, VGfloat sy1,
|
||||
VGfloat sx2, VGfloat sy2,
|
||||
VGfloat sx3, VGfloat sy3,
|
||||
VGfloat * matrix) VGU_API_EXIT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef _VGU_H */
|
12
progs/egl/.gitignore
vendored
Normal file
12
progs/egl/.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
demo1
|
||||
demo2
|
||||
demo3
|
||||
eglgears
|
||||
eglinfo
|
||||
eglscreen
|
||||
egltri
|
||||
peglgears
|
||||
xeglbindtex
|
||||
xeglgears
|
||||
xeglthreads
|
||||
xegl_tri
|
70
progs/egl/Makefile
Normal file
70
progs/egl/Makefile
Normal file
@@ -0,0 +1,70 @@
|
||||
# progs/egl/Makefile
|
||||
|
||||
TOP = ../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/include
|
||||
|
||||
HEADERS = $(TOP)/include/GLES/egl.h
|
||||
LIB_DEP = $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -lEGL -lGL
|
||||
|
||||
PROGRAMS = \
|
||||
demo1 \
|
||||
demo2 \
|
||||
demo3 \
|
||||
egltri \
|
||||
eglinfo \
|
||||
eglgears \
|
||||
eglscreen \
|
||||
peglgears \
|
||||
xeglgears \
|
||||
xeglthreads \
|
||||
xegl_tri
|
||||
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
default: $(PROGRAMS)
|
||||
|
||||
demo1: demo1.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB)
|
||||
|
||||
demo2: demo2.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB)
|
||||
|
||||
demo3: demo3.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB)
|
||||
|
||||
egltri: egltri.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB)
|
||||
|
||||
eglinfo: eglinfo.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
eglgears: eglgears.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -lm
|
||||
|
||||
eglscreen: eglscreen.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB)
|
||||
|
||||
peglgears: peglgears.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -lm
|
||||
|
||||
xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
|
||||
|
||||
xeglthreads: xeglthreads.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
|
||||
|
||||
xegl_tri: xegl_tri.o $(HEADERS) $(LIB_DEP)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lm -L$(libdir) -lX11
|
||||
|
||||
clean:
|
||||
-rm -f *.o *~
|
||||
-rm -f $(PROGRAMS)
|
147
progs/egl/demo1.c
Normal file
147
progs/egl/demo1.c
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Exercise EGL API functions
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/**
|
||||
* Test EGL_MESA_screen_surface functions
|
||||
*/
|
||||
static void
|
||||
TestScreens(EGLDisplay dpy)
|
||||
{
|
||||
#define MAX 8
|
||||
EGLScreenMESA screens[MAX];
|
||||
EGLint numScreens;
|
||||
EGLint i;
|
||||
|
||||
eglGetScreensMESA(dpy, screens, MAX, &numScreens);
|
||||
printf("Found %d screens\n", numScreens);
|
||||
for (i = 0; i < numScreens; i++) {
|
||||
printf(" Screen %d handle: %d\n", i, (int) screens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print table of all available configurations.
|
||||
*/
|
||||
static void
|
||||
PrintConfigs(EGLDisplay d, EGLConfig *configs, EGLint numConfigs)
|
||||
{
|
||||
EGLint i;
|
||||
|
||||
printf("Configurations:\n");
|
||||
printf(" bf lv d st colorbuffer dp st supported \n");
|
||||
printf(" id sz l b ro r g b a th cl surfaces \n");
|
||||
printf("----------------------------------------------\n");
|
||||
for (i = 0; i < numConfigs; i++) {
|
||||
EGLint id, size, level;
|
||||
EGLint red, green, blue, alpha;
|
||||
EGLint depth, stencil;
|
||||
EGLint surfaces;
|
||||
EGLint doubleBuf = 1, stereo = 0;
|
||||
char surfString[100] = "";
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level);
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces);
|
||||
|
||||
if (surfaces & EGL_WINDOW_BIT)
|
||||
strcat(surfString, "win,");
|
||||
if (surfaces & EGL_PBUFFER_BIT)
|
||||
strcat(surfString, "pb,");
|
||||
if (surfaces & EGL_PIXMAP_BIT)
|
||||
strcat(surfString, "pix,");
|
||||
if (strlen(surfString) > 0)
|
||||
surfString[strlen(surfString) - 1] = 0;
|
||||
|
||||
printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n",
|
||||
id, size, level,
|
||||
doubleBuf ? 'y' : '.',
|
||||
stereo ? 'y' : '.',
|
||||
red, green, blue, alpha,
|
||||
depth, stencil, surfString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface pbuffer;
|
||||
EGLConfig *configs;
|
||||
EGLint numConfigs;
|
||||
EGLBoolean b;
|
||||
const EGLint pbufAttribs[] = {
|
||||
EGL_WIDTH, 500,
|
||||
EGL_HEIGHT, 500,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("demo: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
eglGetConfigs(d, NULL, 0, &numConfigs);
|
||||
configs = malloc(sizeof(*configs) *numConfigs);
|
||||
eglGetConfigs(d, configs, numConfigs, &numConfigs);
|
||||
|
||||
PrintConfigs(d, configs, numConfigs);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pbuffer = eglCreatePbufferSurface(d, configs[0], pbufAttribs);
|
||||
if (pbuffer == EGL_NO_SURFACE) {
|
||||
printf("failed to create pbuffer\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(configs);
|
||||
|
||||
b = eglMakeCurrent(d, pbuffer, pbuffer, ctx);
|
||||
if (!b) {
|
||||
printf("make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
TestScreens(d);
|
||||
|
||||
eglDestroySurface(d, pbuffer);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
216
progs/egl/demo2.c
Normal file
216
progs/egl/demo2.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Exercise EGL API functions
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES/gl.h>
|
||||
|
||||
/*#define FRONTBUFFER*/
|
||||
|
||||
static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
|
||||
GLfloat r, GLfloat g, GLfloat b)
|
||||
{
|
||||
GLfloat v[4][2], c[4][4];
|
||||
int i;
|
||||
|
||||
v[0][0] = x1; v[0][1] = y1;
|
||||
v[1][0] = x2; v[1][1] = y1;
|
||||
v[2][0] = x2; v[2][1] = y2;
|
||||
v[3][0] = x1; v[3][1] = y2;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
c[i][0] = r;
|
||||
c[i][1] = g;
|
||||
c[i][2] = b;
|
||||
c[i][3] = 1.0;
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, v);
|
||||
glColorPointer(4, GL_FLOAT, 0, v);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
static void redraw(EGLDisplay dpy, EGLSurface surf, int rot)
|
||||
{
|
||||
GLfloat r, g, b;
|
||||
|
||||
printf("Redraw event\n");
|
||||
|
||||
glClearColor( rand()/(float)RAND_MAX,
|
||||
rand()/(float)RAND_MAX,
|
||||
rand()/(float)RAND_MAX,
|
||||
1);
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
r = rand()/(float)RAND_MAX;
|
||||
g = rand()/(float)RAND_MAX;
|
||||
b = rand()/(float)RAND_MAX;
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(rot, 0, 0, 1);
|
||||
glScalef(.5, .5, .5);
|
||||
_subset_Rectf( -1, -1, 1, 1, r, g, b );
|
||||
glPopMatrix();
|
||||
|
||||
#ifdef FRONTBUFFER
|
||||
glFlush();
|
||||
#else
|
||||
eglSwapBuffers( dpy, surf );
|
||||
#endif
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test EGL_MESA_screen_surface functions
|
||||
*/
|
||||
static void
|
||||
TestScreens(EGLDisplay dpy)
|
||||
{
|
||||
#define MAX 8
|
||||
EGLScreenMESA screens[MAX];
|
||||
EGLint numScreens;
|
||||
EGLint i;
|
||||
|
||||
eglGetScreensMESA(dpy, screens, MAX, &numScreens);
|
||||
printf("Found %d screens\n", numScreens);
|
||||
for (i = 0; i < numScreens; i++) {
|
||||
printf(" Screen %d handle: %d\n", i, (int) screens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface pbuffer, screen_surf;
|
||||
EGLConfig configs[10];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
const EGLint pbufAttribs[] = {
|
||||
EGL_WIDTH, 500,
|
||||
EGL_HEIGHT, 500,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint screenAttribs[32];
|
||||
EGLModeMESA mode;
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("demo: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
|
||||
"EGL_MESA_screen_surface")) {
|
||||
printf("EGL_MESA_screen_surface is not supported\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
eglGetConfigs(d, configs, 10, &numConfigs);
|
||||
printf("Got %d EGL configs:\n", numConfigs);
|
||||
for (i = 0; i < numConfigs; i++) {
|
||||
EGLint id, red, depth;
|
||||
eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
|
||||
printf("%2d: Red Size = %d Depth Size = %d\n", id, red, depth);
|
||||
}
|
||||
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
eglGetModesMESA(d, screen, &mode, 1, &count);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pbuffer = eglCreatePbufferSurface(d, configs[0], pbufAttribs);
|
||||
if (pbuffer == EGL_NO_SURFACE) {
|
||||
printf("failed to create pbuffer\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, pbuffer, pbuffer, ctx);
|
||||
if (!b) {
|
||||
printf("make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]);
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]);
|
||||
screenAttribs[i] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
eglShowScreenSurfaceMESA(d, screen, screen_surf, mode);
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
printf("make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
glViewport(0, 0, 1024, 768);
|
||||
|
||||
glClearColor( 0,
|
||||
1.0,
|
||||
0,
|
||||
1);
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
|
||||
TestScreens(d);
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
redraw(d, screen_surf, i*10 );
|
||||
|
||||
printf("sleep(1)\n");
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
eglDestroySurface(d, pbuffer);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
647
progs/egl/demo3.c
Normal file
647
progs/egl/demo3.c
Normal file
@@ -0,0 +1,647 @@
|
||||
/*
|
||||
* Exercise EGL API functions
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GL/gl.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#define PIXEL_CENTER(x) ((long)(x) + 0.5)
|
||||
|
||||
#define GAP 10
|
||||
#define ROWS 3
|
||||
#define COLS 4
|
||||
|
||||
#define OPENGL_WIDTH 48
|
||||
#define OPENGL_HEIGHT 13
|
||||
|
||||
|
||||
GLenum rgb, doubleBuffer, windType;
|
||||
GLint windW, windH;
|
||||
|
||||
GLenum mode1, mode2;
|
||||
GLint boxW, boxH;
|
||||
GLubyte OpenGL_bits[] = {
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
|
||||
0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01,
|
||||
0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00,
|
||||
0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00,
|
||||
0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00,
|
||||
0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00,
|
||||
0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a,
|
||||
0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e,
|
||||
0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e,
|
||||
0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
|
||||
};
|
||||
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
|
||||
mode1 = GL_TRUE;
|
||||
mode2 = GL_TRUE;
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
windW = (GLint)width;
|
||||
windH = (GLint)height;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void RotateColorMask(void)
|
||||
{
|
||||
static GLint rotation = 0;
|
||||
|
||||
rotation = (rotation + 1) & 0x3;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glIndexMask( 0xff );
|
||||
break;
|
||||
case 1:
|
||||
glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glIndexMask(0xFE);
|
||||
break;
|
||||
case 2:
|
||||
glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
|
||||
glIndexMask(0xFD);
|
||||
break;
|
||||
case 3:
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
|
||||
glIndexMask(0xFB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void Viewport(GLint row, GLint column)
|
||||
{
|
||||
GLint x, y;
|
||||
|
||||
boxW = (windW - (COLS + 1) * GAP) / COLS;
|
||||
boxH = (windH - (ROWS + 1) * GAP) / ROWS;
|
||||
|
||||
x = GAP + column * (boxW + GAP);
|
||||
y = GAP + row * (boxH + GAP);
|
||||
|
||||
glViewport(x, y, boxW, boxH);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(x, y, boxW, boxH);
|
||||
}
|
||||
|
||||
enum {
|
||||
COLOR_BLACK = 0,
|
||||
COLOR_RED,
|
||||
COLOR_GREEN,
|
||||
COLOR_YELLOW,
|
||||
COLOR_BLUE,
|
||||
COLOR_MAGENTA,
|
||||
COLOR_CYAN,
|
||||
COLOR_WHITE
|
||||
};
|
||||
|
||||
static float RGBMap[9][3] = {
|
||||
{0, 0, 0},
|
||||
{1, 0, 0},
|
||||
{0, 1, 0},
|
||||
{1, 1, 0},
|
||||
{0, 0, 1},
|
||||
{1, 0, 1},
|
||||
{0, 1, 1},
|
||||
{1, 1, 1},
|
||||
{0.5, 0.5, 0.5}
|
||||
};
|
||||
|
||||
static void SetColor(int c)
|
||||
{
|
||||
glColor3fv(RGBMap[c]);
|
||||
}
|
||||
|
||||
static void Point(void)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, 0);
|
||||
for (i = 1; i < 8; i++) {
|
||||
GLint j = i * 2;
|
||||
SetColor(COLOR_BLACK+i);
|
||||
glVertex2i(-j, -j);
|
||||
glVertex2i(-j, 0);
|
||||
glVertex2i(-j, j);
|
||||
glVertex2i(0, j);
|
||||
glVertex2i(j, j);
|
||||
glVertex2i(j, 0);
|
||||
glVertex2i(j, -j);
|
||||
glVertex2i(0, -j);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Lines(void)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(-12, 0, 0);
|
||||
for (i = 1; i < 8; i++) {
|
||||
SetColor(COLOR_BLACK+i);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
glTranslatef(4, 0, 0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void LineStrip(void)
|
||||
{
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void LineLoop(void)
|
||||
{
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_LOGIC_OP);
|
||||
glLogicOp(GL_XOR);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
SetColor(COLOR_MAGENTA);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8));
|
||||
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8));
|
||||
glEnd();
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5));
|
||||
glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5));
|
||||
glEnd();
|
||||
glDisable(GL_LOGIC_OP);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2i(0, 0);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(0, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Bitmap(void)
|
||||
{
|
||||
|
||||
glBegin(GL_LINES);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/2, 0);
|
||||
glVertex2i(boxW/2, 0);
|
||||
glVertex2i(0, -boxH/2);
|
||||
glVertex2i(0, boxH/2);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(0, -3);
|
||||
glVertex2i(0, -3+OPENGL_HEIGHT);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -3);
|
||||
glVertex2i(OPENGL_WIDTH, -3);
|
||||
glEnd();
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
|
||||
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glRasterPos2i(0, 0);
|
||||
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, 0, 3, 0.0, 0.0, OpenGL_bits);
|
||||
}
|
||||
|
||||
static void Triangles(void)
|
||||
{
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, -boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, -boxH/16);
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, boxH/16);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void TriangleStrip(void)
|
||||
{
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -boxH/4);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, boxH/4);
|
||||
SetColor(COLOR_CYAN);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
SetColor(COLOR_YELLOW);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void TriangleFan(void)
|
||||
{
|
||||
GLint vx[8][2];
|
||||
GLint x0, y0, x1, y1, x2, y2, x3, y3;
|
||||
GLint i;
|
||||
|
||||
y0 = -boxH/4;
|
||||
y1 = y0 + boxH/2/3;
|
||||
y2 = y1 + boxH/2/3;
|
||||
y3 = boxH/4;
|
||||
x0 = -boxW/4;
|
||||
x1 = x0 + boxW/2/3;
|
||||
x2 = x1 + boxW/2/3;
|
||||
x3 = boxW/4;
|
||||
|
||||
vx[0][0] = x0; vx[0][1] = y1;
|
||||
vx[1][0] = x0; vx[1][1] = y2;
|
||||
vx[2][0] = x1; vx[2][1] = y3;
|
||||
vx[3][0] = x2; vx[3][1] = y3;
|
||||
vx[4][0] = x3; vx[4][1] = y2;
|
||||
vx[5][0] = x3; vx[5][1] = y1;
|
||||
vx[6][0] = x2; vx[6][1] = y0;
|
||||
vx[7][0] = x1; vx[7][1] = y0;
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, 0);
|
||||
for (i = 0; i < 8; i++) {
|
||||
SetColor(COLOR_WHITE-i);
|
||||
glVertex2iv(vx[i]);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Rect(void)
|
||||
{
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4);
|
||||
}
|
||||
|
||||
static void PolygonFunc(void)
|
||||
{
|
||||
GLint vx[8][2];
|
||||
GLint x0, y0, x1, y1, x2, y2, x3, y3;
|
||||
GLint i;
|
||||
|
||||
y0 = -boxH/4;
|
||||
y1 = y0 + boxH/2/3;
|
||||
y2 = y1 + boxH/2/3;
|
||||
y3 = boxH/4;
|
||||
x0 = -boxW/4;
|
||||
x1 = x0 + boxW/2/3;
|
||||
x2 = x1 + boxW/2/3;
|
||||
x3 = boxW/4;
|
||||
|
||||
vx[0][0] = x0; vx[0][1] = y1;
|
||||
vx[1][0] = x0; vx[1][1] = y2;
|
||||
vx[2][0] = x1; vx[2][1] = y3;
|
||||
vx[3][0] = x2; vx[3][1] = y3;
|
||||
vx[4][0] = x3; vx[4][1] = y2;
|
||||
vx[5][0] = x3; vx[5][1] = y1;
|
||||
vx[6][0] = x2; vx[6][1] = y0;
|
||||
vx[7][0] = x1; vx[7][1] = y0;
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
for (i = 0; i < 8; i++) {
|
||||
SetColor(COLOR_WHITE-i);
|
||||
glVertex2iv(vx[i]);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Quads(void)
|
||||
{
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, -boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, -boxH/16);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/8, boxH/16);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(boxW/8, boxH/16);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glVertex2i(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void QuadStrip(void)
|
||||
{
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
SetColor(COLOR_GREEN);
|
||||
glVertex2i(-boxW/4, -boxH/4);
|
||||
SetColor(COLOR_RED);
|
||||
glVertex2i(-boxW/4, boxH/4);
|
||||
SetColor(COLOR_BLUE);
|
||||
glVertex2i(0, -boxH/4);
|
||||
SetColor(COLOR_WHITE);
|
||||
glVertex2i(0, boxH/4);
|
||||
SetColor(COLOR_CYAN);
|
||||
glVertex2i(boxW/4, -boxH/4);
|
||||
SetColor(COLOR_YELLOW);
|
||||
glVertex2i(boxW/4, boxH/4);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
glVertex2i(0, 0);
|
||||
glVertex2i(100, 100);
|
||||
glVertex2i(-100, 100);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void Draw(EGLDisplay dpy, EGLSurface surf)
|
||||
{
|
||||
|
||||
glViewport(0, 0, windW, windH);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColorMask(1, 1, 1, 1);
|
||||
glIndexMask(~0);
|
||||
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glPopAttrib();
|
||||
|
||||
if (mode1) {
|
||||
glShadeModel(GL_SMOOTH);
|
||||
} else {
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
if (mode2) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
} else {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
|
||||
Viewport(0, 0); Point();
|
||||
Viewport(0, 1); Lines();
|
||||
Viewport(0, 2); LineStrip();
|
||||
Viewport(0, 3); LineLoop();
|
||||
|
||||
Viewport(1, 0); Bitmap();
|
||||
|
||||
Viewport(1, 1); TriangleFan();
|
||||
Viewport(1, 2); Triangles();
|
||||
Viewport(1, 3); TriangleStrip();
|
||||
|
||||
Viewport(2, 0); Rect();
|
||||
Viewport(2, 1); PolygonFunc();
|
||||
Viewport(2, 2); Quads();
|
||||
Viewport(2, 3); QuadStrip();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
eglSwapBuffers(dpy, surf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
|
||||
{
|
||||
const int binary = 0;
|
||||
FILE *f = fopen( filename, "w" );
|
||||
if (f) {
|
||||
int i, x, y;
|
||||
const GLubyte *ptr = buffer;
|
||||
if (binary) {
|
||||
fprintf(f,"P6\n");
|
||||
fprintf(f,"# ppm-file created by osdemo.c\n");
|
||||
fprintf(f,"%i %i\n", width,height);
|
||||
fprintf(f,"255\n");
|
||||
fclose(f);
|
||||
f = fopen( filename, "ab" ); /* reopen in binary append mode */
|
||||
for (y=height-1; y>=0; y--) {
|
||||
for (x=0; x<width; x++) {
|
||||
i = (y*width + x) * 4;
|
||||
fputc(ptr[i], f); /* write red */
|
||||
fputc(ptr[i+1], f); /* write green */
|
||||
fputc(ptr[i+2], f); /* write blue */
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*ASCII*/
|
||||
int counter = 0;
|
||||
fprintf(f,"P3\n");
|
||||
fprintf(f,"# ascii ppm file created by osdemo.c\n");
|
||||
fprintf(f,"%i %i\n", width, height);
|
||||
fprintf(f,"255\n");
|
||||
for (y=height-1; y>=0; y--) {
|
||||
for (x=0; x<width; x++) {
|
||||
i = (y*width + x) * 4;
|
||||
fprintf(f, " %3d %3d %3d", ptr[i], ptr[i+1], ptr[i+2]);
|
||||
counter++;
|
||||
if (counter % 5 == 0)
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface screen_surf;
|
||||
EGLConfig configs[10];
|
||||
EGLScreenMESA screen;
|
||||
EGLModeMESA mode;
|
||||
EGLint numConfigs, count;
|
||||
EGLBoolean b;
|
||||
const GLubyte *bitmap;
|
||||
EGLint screenAttribs[32];
|
||||
EGLint i;
|
||||
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("demo: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("EGL version = %d.%d\n", maj, min);
|
||||
printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
if (!strstr(eglQueryString(d, EGL_EXTENSIONS),
|
||||
"EGL_MESA_screen_surface")) {
|
||||
printf("EGL_MESA_screen_surface is not supported\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
eglGetConfigs(d, configs, 10, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
eglGetModesMESA(d, screen, &mode, 1, &count);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]);
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]);
|
||||
screenAttribs[i] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
eglShowScreenSurfaceMESA(d, screen, screen_surf, mode);
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
printf("make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
glViewport(0, 0, 1024, 768);
|
||||
|
||||
|
||||
Init();
|
||||
Reshape(1024, 768);
|
||||
|
||||
/* some drivers crash when rendering to front buffer */
|
||||
#if 0
|
||||
glDrawBuffer( GL_FRONT );
|
||||
glClearColor( 0, 1.0, 0, 1);
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
#endif
|
||||
|
||||
doubleBuffer = 1;
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
Draw(d, screen_surf);
|
||||
sleep(2);
|
||||
|
||||
/* TODO EGL_KHR_lock_surface */
|
||||
bitmap = NULL;
|
||||
if (bitmap)
|
||||
write_ppm("dump.ppm", bitmap, 1024, 768);
|
||||
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
482
progs/egl/eglgears.c
Normal file
482
progs/egl/eglgears.c
Normal file
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a port of the infamous "glxgears" demo to straight EGL
|
||||
* Port by Dane Rushton 10 July 2005
|
||||
*
|
||||
* No command line options.
|
||||
* Program runs for 5 seconds then exits, outputing framerate to console
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#define MAX_CONFIGS 10
|
||||
#define MAX_MODES 100
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
|
||||
/* XXX this probably isn't very portable */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* return current time (in seconds) */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef __VMS
|
||||
(void) gettimeofday(&tv, NULL );
|
||||
#else
|
||||
struct timezone tz;
|
||||
(void) gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
#else /*BENCHMARK*/
|
||||
|
||||
/* dummy */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
/* update this function for other platforms! */
|
||||
static double t = 0.0;
|
||||
static int warn = 1;
|
||||
if (warn) {
|
||||
fprintf(stderr, "Warning: current_time() not implemented!!\n");
|
||||
warn = 0;
|
||||
}
|
||||
return t += 1.0;
|
||||
}
|
||||
|
||||
#endif /*BENCHMARK*/
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
|
||||
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
||||
static GLint gear1, gear2, gear3;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
#if 0
|
||||
static GLfloat eyesep = 5.0; /* Eye separation. */
|
||||
static GLfloat fix_point = 40.0; /* Fixation point distance. */
|
||||
static GLfloat left, right, asp; /* Stereo frustum params. */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Draw a gear wheel. You'll probably want to call this function when
|
||||
* building a display list since we do a lot of trig here.
|
||||
*
|
||||
* Input: inner_radius - radius of hole at center
|
||||
* outer_radius - radius at center of teeth
|
||||
* width - width of gear
|
||||
* teeth - number of teeth
|
||||
* tooth_depth - depth of tooth
|
||||
*/
|
||||
static void
|
||||
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth)
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth / 2.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1.0, 0.0, 0.0);
|
||||
glRotatef(view_roty, 0.0, 1.0, 0.0);
|
||||
glRotatef(view_rotz, 0.0, 0.0, 1.0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(angle, 0.0, 0.0, 1.0);
|
||||
glCallList(gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
|
||||
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
|
||||
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* make the gears */
|
||||
gear1 = glGenLists(1);
|
||||
glNewList(gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear2 = glGenLists(1);
|
||||
glNewList(gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear3 = glGenLists(1);
|
||||
glNewList(gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
|
||||
{
|
||||
double st = current_time();
|
||||
double ct = st;
|
||||
int frames = 0;
|
||||
GLfloat seconds, fps;
|
||||
|
||||
while (ct - st < ttr)
|
||||
{
|
||||
double tt = current_time();
|
||||
double dt = tt - ct;
|
||||
ct = tt;
|
||||
|
||||
/* advance rotation for next frame */
|
||||
angle += 70.0 * dt; /* 70 degrees per second */
|
||||
if (angle > 3600.0)
|
||||
angle -= 3600.0;
|
||||
|
||||
draw();
|
||||
|
||||
eglSwapBuffers(dpy, surf);
|
||||
|
||||
|
||||
frames++;
|
||||
}
|
||||
|
||||
seconds = ct - st;
|
||||
fps = frames / seconds;
|
||||
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface screen_surf;
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
EGLDisplay d;
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
EGLint chosenMode = 0;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint width = 0, height = 0;
|
||||
|
||||
/* parse cmd line args */
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-info") == 0)
|
||||
{
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else
|
||||
printf("Warning: unknown parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
/* DBR : Create EGL context/surface etc */
|
||||
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglgears: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("eglgears: EGL version = %d.%d\n", maj, min);
|
||||
printf("eglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
/* XXX use ChooseConfig */
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
|
||||
if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) {
|
||||
printf("eglgears: eglGetModesMESA failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print list of modes, and find the one to use */
|
||||
printf("eglgears: Found %d modes:\n", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
EGLint w, h;
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
|
||||
printf("%3d: %d x %d\n", i, w, h);
|
||||
if (w > width && h > height) {
|
||||
width = w;
|
||||
height = h;
|
||||
chosenMode = i;
|
||||
}
|
||||
}
|
||||
printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("eglgears: failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* build up screenAttribs array */
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
screenAttribs[i++] = width;
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
screenAttribs[i++] = height;
|
||||
screenAttribs[i++] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("eglgears: failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]);
|
||||
if (!b) {
|
||||
printf("eglgears: show surface failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
printf("eglgears: make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (printInfo)
|
||||
{
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
reshape(width, height);
|
||||
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
run_gears(d, screen_surf, 5.0);
|
||||
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
223
progs/egl/eglinfo.c
Normal file
223
progs/egl/eglinfo.c
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* eglinfo - like glxinfo but for EGL
|
||||
*
|
||||
* Brian Paul
|
||||
* 11 March 2005
|
||||
*
|
||||
* Copyright (C) 2005 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_CONFIGS 1000
|
||||
#define MAX_MODES 1000
|
||||
#define MAX_SCREENS 10
|
||||
|
||||
/* These are X visual types, so if you're running eglinfo under
|
||||
* something not X, they probably don't make sense. */
|
||||
static const char *vnames[] = { "SG", "GS", "SC", "PC", "TC", "DC" };
|
||||
|
||||
/**
|
||||
* Print table of all available configurations.
|
||||
*/
|
||||
static void
|
||||
PrintConfigs(EGLDisplay d)
|
||||
{
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLint numConfigs, i;
|
||||
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
|
||||
printf("Configurations:\n");
|
||||
printf(" bf lv colorbuffer dp st ms vis cav bi renderable supported\n");
|
||||
printf(" id sz l r g b a th cl ns b id eat nd gl es es2 vg surfaces \n");
|
||||
printf("---------------------------------------------------------------------\n");
|
||||
for (i = 0; i < numConfigs; i++) {
|
||||
EGLint id, size, level;
|
||||
EGLint red, green, blue, alpha;
|
||||
EGLint depth, stencil;
|
||||
EGLint renderable, surfaces;
|
||||
EGLint vid, vtype, caveat, bindRgb, bindRgba;
|
||||
EGLint samples, sampleBuffers;
|
||||
char surfString[100] = "";
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level);
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_TYPE, &vtype);
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_CONFIG_CAVEAT, &caveat);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGB, &bindRgb);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &bindRgba);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_RENDERABLE_TYPE, &renderable);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces);
|
||||
|
||||
eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples);
|
||||
eglGetConfigAttrib(d, configs[i], EGL_SAMPLE_BUFFERS, &sampleBuffers);
|
||||
|
||||
if (surfaces & EGL_WINDOW_BIT)
|
||||
strcat(surfString, "win,");
|
||||
if (surfaces & EGL_PBUFFER_BIT)
|
||||
strcat(surfString, "pb,");
|
||||
if (surfaces & EGL_PIXMAP_BIT)
|
||||
strcat(surfString, "pix,");
|
||||
#ifdef EGL_MESA_screen_surface
|
||||
if (surfaces & EGL_SCREEN_BIT_MESA)
|
||||
strcat(surfString, "scrn,");
|
||||
#endif
|
||||
if (strlen(surfString) > 0)
|
||||
surfString[strlen(surfString) - 1] = 0;
|
||||
|
||||
printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x%s ",
|
||||
id, size, level,
|
||||
red, green, blue, alpha,
|
||||
depth, stencil,
|
||||
samples, sampleBuffers, vid, vtype < 6 ? vnames[vtype] : "--");
|
||||
printf(" %c %c %c %c %c %c %s\n",
|
||||
(caveat != EGL_NONE) ? 'y' : ' ',
|
||||
(bindRgba) ? 'a' : (bindRgb) ? 'y' : ' ',
|
||||
(renderable & EGL_OPENGL_BIT) ? 'y' : ' ',
|
||||
(renderable & EGL_OPENGL_ES_BIT) ? 'y' : ' ',
|
||||
(renderable & EGL_OPENGL_ES2_BIT) ? 'y' : ' ',
|
||||
(renderable & EGL_OPENVG_BIT) ? 'y' : ' ',
|
||||
surfString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print table of all available configurations.
|
||||
*/
|
||||
static void
|
||||
PrintModes(EGLDisplay d)
|
||||
{
|
||||
#ifdef EGL_MESA_screen_surface
|
||||
const char *extensions = eglQueryString(d, EGL_EXTENSIONS);
|
||||
if (strstr(extensions, "EGL_MESA_screen_surface")) {
|
||||
EGLScreenMESA screens[MAX_SCREENS];
|
||||
EGLint numScreens = 1, scrn;
|
||||
EGLModeMESA modes[MAX_MODES];
|
||||
|
||||
eglGetScreensMESA(d, screens, MAX_SCREENS, &numScreens);
|
||||
printf("Number of Screens: %d\n\n", numScreens);
|
||||
|
||||
for (scrn = 0; scrn < numScreens; scrn++) {
|
||||
EGLint numModes, i;
|
||||
|
||||
eglGetModesMESA(d, screens[scrn], modes, MAX_MODES, &numModes);
|
||||
|
||||
printf("Screen %d Modes:\n", scrn);
|
||||
printf(" id width height refresh name\n");
|
||||
printf("-----------------------------------------\n");
|
||||
for (i = 0; i < numModes; i++) {
|
||||
EGLint id, w, h, r;
|
||||
const char *str;
|
||||
eglGetModeAttribMESA(d, modes[i], EGL_MODE_ID_MESA, &id);
|
||||
eglGetModeAttribMESA(d, modes[i], EGL_WIDTH, &w);
|
||||
eglGetModeAttribMESA(d, modes[i], EGL_HEIGHT, &h);
|
||||
eglGetModeAttribMESA(d, modes[i], EGL_REFRESH_RATE_MESA, &r);
|
||||
str = eglQueryModeStringMESA(d, modes[i]);
|
||||
printf("0x%02x %5d %5d %.3f %s\n", id, w, h, r / 1000.0, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
PrintExtensions(EGLDisplay d)
|
||||
{
|
||||
const char *extensions, *p, *end, *next;
|
||||
int column;
|
||||
|
||||
printf("EGL extensions string:\n");
|
||||
|
||||
extensions = eglQueryString(d, EGL_EXTENSIONS);
|
||||
|
||||
column = 0;
|
||||
end = extensions + strlen(extensions);
|
||||
|
||||
for (p = extensions; p < end; p = next + 1) {
|
||||
next = strchr(p, ' ');
|
||||
if (next == NULL)
|
||||
next = end;
|
||||
|
||||
if (column > 0 && column + next - p + 1 > 70) {
|
||||
printf("\n");
|
||||
column = 0;
|
||||
}
|
||||
if (column == 0)
|
||||
printf(" ");
|
||||
else
|
||||
printf(" ");
|
||||
column += next - p + 1;
|
||||
|
||||
printf("%.*s", (int) (next - p), p);
|
||||
|
||||
p = next + 1;
|
||||
}
|
||||
|
||||
if (column > 0)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglinfo: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("EGL API version: %d.%d\n", maj, min);
|
||||
printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION));
|
||||
#ifdef EGL_VERSION_1_2
|
||||
printf("EGL client APIs: %s\n", eglQueryString(d, EGL_CLIENT_APIS));
|
||||
#endif
|
||||
|
||||
PrintExtensions(d);
|
||||
|
||||
PrintConfigs(d);
|
||||
|
||||
PrintModes(d);
|
||||
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
120
progs/egl/eglscreen.c
Normal file
120
progs/egl/eglscreen.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Stolen from eglgears
|
||||
*
|
||||
* Creates a surface and show that on the first screen
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#define MAX_CONFIGS 10
|
||||
#define MAX_MODES 100
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLSurface screen_surf;
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
EGLDisplay d;
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
EGLint chosenMode = 0;
|
||||
EGLint width = 0, height = 0;
|
||||
|
||||
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("eglscreen: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("eglscreen: EGL version = %d.%d\n", maj, min);
|
||||
printf("eglscreen: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
/* XXX use ChooseConfig */
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
|
||||
if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) {
|
||||
printf("eglscreen: eglGetModesMESA failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print list of modes, and find the one to use */
|
||||
printf("eglscreen: Found %d modes:\n", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
EGLint w, h;
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
|
||||
printf("%3d: %d x %d\n", i, w, h);
|
||||
if (w > width && h > height) {
|
||||
width = w;
|
||||
height = h;
|
||||
chosenMode = i;
|
||||
}
|
||||
}
|
||||
printf("eglscreen: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
|
||||
/* build up screenAttribs array */
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
screenAttribs[i++] = width;
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
screenAttribs[i++] = height;
|
||||
screenAttribs[i++] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("eglscreen: Failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]);
|
||||
if (!b) {
|
||||
printf("eglscreen: Show surface failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
usleep(5000000);
|
||||
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
264
progs/egl/egltri.c
Normal file
264
progs/egl/egltri.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 2008 Jakob Bornecrantz All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This program is based on eglgears and xegl_tri.
|
||||
* Remixed by Jakob Bornecrantz
|
||||
*
|
||||
* No command line options.
|
||||
* Program runs for 5 seconds then exits, outputing framerate to console
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#define MAX_CONFIGS 10
|
||||
#define MAX_MODES 100
|
||||
|
||||
|
||||
/* XXX this probably isn't very portable */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* return current time (in seconds) */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef __VMS
|
||||
(void) gettimeofday(&tv, NULL );
|
||||
#else
|
||||
struct timezone tz;
|
||||
(void) gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
static void draw()
|
||||
{
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat colors[3][3] = {
|
||||
{ 1, 0, 0 },
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 0, 1 }
|
||||
};
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
{
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(3, GL_FLOAT, 0, colors);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -10.0);
|
||||
}
|
||||
|
||||
static void run(EGLDisplay dpy, EGLSurface surf, int ttr)
|
||||
{
|
||||
double st = current_time();
|
||||
double ct = st;
|
||||
int frames = 0;
|
||||
GLfloat seconds, fps;
|
||||
|
||||
while (ct - st < ttr)
|
||||
{
|
||||
ct = current_time();
|
||||
|
||||
draw();
|
||||
|
||||
eglSwapBuffers(dpy, surf);
|
||||
|
||||
frames++;
|
||||
}
|
||||
|
||||
seconds = ct - st;
|
||||
fps = frames / seconds;
|
||||
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int maj, min;
|
||||
EGLContext ctx;
|
||||
EGLSurface screen_surf;
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
EGLDisplay d;
|
||||
EGLint screenAttribs[10];
|
||||
EGLModeMESA mode[MAX_MODES];
|
||||
EGLScreenMESA screen;
|
||||
EGLint count, chosenMode = 0;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint width = 0, height = 0;
|
||||
|
||||
/* parse cmd line args */
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-info") == 0)
|
||||
{
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else
|
||||
printf("Warning: unknown parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
/* DBR : Create EGL context/surface etc */
|
||||
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &maj, &min)) {
|
||||
printf("egltri: eglInitialize failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("egltri: EGL version = %d.%d\n", maj, min);
|
||||
printf("egltri: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
/* XXX use ChooseConfig */
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
|
||||
if (!eglGetModesMESA(d, screen, mode, MAX_MODES, &count) || count == 0) {
|
||||
printf("egltri: eglGetModesMESA failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print list of modes, and find the one to use */
|
||||
printf("egltri: Found %d modes:\n", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
EGLint w, h;
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_WIDTH, &w);
|
||||
eglGetModeAttribMESA(d, mode[i], EGL_HEIGHT, &h);
|
||||
printf("%3d: %d x %d\n", i, w, h);
|
||||
if (w > width && h > height) {
|
||||
width = w;
|
||||
height = h;
|
||||
chosenMode = i;
|
||||
}
|
||||
}
|
||||
printf("egltri: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("egltri: failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* build up screenAttribs array */
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
screenAttribs[i++] = width;
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
screenAttribs[i++] = height;
|
||||
screenAttribs[i++] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("egltri: failed to create screen surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglShowScreenSurfaceMESA(d, screen, screen_surf, mode[chosenMode]);
|
||||
if (!b) {
|
||||
printf("egltri: show surface failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, screen_surf, screen_surf, ctx);
|
||||
if (!b) {
|
||||
printf("egltri: make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (printInfo)
|
||||
{
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
reshape(width, height);
|
||||
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
run(d, screen_surf, 5.0);
|
||||
|
||||
eglDestroySurface(d, screen_surf);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
451
progs/egl/peglgears.c
Normal file
451
progs/egl/peglgears.c
Normal file
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a port of the infamous "glxgears" demo to straight EGL
|
||||
* Port by Dane Rushton 10 July 2005
|
||||
*
|
||||
* No command line options.
|
||||
* Program runs for 5 seconds then exits, outputing framerate to console
|
||||
*/
|
||||
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#define MAX_CONFIGS 10
|
||||
#define MAX_MODES 100
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
|
||||
/* XXX this probably isn't very portable */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* return current time (in seconds) */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef __VMS
|
||||
(void) gettimeofday(&tv, NULL );
|
||||
#else
|
||||
struct timezone tz;
|
||||
(void) gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
#else /*BENCHMARK*/
|
||||
|
||||
/* dummy */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
/* update this function for other platforms! */
|
||||
static double t = 0.0;
|
||||
static int warn = 1;
|
||||
if (warn) {
|
||||
fprintf(stderr, "Warning: current_time() not implemented!!\n");
|
||||
warn = 0;
|
||||
}
|
||||
return t += 1.0;
|
||||
}
|
||||
|
||||
#endif /*BENCHMARK*/
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
|
||||
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
||||
static GLint gear1, gear2, gear3;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
#if 0
|
||||
static GLfloat eyesep = 5.0; /* Eye separation. */
|
||||
static GLfloat fix_point = 40.0; /* Fixation point distance. */
|
||||
static GLfloat left, right, asp; /* Stereo frustum params. */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Draw a gear wheel. You'll probably want to call this function when
|
||||
* building a display list since we do a lot of trig here.
|
||||
*
|
||||
* Input: inner_radius - radius of hole at center
|
||||
* outer_radius - radius at center of teeth
|
||||
* width - width of gear
|
||||
* teeth - number of teeth
|
||||
* tooth_depth - depth of tooth
|
||||
*/
|
||||
static void
|
||||
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth)
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth / 2.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1.0, 0.0, 0.0);
|
||||
glRotatef(view_roty, 0.0, 1.0, 0.0);
|
||||
glRotatef(view_rotz, 0.0, 0.0, 1.0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(angle, 0.0, 0.0, 1.0);
|
||||
glCallList(gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
|
||||
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
|
||||
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* make the gears */
|
||||
gear1 = glGenLists(1);
|
||||
glNewList(gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear2 = glGenLists(1);
|
||||
glNewList(gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear3 = glGenLists(1);
|
||||
glNewList(gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
|
||||
{
|
||||
double st = current_time();
|
||||
double ct = st;
|
||||
int frames = 0;
|
||||
GLfloat seconds, fps;
|
||||
|
||||
while (ct - st < ttr)
|
||||
{
|
||||
double tt = current_time();
|
||||
double dt = tt - ct;
|
||||
ct = tt;
|
||||
|
||||
/* advance rotation for next frame */
|
||||
angle += 70.0 * dt; /* 70 degrees per second */
|
||||
if (angle > 3600.0)
|
||||
angle -= 3600.0;
|
||||
|
||||
draw();
|
||||
|
||||
eglSwapBuffers(dpy, surf);
|
||||
|
||||
|
||||
frames++;
|
||||
}
|
||||
|
||||
seconds = ct - st;
|
||||
fps = frames / seconds;
|
||||
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int major, minor;
|
||||
EGLContext ctx;
|
||||
EGLSurface surface;
|
||||
EGLConfig configs[MAX_CONFIGS];
|
||||
EGLint numConfigs, i;
|
||||
EGLBoolean b;
|
||||
EGLDisplay d;
|
||||
EGLint screenAttribs[10];
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint width = 300, height = 300;
|
||||
|
||||
/* parse cmd line args */
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-info") == 0)
|
||||
{
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else
|
||||
printf("Warning: unknown parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
/* DBR : Create EGL context/surface etc */
|
||||
d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
||||
if (!eglInitialize(d, &major, &minor)) {
|
||||
printf("peglgears: eglInitialize failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("peglgears: EGL version = %d.%d\n", major, minor);
|
||||
printf("peglgears: EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR));
|
||||
|
||||
eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("peglgears: failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* build up screenAttribs array */
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
screenAttribs[i++] = width;
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
screenAttribs[i++] = height;
|
||||
screenAttribs[i++] = EGL_NONE;
|
||||
|
||||
surface = eglCreatePbufferSurface(d, configs[0], screenAttribs);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
printf("peglgears: failed to create pbuffer surface\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
b = eglMakeCurrent(d, surface, surface, ctx);
|
||||
if (!b) {
|
||||
printf("peglgears: make current failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (printInfo)
|
||||
{
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
reshape(width, height);
|
||||
|
||||
glDrawBuffer( GL_BACK );
|
||||
|
||||
run_gears(d, surface, 5.0);
|
||||
|
||||
eglDestroySurface(d, surface);
|
||||
eglDestroyContext(d, ctx);
|
||||
eglTerminate(d);
|
||||
|
||||
return 0;
|
||||
}
|
361
progs/egl/xegl_tri.c
Normal file
361
progs/egl/xegl_tri.c
Normal file
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Draw a triangle with X/EGL.
|
||||
* Brian Paul
|
||||
* 3 June 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GL/gl.h> /* using full OpenGL for now */
|
||||
#include <GLES/egl.h>
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat colors[3][3] = {
|
||||
{ 1, 0, 0 },
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 0, 1 }
|
||||
};
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
{
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(3, GL_FLOAT, 0, colors);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -10.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: glXCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"xegl_tri", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
954
progs/egl/xeglgears.c
Normal file
954
progs/egl/xeglgears.c
Normal file
@@ -0,0 +1,954 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ported to X/EGL/GLES. XXX Actually, uses full OpenGL ATM.
|
||||
* Brian Paul
|
||||
* 30 May 2008
|
||||
*/
|
||||
|
||||
/*
|
||||
* Command line options:
|
||||
* -info print GL implementation information
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#define EGL_EGLEXT_PROTOTYPES
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
|
||||
/* XXX this probably isn't very portable */
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* return current time (in seconds) */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef __VMS
|
||||
(void) gettimeofday(&tv, NULL );
|
||||
#else
|
||||
struct timezone tz;
|
||||
(void) gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
#else /*BENCHMARK*/
|
||||
|
||||
/* dummy */
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
/* update this function for other platforms! */
|
||||
static double t = 0.0;
|
||||
static int warn = 1;
|
||||
if (warn) {
|
||||
fprintf(stderr, "Warning: current_time() not implemented!!\n");
|
||||
warn = 0;
|
||||
}
|
||||
return t += 1.0;
|
||||
}
|
||||
|
||||
#endif /*BENCHMARK*/
|
||||
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
|
||||
static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
|
||||
static GLint gear1, gear2, gear3;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
/*
|
||||
*
|
||||
* Draw a gear wheel. You'll probably want to call this function when
|
||||
* building a display list since we do a lot of trig here.
|
||||
*
|
||||
* Input: inner_radius - radius of hole at center
|
||||
* outer_radius - radius at center of teeth
|
||||
* width - width of gear
|
||||
* teeth - number of teeth
|
||||
* tooth_depth - depth of tooth
|
||||
*/
|
||||
static void
|
||||
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth)
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth / 2.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClearColor(0.2, 0.2, 0.2, 0.2);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1.0, 0.0, 0.0);
|
||||
glRotatef(view_roty, 0.0, 1.0, 0.0);
|
||||
glRotatef(view_rotz, 0.0, 0.0, 1.0);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.0, -2.0, 0.0);
|
||||
glRotatef(angle, 0.0, 0.0, 1.0);
|
||||
glCallList(gear1);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(3.1, -2.0, 0.0);
|
||||
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear2);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-3.1, 4.2, 0.0);
|
||||
glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear3);
|
||||
glPopMatrix();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
|
||||
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
|
||||
static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* make the gears */
|
||||
gear1 = glGenLists(1);
|
||||
glNewList(gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear2 = glGenLists(1);
|
||||
glNewList(gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(0.5, 2.0, 2.0, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
gear3 = glGenLists(1);
|
||||
glNewList(gear3, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
gear(1.3, 2.0, 0.5, 10, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
}
|
||||
|
||||
|
||||
struct egl_manager {
|
||||
EGLNativeDisplayType xdpy;
|
||||
EGLNativeWindowType xwin;
|
||||
EGLNativePixmapType xpix;
|
||||
|
||||
EGLDisplay dpy;
|
||||
EGLConfig conf;
|
||||
EGLContext ctx;
|
||||
|
||||
EGLSurface win;
|
||||
EGLSurface pix;
|
||||
EGLSurface pbuf;
|
||||
EGLImageKHR image;
|
||||
|
||||
EGLBoolean verbose;
|
||||
EGLint major, minor;
|
||||
|
||||
GC gc;
|
||||
GLuint fbo;
|
||||
};
|
||||
|
||||
static struct egl_manager *
|
||||
egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list,
|
||||
EGLBoolean verbose)
|
||||
{
|
||||
struct egl_manager *eman;
|
||||
const char *ver;
|
||||
EGLint num_conf;
|
||||
|
||||
eman = calloc(1, sizeof(*eman));
|
||||
if (!eman)
|
||||
return NULL;
|
||||
|
||||
eman->verbose = verbose;
|
||||
eman->xdpy = xdpy;
|
||||
|
||||
eman->dpy = eglGetDisplay(eman->xdpy);
|
||||
if (eman->dpy == EGL_NO_DISPLAY) {
|
||||
printf("eglGetDisplay() failed\n");
|
||||
free(eman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) {
|
||||
printf("eglInitialize() failed\n");
|
||||
free(eman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ver = eglQueryString(eman->dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", ver);
|
||||
|
||||
if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) ||
|
||||
!num_conf) {
|
||||
printf("eglChooseConfig() failed\n");
|
||||
eglTerminate(eman->dpy);
|
||||
free(eman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL);
|
||||
if (eman->ctx == EGL_NO_CONTEXT) {
|
||||
printf("eglCreateContext() failed\n");
|
||||
eglTerminate(eman->dpy);
|
||||
free(eman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return eman;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
egl_manager_create_window(struct egl_manager *eman, const char *name,
|
||||
EGLint w, EGLint h, EGLBoolean need_surface,
|
||||
EGLBoolean fullscreen, const EGLint *attrib_list)
|
||||
{
|
||||
XVisualInfo vinfo_template, *vinfo = NULL;
|
||||
EGLint val, num_vinfo;
|
||||
Window root;
|
||||
XSetWindowAttributes attrs;
|
||||
unsigned long mask;
|
||||
EGLint x = 0, y = 0;
|
||||
|
||||
if (!eglGetConfigAttrib(eman->dpy, eman->conf,
|
||||
EGL_NATIVE_VISUAL_ID, &val)) {
|
||||
printf("eglGetConfigAttrib() failed\n");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
if (val) {
|
||||
vinfo_template.visualid = (VisualID) val;
|
||||
vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo);
|
||||
}
|
||||
/* try harder if window surface is not needed */
|
||||
if (!vinfo && !need_surface &&
|
||||
eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) {
|
||||
if (val == 32)
|
||||
val = 24;
|
||||
vinfo_template.depth = val;
|
||||
vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo);
|
||||
}
|
||||
|
||||
if (!vinfo) {
|
||||
printf("XGetVisualInfo() failed\n");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
root = DefaultRootWindow(eman->xdpy);
|
||||
if (fullscreen) {
|
||||
x = y = 0;
|
||||
w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy));
|
||||
h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy));
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attrs.background_pixel = 0;
|
||||
attrs.border_pixel = 0;
|
||||
attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone);
|
||||
attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
attrs.override_redirect = fullscreen;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
|
||||
|
||||
eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h,
|
||||
0, vinfo->depth, InputOutput,
|
||||
vinfo->visual, mask, &attrs);
|
||||
XFree(vinfo);
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = w;
|
||||
sizehints.height = h;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(eman->xdpy, eman->xwin, &sizehints);
|
||||
XSetStandardProperties(eman->xdpy, eman->xwin, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
if (need_surface) {
|
||||
eman->win = eglCreateWindowSurface(eman->dpy, eman->conf,
|
||||
eman->xwin, attrib_list);
|
||||
if (eman->win == EGL_NO_SURFACE) {
|
||||
printf("eglCreateWindowSurface() failed\n");
|
||||
XDestroyWindow(eman->xdpy, eman->xwin);
|
||||
eman->xwin = None;
|
||||
return EGL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
eman->gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL);
|
||||
|
||||
XMapWindow(eman->xdpy, eman->xwin);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin,
|
||||
EGLBoolean need_surface, const EGLint *attrib_list)
|
||||
{
|
||||
XWindowAttributes attrs;
|
||||
|
||||
if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) {
|
||||
printf("XGetWindowAttributes() failed\n");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
eman->xpix = XCreatePixmap(eman->xdpy, xwin,
|
||||
attrs.width, attrs.height, attrs.depth);
|
||||
|
||||
if (need_surface) {
|
||||
eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf,
|
||||
eman->xpix, attrib_list);
|
||||
if (eman->pix == EGL_NO_SURFACE) {
|
||||
printf("eglCreatePixmapSurface() failed\n");
|
||||
XFreePixmap(eman->xdpy, eman->xpix);
|
||||
eman->xpix = None;
|
||||
return EGL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list)
|
||||
{
|
||||
eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list);
|
||||
if (eman->pbuf == EGL_NO_SURFACE) {
|
||||
printf("eglCreatePbufferSurface() failed\n");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
egl_manager_destroy(struct egl_manager *eman)
|
||||
{
|
||||
eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglTerminate(eman->dpy);
|
||||
|
||||
if (eman->xwin != None)
|
||||
XDestroyWindow(eman->xdpy, eman->xwin);
|
||||
if (eman->xpix != None)
|
||||
XFreePixmap(eman->xdpy, eman->xpix);
|
||||
|
||||
XFreeGC(eman->xdpy, eman->gc);
|
||||
|
||||
free(eman);
|
||||
}
|
||||
|
||||
enum {
|
||||
GEARS_WINDOW,
|
||||
GEARS_PIXMAP,
|
||||
GEARS_PIXMAP_TEXTURE,
|
||||
GEARS_PBUFFER,
|
||||
GEARS_PBUFFER_TEXTURE,
|
||||
GEARS_RENDERBUFFER
|
||||
};
|
||||
|
||||
static void
|
||||
texture_gears(struct egl_manager *eman, int surface_type)
|
||||
{
|
||||
static const GLint verts[12] =
|
||||
{ -5, -6, -10, 5, -6, -10, -5, 4, 10, 5, 4, 10 };
|
||||
static const GLint tex_coords[8] = { 0, 0, 1, 0, 0, 1, 1, 1 };
|
||||
|
||||
eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(3, GL_INT, 0, verts);
|
||||
glTexCoordPointer(2, GL_INT, 0, tex_coords);
|
||||
|
||||
if (surface_type == GEARS_PBUFFER_TEXTURE)
|
||||
eglBindTexImage(eman->dpy, eman->pbuf, EGL_BACK_BUFFER);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
if (surface_type == GEARS_PBUFFER_TEXTURE)
|
||||
eglReleaseTexImage(eman->dpy, eman->pbuf, EGL_BACK_BUFFER);
|
||||
|
||||
eglSwapBuffers(eman->dpy, eman->win);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_gears(struct egl_manager *eman,
|
||||
EGLint tile_w, EGLint tile_h, EGLint w, EGLint h)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
eglWaitClient();
|
||||
|
||||
for (x = 0; x < w; x += tile_w) {
|
||||
for (y = 0; y < h; y += tile_h) {
|
||||
|
||||
XCopyArea(eman->xdpy, eman->xpix, eman->xwin, eman->gc,
|
||||
0, 0, tile_w, tile_h, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h)
|
||||
{
|
||||
int window_w = w, window_h = h;
|
||||
|
||||
if (surface_type == EGL_PBUFFER_BIT)
|
||||
printf("there will be no screen update if "
|
||||
"eglCopyBuffers() is not implemented\n");
|
||||
|
||||
while (1) {
|
||||
while (XPending(eman->xdpy) > 0) {
|
||||
XEvent event;
|
||||
XNextEvent(eman->xdpy, &event);
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
/* we'll redraw below */
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
window_w = event.xconfigure.width;
|
||||
window_h = event.xconfigure.height;
|
||||
if (surface_type == EGL_WINDOW_BIT)
|
||||
reshape(window_w, window_h);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
static int frames = 0;
|
||||
static double tRot0 = -1.0, tRate0 = -1.0;
|
||||
double dt, t = current_time();
|
||||
if (tRot0 < 0.0)
|
||||
tRot0 = t;
|
||||
dt = t - tRot0;
|
||||
tRot0 = t;
|
||||
|
||||
/* advance rotation for next frame */
|
||||
angle += 70.0 * dt; /* 70 degrees per second */
|
||||
if (angle > 3600.0)
|
||||
angle -= 3600.0;
|
||||
|
||||
switch (surface_type) {
|
||||
case GEARS_WINDOW:
|
||||
draw();
|
||||
eglSwapBuffers(eman->dpy, eman->win);
|
||||
break;
|
||||
|
||||
case GEARS_PBUFFER:
|
||||
draw();
|
||||
if (!eglCopyBuffers(eman->dpy, eman->pbuf, eman->xpix))
|
||||
break;
|
||||
copy_gears(eman, w, h, window_w, window_h);
|
||||
break;
|
||||
|
||||
case GEARS_PBUFFER_TEXTURE:
|
||||
eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
|
||||
draw();
|
||||
texture_gears(eman, surface_type);
|
||||
break;
|
||||
|
||||
case GEARS_PIXMAP:
|
||||
draw();
|
||||
copy_gears(eman, w, h, window_w, window_h);
|
||||
break;
|
||||
|
||||
case GEARS_PIXMAP_TEXTURE:
|
||||
eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
|
||||
draw();
|
||||
texture_gears(eman, surface_type);
|
||||
break;
|
||||
|
||||
case GEARS_RENDERBUFFER:
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, eman->fbo);
|
||||
draw();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
texture_gears(eman, surface_type);
|
||||
break;
|
||||
}
|
||||
|
||||
frames++;
|
||||
|
||||
if (tRate0 < 0.0)
|
||||
tRate0 = t;
|
||||
if (t - tRate0 >= 5.0) {
|
||||
GLfloat seconds = t - tRate0;
|
||||
GLfloat fps = frames / seconds;
|
||||
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
|
||||
fps);
|
||||
tRate0 = t;
|
||||
frames = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -fullscreen run in fullscreen mode\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
printf(" -pixmap use pixmap surface\n");
|
||||
printf(" -pixmap-texture use pixmap surface and texture using EGLImage\n");
|
||||
printf(" -pbuffer use pbuffer surface and eglCopyBuffers\n");
|
||||
printf(" -pbuffer-texture use pbuffer surface and eglBindTexImage\n");
|
||||
printf(" -renderbuffer renderbuffer as EGLImage and bind as texture from\n");
|
||||
}
|
||||
|
||||
static const char *names[] = {
|
||||
"window",
|
||||
"pixmap",
|
||||
"pixmap_texture",
|
||||
"pbuffer",
|
||||
"pbuffer_texture",
|
||||
"renderbuffer"
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
char *dpyName = NULL;
|
||||
struct egl_manager *eman;
|
||||
EGLint attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, /* may be changed later */
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
char win_title[] = "xeglgears (window/pixmap/pbuffer)";
|
||||
EGLint surface_type = GEARS_WINDOW;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
GLboolean fullscreen = GL_FALSE;
|
||||
EGLBoolean ret;
|
||||
GLuint texture, color_rb, depth_rb;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-fullscreen") == 0) {
|
||||
fullscreen = GL_TRUE;
|
||||
}
|
||||
else if (strcmp(argv[i], "-pixmap") == 0) {
|
||||
surface_type = GEARS_PIXMAP;
|
||||
attribs[1] = EGL_PIXMAP_BIT;
|
||||
}
|
||||
else if (strcmp(argv[i], "-pixmap-texture") == 0) {
|
||||
surface_type = GEARS_PIXMAP_TEXTURE;
|
||||
attribs[1] = EGL_PIXMAP_BIT;
|
||||
}
|
||||
else if (strcmp(argv[i], "-pbuffer") == 0) {
|
||||
surface_type = GEARS_PBUFFER;
|
||||
attribs[1] = EGL_PBUFFER_BIT;
|
||||
}
|
||||
else if (strcmp(argv[i], "-pbuffer-texture") == 0) {
|
||||
surface_type = GEARS_PBUFFER_TEXTURE;
|
||||
attribs[1] = EGL_PBUFFER_BIT;
|
||||
}
|
||||
else if (strcmp(argv[i], "-renderbuffer") == 0) {
|
||||
surface_type = GEARS_RENDERBUFFER;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
eman = egl_manager_new(x_dpy, attribs, printInfo);
|
||||
if (!eman) {
|
||||
XCloseDisplay(x_dpy);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(win_title, sizeof(win_title),
|
||||
"xeglgears (%s)", names[surface_type]);
|
||||
|
||||
ret = egl_manager_create_window(eman, win_title, winWidth, winHeight,
|
||||
EGL_TRUE, fullscreen, NULL);
|
||||
if (!ret)
|
||||
return -1;
|
||||
|
||||
/* create surface(s) */
|
||||
switch (surface_type) {
|
||||
case GEARS_WINDOW:
|
||||
if (ret)
|
||||
ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
|
||||
break;
|
||||
case GEARS_PIXMAP:
|
||||
case GEARS_PIXMAP_TEXTURE:
|
||||
ret = egl_manager_create_pixmap(eman, eman->xwin, EGL_TRUE, NULL);
|
||||
if (surface_type == GEARS_PIXMAP_TEXTURE)
|
||||
eman->image = eglCreateImageKHR (eman->dpy, eman->ctx,
|
||||
EGL_NATIVE_PIXMAP_KHR,
|
||||
(EGLClientBuffer) eman->xpix, NULL);
|
||||
if (ret)
|
||||
ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx);
|
||||
break;
|
||||
case GEARS_PBUFFER:
|
||||
case GEARS_PBUFFER_TEXTURE:
|
||||
{
|
||||
EGLint pbuf_attribs[] = {
|
||||
EGL_WIDTH, winWidth,
|
||||
EGL_HEIGHT, winHeight,
|
||||
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
|
||||
EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
|
||||
EGL_NONE
|
||||
};
|
||||
ret = (egl_manager_create_pixmap(eman, eman->xwin,
|
||||
EGL_TRUE, NULL) &&
|
||||
egl_manager_create_pbuffer(eman, pbuf_attribs));
|
||||
if (ret)
|
||||
ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GEARS_RENDERBUFFER:
|
||||
ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx);
|
||||
if (ret == EGL_FALSE)
|
||||
printf("failed to make context current\n");
|
||||
|
||||
glGenFramebuffers(1, &eman->fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, eman->fbo);
|
||||
|
||||
glGenRenderbuffers(1, &color_rb);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER_EXT, color_rb);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, winWidth, winHeight);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_RENDERBUFFER_EXT,
|
||||
color_rb);
|
||||
|
||||
eman->image = eglCreateImageKHR(eman->dpy, eman->ctx,
|
||||
EGL_GL_RENDERBUFFER_KHR,
|
||||
(EGLClientBuffer) color_rb, NULL);
|
||||
|
||||
glGenRenderbuffers(1, &depth_rb);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth_rb);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER_EXT,
|
||||
GL_DEPTH_COMPONENT, winWidth, winHeight);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT,
|
||||
depth_rb);
|
||||
|
||||
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
printf("framebuffer not complete\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = EGL_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (surface_type) {
|
||||
case GEARS_PIXMAP_TEXTURE:
|
||||
case GEARS_RENDERBUFFER:
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eman->image);
|
||||
break;
|
||||
case GEARS_PBUFFER_TEXTURE:
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
egl_manager_destroy(eman);
|
||||
XCloseDisplay(x_dpy);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(eman, surface_type, winWidth, winHeight);
|
||||
|
||||
glDeleteLists(gear1, 1);
|
||||
glDeleteLists(gear2, 1);
|
||||
glDeleteLists(gear3, 1);
|
||||
|
||||
egl_manager_destroy(eman);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
775
progs/egl/xeglthreads.c
Normal file
775
progs/egl/xeglthreads.c
Normal file
@@ -0,0 +1,775 @@
|
||||
/*
|
||||
* Copyright (C) 2000 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Ported to EGL by Chia-I Wu <olvaffe@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This program tests EGL thread safety.
|
||||
* Command line options:
|
||||
* -p Open a display connection for each thread
|
||||
* -l Enable application-side locking
|
||||
* -n <num threads> Number of threads to create (default is 2)
|
||||
* -display <display name> Specify X display (default is $DISPLAY)
|
||||
* -t Use texture mapping
|
||||
*
|
||||
* Brian Paul 20 July 2000
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Notes:
|
||||
* - Each thread gets its own EGL context.
|
||||
*
|
||||
* - The EGL contexts share texture objects.
|
||||
*
|
||||
* - When 't' is pressed to update the texture image, the window/thread which
|
||||
* has input focus is signalled to change the texture. The other threads
|
||||
* should see the updated texture the next time they call glBindTexture.
|
||||
*/
|
||||
|
||||
|
||||
#if defined(PTHREADS) /* defined by Mesa on Linux and other platforms */
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
/*
|
||||
* Each window/thread/context:
|
||||
*/
|
||||
struct winthread {
|
||||
Display *Dpy;
|
||||
int Index;
|
||||
pthread_t Thread;
|
||||
Window Win;
|
||||
EGLDisplay Display;
|
||||
EGLContext Context;
|
||||
EGLSurface Surface;
|
||||
float Angle;
|
||||
int WinWidth, WinHeight;
|
||||
GLboolean NewSize;
|
||||
GLboolean Initialized;
|
||||
GLboolean MakeNewTexture;
|
||||
};
|
||||
|
||||
|
||||
#define MAX_WINTHREADS 100
|
||||
static struct winthread WinThreads[MAX_WINTHREADS];
|
||||
static int NumWinThreads = 0;
|
||||
static volatile GLboolean ExitFlag = GL_FALSE;
|
||||
|
||||
static GLboolean MultiDisplays = 0;
|
||||
static GLboolean Locking = 0;
|
||||
static GLboolean Texture = GL_FALSE;
|
||||
static GLuint TexObj = 12;
|
||||
static GLboolean Animate = GL_TRUE;
|
||||
|
||||
static pthread_mutex_t Mutex;
|
||||
static pthread_cond_t CondVar;
|
||||
static pthread_mutex_t CondMutex;
|
||||
|
||||
|
||||
static void
|
||||
Error(const char *msg)
|
||||
{
|
||||
fprintf(stderr, "Error: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
signal_redraw(void)
|
||||
{
|
||||
pthread_mutex_lock(&CondMutex);
|
||||
pthread_cond_broadcast(&CondVar);
|
||||
pthread_mutex_unlock(&CondMutex);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
MakeNewTexture(struct winthread *wt)
|
||||
{
|
||||
#define TEX_SIZE 128
|
||||
static float step = 0.0;
|
||||
GLfloat image[TEX_SIZE][TEX_SIZE][4];
|
||||
GLint width;
|
||||
int i, j;
|
||||
|
||||
for (j = 0; j < TEX_SIZE; j++) {
|
||||
for (i = 0; i < TEX_SIZE; i++) {
|
||||
float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE;
|
||||
float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE;
|
||||
float r = dt * dt + ds * ds + step;
|
||||
image[j][i][0] =
|
||||
image[j][i][1] =
|
||||
image[j][i][2] = 0.75 + 0.25 * cos(r);
|
||||
image[j][i][3] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
step += 0.5;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj);
|
||||
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
|
||||
if (width) {
|
||||
assert(width == TEX_SIZE);
|
||||
/* sub-tex replace */
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_SIZE, TEX_SIZE,
|
||||
GL_RGBA, GL_FLOAT, image);
|
||||
}
|
||||
else {
|
||||
/* create new */
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0,
|
||||
GL_RGBA, GL_FLOAT, image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* draw a colored cube */
|
||||
static void
|
||||
draw_object(void)
|
||||
{
|
||||
glPushMatrix();
|
||||
glScalef(0.75, 0.75, 0.75);
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
|
||||
if (Texture) {
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
/* -X */
|
||||
glColor3f(0, 1, 1);
|
||||
glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
|
||||
glTexCoord2f(1, 0); glVertex3f(-1, 1, -1);
|
||||
glTexCoord2f(1, 1); glVertex3f(-1, 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex3f(-1, -1, 1);
|
||||
|
||||
/* +X */
|
||||
glColor3f(1, 0, 0);
|
||||
glTexCoord2f(0, 0); glVertex3f(1, -1, -1);
|
||||
glTexCoord2f(1, 0); glVertex3f(1, 1, -1);
|
||||
glTexCoord2f(1, 1); glVertex3f(1, 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex3f(1, -1, 1);
|
||||
|
||||
/* -Y */
|
||||
glColor3f(1, 0, 1);
|
||||
glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
|
||||
glTexCoord2f(1, 0); glVertex3f( 1, -1, -1);
|
||||
glTexCoord2f(1, 1); glVertex3f( 1, -1, 1);
|
||||
glTexCoord2f(0, 1); glVertex3f(-1, -1, 1);
|
||||
|
||||
/* +Y */
|
||||
glColor3f(0, 1, 0);
|
||||
glTexCoord2f(0, 0); glVertex3f(-1, 1, -1);
|
||||
glTexCoord2f(1, 0); glVertex3f( 1, 1, -1);
|
||||
glTexCoord2f(1, 1); glVertex3f( 1, 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex3f(-1, 1, 1);
|
||||
|
||||
/* -Z */
|
||||
glColor3f(1, 1, 0);
|
||||
glTexCoord2f(0, 0); glVertex3f(-1, -1, -1);
|
||||
glTexCoord2f(1, 0); glVertex3f( 1, -1, -1);
|
||||
glTexCoord2f(1, 1); glVertex3f( 1, 1, -1);
|
||||
glTexCoord2f(0, 1); glVertex3f(-1, 1, -1);
|
||||
|
||||
/* +Y */
|
||||
glColor3f(0, 0, 1);
|
||||
glTexCoord2f(0, 0); glVertex3f(-1, -1, 1);
|
||||
glTexCoord2f(1, 0); glVertex3f( 1, -1, 1);
|
||||
glTexCoord2f(1, 1); glVertex3f( 1, 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex3f(-1, 1, 1);
|
||||
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* signal resize of given window */
|
||||
static void
|
||||
resize(struct winthread *wt, int w, int h)
|
||||
{
|
||||
wt->NewSize = GL_TRUE;
|
||||
wt->WinWidth = w;
|
||||
wt->WinHeight = h;
|
||||
if (!Animate)
|
||||
signal_redraw();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We have an instance of this for each thread.
|
||||
*/
|
||||
static void
|
||||
draw_loop(struct winthread *wt)
|
||||
{
|
||||
while (!ExitFlag) {
|
||||
|
||||
if (Locking)
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
if (!wt->Initialized) {
|
||||
eglMakeCurrent(wt->Display, wt->Surface, wt->Surface, wt->Context);
|
||||
printf("xeglthreads: %d: GL_RENDERER = %s\n", wt->Index,
|
||||
(char *) glGetString(GL_RENDERER));
|
||||
if (Texture /*&& wt->Index == 0*/) {
|
||||
MakeNewTexture(wt);
|
||||
}
|
||||
wt->Initialized = GL_TRUE;
|
||||
}
|
||||
|
||||
if (Locking)
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
if (eglGetCurrentContext() != wt->Context) {
|
||||
printf("xeglthreads: current context %p != %p\n",
|
||||
eglGetCurrentContext(), wt->Context);
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
if (wt->NewSize) {
|
||||
GLfloat w = (float) wt->WinWidth / (float) wt->WinHeight;
|
||||
glViewport(0, 0, wt->WinWidth, wt->WinHeight);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-w, w, -1.0, 1.0, 1.5, 10);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0, 0, -2.5);
|
||||
wt->NewSize = GL_FALSE;
|
||||
}
|
||||
|
||||
if (wt->MakeNewTexture) {
|
||||
MakeNewTexture(wt);
|
||||
wt->MakeNewTexture = GL_FALSE;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(wt->Angle, 0, 1, 0);
|
||||
glRotatef(wt->Angle, 1, 0, 0);
|
||||
glScalef(0.7, 0.7, 0.7);
|
||||
draw_object();
|
||||
glPopMatrix();
|
||||
|
||||
if (Locking)
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
eglSwapBuffers(wt->Display, wt->Surface);
|
||||
|
||||
if (Locking)
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
|
||||
if (Animate) {
|
||||
usleep(5000);
|
||||
}
|
||||
else {
|
||||
/* wait for signal to draw */
|
||||
pthread_mutex_lock(&CondMutex);
|
||||
pthread_cond_wait(&CondVar, &CondMutex);
|
||||
pthread_mutex_unlock(&CondMutex);
|
||||
}
|
||||
wt->Angle += 1.0;
|
||||
}
|
||||
eglMakeCurrent(wt->Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
keypress(XEvent *event, struct winthread *wt)
|
||||
{
|
||||
char buf[100];
|
||||
KeySym keySym;
|
||||
XComposeStatus stat;
|
||||
|
||||
XLookupString(&event->xkey, buf, sizeof(buf), &keySym, &stat);
|
||||
|
||||
switch (keySym) {
|
||||
case XK_Escape:
|
||||
/* tell all threads to exit */
|
||||
if (!Animate) {
|
||||
signal_redraw();
|
||||
}
|
||||
ExitFlag = GL_TRUE;
|
||||
/*printf("exit draw_loop %d\n", wt->Index);*/
|
||||
return;
|
||||
case XK_t:
|
||||
case XK_T:
|
||||
if (Texture) {
|
||||
wt->MakeNewTexture = GL_TRUE;
|
||||
if (!Animate)
|
||||
signal_redraw();
|
||||
}
|
||||
break;
|
||||
case XK_a:
|
||||
case XK_A:
|
||||
Animate = !Animate;
|
||||
if (Animate) /* yes, prev Animate state! */
|
||||
signal_redraw();
|
||||
break;
|
||||
case XK_s:
|
||||
case XK_S:
|
||||
if (!Animate)
|
||||
signal_redraw();
|
||||
break;
|
||||
default:
|
||||
; /* nop */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The main process thread runs this loop.
|
||||
* Single display connection for all threads.
|
||||
*/
|
||||
static void
|
||||
event_loop(Display *dpy)
|
||||
{
|
||||
XEvent event;
|
||||
int i;
|
||||
|
||||
assert(!MultiDisplays);
|
||||
|
||||
while (!ExitFlag) {
|
||||
|
||||
if (Locking) {
|
||||
while (1) {
|
||||
int k;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
k = XPending(dpy);
|
||||
if (k) {
|
||||
XNextEvent(dpy, &event);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
usleep(5000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
XNextEvent(dpy, &event);
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
case ConfigureNotify:
|
||||
/* Find winthread for this event's window */
|
||||
for (i = 0; i < NumWinThreads; i++) {
|
||||
struct winthread *wt = &WinThreads[i];
|
||||
if (event.xconfigure.window == wt->Win) {
|
||||
resize(wt, event.xconfigure.width,
|
||||
event.xconfigure.height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
for (i = 0; i < NumWinThreads; i++) {
|
||||
struct winthread *wt = &WinThreads[i];
|
||||
if (event.xkey.window == wt->Win) {
|
||||
keypress(&event, wt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/*no-op*/ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Separate display connection for each thread.
|
||||
*/
|
||||
static void
|
||||
event_loop_multi(void)
|
||||
{
|
||||
XEvent event;
|
||||
int w = 0;
|
||||
|
||||
assert(MultiDisplays);
|
||||
|
||||
while (!ExitFlag) {
|
||||
struct winthread *wt = &WinThreads[w];
|
||||
if (XPending(wt->Dpy)) {
|
||||
XNextEvent(wt->Dpy, &event);
|
||||
switch (event.type) {
|
||||
case ConfigureNotify:
|
||||
resize(wt, event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
keypress(&event, wt);
|
||||
break;
|
||||
default:
|
||||
; /* nop */
|
||||
}
|
||||
}
|
||||
w = (w + 1) % NumWinThreads;
|
||||
usleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* we'll call this once for each thread, before the threads are created.
|
||||
*/
|
||||
static void
|
||||
create_window(struct winthread *wt, EGLContext shareCtx)
|
||||
{
|
||||
Window win;
|
||||
EGLContext ctx;
|
||||
EGLSurface surf;
|
||||
EGLint attribs[] = { EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE };
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
XVisualInfo *visinfo, visTemplate;
|
||||
int num_visuals;
|
||||
int width = 160, height = 160;
|
||||
int xpos = (wt->Index % 8) * (width + 10);
|
||||
int ypos = (wt->Index / 8) * (width + 20);
|
||||
|
||||
scrnum = DefaultScreen(wt->Dpy);
|
||||
root = RootWindow(wt->Dpy, scrnum);
|
||||
|
||||
if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
Error("Unable to choose an EGL config");
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(wt->Display, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
Error("Unable to get visual id of EGL config\n");
|
||||
}
|
||||
|
||||
visTemplate.visualid = vid;
|
||||
visinfo = XGetVisualInfo(wt->Dpy, VisualIDMask,
|
||||
&visTemplate, &num_visuals);
|
||||
if (!visinfo) {
|
||||
Error("Unable to find RGB, Z, double-buffered visual");
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap(wt->Dpy, root, visinfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow(wt->Dpy, root, xpos, ypos, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr);
|
||||
if (!win) {
|
||||
Error("Couldn't create window");
|
||||
}
|
||||
|
||||
XFree(visinfo);
|
||||
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = xpos;
|
||||
sizehints.y = ypos;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(wt->Dpy, win, &sizehints);
|
||||
XSetStandardProperties(wt->Dpy, win, "xeglthreads", "xeglthreads",
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
|
||||
ctx = eglCreateContext(wt->Display, config, shareCtx, NULL);
|
||||
if (!ctx) {
|
||||
Error("Couldn't create EGL context");
|
||||
}
|
||||
surf = eglCreateWindowSurface(wt->Display, config, win, NULL);
|
||||
if (!surf) {
|
||||
Error("Couldn't create EGL surface");
|
||||
}
|
||||
|
||||
XMapWindow(wt->Dpy, win);
|
||||
XSync(wt->Dpy, 0);
|
||||
|
||||
/* save the info for this window/context */
|
||||
wt->Win = win;
|
||||
wt->Context = ctx;
|
||||
wt->Surface = surf;
|
||||
wt->Angle = 0.0;
|
||||
wt->WinWidth = width;
|
||||
wt->WinHeight = height;
|
||||
wt->NewSize = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by pthread_create()
|
||||
*/
|
||||
static void *
|
||||
thread_function(void *p)
|
||||
{
|
||||
struct winthread *wt = (struct winthread *) p;
|
||||
draw_loop(wt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* called before exit to wait for all threads to finish
|
||||
*/
|
||||
static void
|
||||
clean_up(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* wait for threads to finish */
|
||||
for (i = 0; i < NumWinThreads; i++) {
|
||||
pthread_join(WinThreads[i].Thread, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < NumWinThreads; i++) {
|
||||
eglDestroyContext(WinThreads[i].Display, WinThreads[i].Context);
|
||||
XDestroyWindow(WinThreads[i].Dpy, WinThreads[i].Win);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("xeglthreads: test of EGL/GL thread safety (any key = exit)\n");
|
||||
printf("Usage:\n");
|
||||
printf(" xeglthreads [options]\n");
|
||||
printf("Options:\n");
|
||||
printf(" -display DISPLAYNAME Specify display string\n");
|
||||
printf(" -n NUMTHREADS Number of threads to create\n");
|
||||
printf(" -p Use a separate display connection for each thread\n");
|
||||
printf(" -l Use application-side locking\n");
|
||||
printf(" -t Enable texturing\n");
|
||||
printf("Keyboard:\n");
|
||||
printf(" Esc Exit\n");
|
||||
printf(" t Change texture image (requires -t option)\n");
|
||||
printf(" a Toggle animation\n");
|
||||
printf(" s Step rotation (when not animating)\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *displayName = NULL;
|
||||
int numThreads = 2;
|
||||
Display *dpy = NULL;
|
||||
EGLDisplay *egl_dpy = NULL;
|
||||
int i;
|
||||
Status threadStat;
|
||||
|
||||
if (argc == 1) {
|
||||
usage();
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) {
|
||||
displayName = argv[i + 1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-p") == 0) {
|
||||
MultiDisplays = 1;
|
||||
}
|
||||
else if (strcmp(argv[i], "-l") == 0) {
|
||||
Locking = 1;
|
||||
}
|
||||
else if (strcmp(argv[i], "-t") == 0) {
|
||||
Texture = 1;
|
||||
}
|
||||
else if (strcmp(argv[i], "-n") == 0 && i + 1 < argc) {
|
||||
numThreads = atoi(argv[i + 1]);
|
||||
if (numThreads < 1)
|
||||
numThreads = 1;
|
||||
else if (numThreads > MAX_WINTHREADS)
|
||||
numThreads = MAX_WINTHREADS;
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Locking)
|
||||
printf("xeglthreads: Using explicit locks around Xlib calls.\n");
|
||||
else
|
||||
printf("xeglthreads: No explict locking.\n");
|
||||
|
||||
if (MultiDisplays)
|
||||
printf("xeglthreads: Per-thread display connections.\n");
|
||||
else
|
||||
printf("xeglthreads: Single display connection.\n");
|
||||
|
||||
/*
|
||||
* VERY IMPORTANT: call XInitThreads() before any other Xlib functions.
|
||||
*/
|
||||
if (!MultiDisplays) {
|
||||
if (!Locking) {
|
||||
threadStat = XInitThreads();
|
||||
if (threadStat) {
|
||||
printf("XInitThreads() returned %d (success)\n",
|
||||
(int) threadStat);
|
||||
}
|
||||
else {
|
||||
printf("XInitThreads() returned 0 "
|
||||
"(failure- this program may fail)\n");
|
||||
}
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(displayName);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "Unable to open display %s\n",
|
||||
XDisplayName(displayName));
|
||||
return -1;
|
||||
}
|
||||
egl_dpy = eglGetDisplay(dpy);
|
||||
if (!egl_dpy) {
|
||||
fprintf(stderr, "Unable to get EGL display\n");
|
||||
XCloseDisplay(dpy);
|
||||
return -1;
|
||||
}
|
||||
if (!eglInitialize(egl_dpy, NULL, NULL)) {
|
||||
fprintf(stderr, "Unable to initialize EGL display\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_init(&Mutex, NULL);
|
||||
pthread_mutex_init(&CondMutex, NULL);
|
||||
pthread_cond_init(&CondVar, NULL);
|
||||
|
||||
printf("xeglthreads: creating windows\n");
|
||||
|
||||
NumWinThreads = numThreads;
|
||||
|
||||
/* Create the EGL windows and contexts */
|
||||
for (i = 0; i < numThreads; i++) {
|
||||
EGLContext share;
|
||||
|
||||
if (MultiDisplays) {
|
||||
WinThreads[i].Dpy = XOpenDisplay(displayName);
|
||||
assert(WinThreads[i].Dpy);
|
||||
WinThreads[i].Display = eglGetDisplay(WinThreads[i].Dpy);
|
||||
assert(eglInitialize(WinThreads[i].Display, NULL, NULL));
|
||||
}
|
||||
else {
|
||||
WinThreads[i].Dpy = dpy;
|
||||
WinThreads[i].Display = egl_dpy;
|
||||
}
|
||||
WinThreads[i].Index = i;
|
||||
WinThreads[i].Initialized = GL_FALSE;
|
||||
|
||||
share = (Texture && i > 0) ? WinThreads[0].Context : 0;
|
||||
|
||||
create_window(&WinThreads[i], share);
|
||||
}
|
||||
|
||||
printf("xeglthreads: creating threads\n");
|
||||
|
||||
/* Create the threads */
|
||||
for (i = 0; i < numThreads; i++) {
|
||||
pthread_create(&WinThreads[i].Thread, NULL, thread_function,
|
||||
(void*) &WinThreads[i]);
|
||||
printf("xeglthreads: Created thread %p\n",
|
||||
(void *) WinThreads[i].Thread);
|
||||
}
|
||||
|
||||
if (MultiDisplays)
|
||||
event_loop_multi();
|
||||
else
|
||||
event_loop(dpy);
|
||||
|
||||
clean_up();
|
||||
|
||||
if (MultiDisplays) {
|
||||
for (i = 0; i < numThreads; i++) {
|
||||
eglTerminate(WinThreads[i].Display);
|
||||
XCloseDisplay(WinThreads[i].Dpy);
|
||||
}
|
||||
}
|
||||
else {
|
||||
eglTerminate(egl_dpy);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#else /* PTHREADS */
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
printf("Sorry, this program wasn't compiled with PTHREADS defined.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* PTHREADS */
|
24
progs/openvg/.gitignore
vendored
Normal file
24
progs/openvg/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
demos/lion
|
||||
demos/sp
|
||||
trivial/arc
|
||||
trivial/cap
|
||||
trivial/clear
|
||||
trivial/coord
|
||||
trivial/dash
|
||||
trivial/ellipse
|
||||
trivial/filter
|
||||
trivial/gradorigin
|
||||
trivial/lineto
|
||||
trivial/lingrad
|
||||
trivial/lookup
|
||||
trivial/mask4
|
||||
trivial/mask
|
||||
trivial/path3
|
||||
trivial/radialgrad
|
||||
trivial/readpixels
|
||||
trivial/roundedrect
|
||||
trivial/star-nonzero
|
||||
trivial/star-oddeven
|
||||
trivial/stroke2
|
||||
trivial/stroke
|
||||
trivial/vguarc
|
39
progs/openvg/demos/Makefile
Normal file
39
progs/openvg/demos/Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
# progs/vg/Makefile
|
||||
|
||||
TOP = ../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
VG_LIBS=-lm -pthread -lX11 -lEGL -lOpenVG
|
||||
INCLUDE_DIRS = -I$(TOP)/include
|
||||
|
||||
PROGRAMS = \
|
||||
lion \
|
||||
sp
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
default: $(PROGRAMS)
|
||||
|
||||
lion: lion.o lion-render.o
|
||||
$(CC) $(CFLAGS) lion.o lion-render.o -L$(TOP)/$(LIB_DIR) $(VG_LIBS) -o $@
|
||||
|
||||
lion.o: lion.c lion-render.h $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include lion.c
|
||||
lion-render.o: lion-render.c lion-render.h $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include lion-render.c
|
||||
|
||||
|
||||
sp: sp.c eglcommon.o
|
||||
$(CC) $(INCLUDE_DIRS) $(CFLAGS) $^ -L$(TOP)/$(LIB_DIR) $(LIBS) $(VG_LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
eglcommon.o: eglcommon.c $(HEADERS)
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) eglcommon.c
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
rm -f *.so
|
||||
rm -f $(PROGRAMS)
|
289
progs/openvg/demos/eglcommon.c
Normal file
289
progs/openvg/demos/eglcommon.c
Normal file
@@ -0,0 +1,289 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <VG/openvg.h> /* using full OpenGL for now */
|
||||
#include <GLES/egl.h>
|
||||
|
||||
|
||||
static init_func init = 0;
|
||||
static draw_func draw = 0;
|
||||
static reshape_func reshape = 0;
|
||||
static key_func keyPress = 0;
|
||||
static VGint width = 300, height = 300;
|
||||
|
||||
|
||||
void set_window_size(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (reshape) {
|
||||
width = event.xconfigure.width;
|
||||
height = event.xconfigure.height;
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (!keyPress || !keyPress(code)) {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int window_width(void)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
int window_height(void)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
int run(int argc, char **argv,
|
||||
init_func init_f,
|
||||
reshape_func resh_f,
|
||||
draw_func draw_f,
|
||||
key_func key_f)
|
||||
{
|
||||
const int winWidth = width, winHeight = height;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
init = init_f;
|
||||
draw = draw_f;
|
||||
reshape = resh_f;
|
||||
keyPress = key_f;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"OpenVG Example", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("VG_RENDERER = %s\n", (char *) vgGetString(VG_RENDERER));
|
||||
printf("VG_VERSION = %s\n", (char *) vgGetString(VG_VERSION));
|
||||
printf("VG_VENDOR = %s\n", (char *) vgGetString(VG_VENDOR));
|
||||
}
|
||||
|
||||
if (init)
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
if (reshape)
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglMakeCurrent(egl_dpy, 0, 0, 0);
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
20
progs/openvg/demos/eglcommon.h
Normal file
20
progs/openvg/demos/eglcommon.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef EGLCOMMON_H
|
||||
#define EGLCOMMON_H
|
||||
|
||||
typedef void (*init_func)();
|
||||
typedef void (*reshape_func)(int, int);
|
||||
typedef void (*draw_func)();
|
||||
typedef int (*key_func)(unsigned key);
|
||||
|
||||
|
||||
void set_window_size(int width, int height);
|
||||
int window_width(void);
|
||||
int window_height(void);
|
||||
|
||||
int run(int argc, char **argv,
|
||||
init_func init,
|
||||
reshape_func resh,
|
||||
draw_func draw,
|
||||
key_func key);
|
||||
|
||||
#endif
|
1573
progs/openvg/demos/lion-render.c
Normal file
1573
progs/openvg/demos/lion-render.c
Normal file
File diff suppressed because it is too large
Load Diff
16
progs/openvg/demos/lion-render.h
Normal file
16
progs/openvg/demos/lion-render.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef LION_RENDER_H
|
||||
#define LION_RENDER_H
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#define LION_SIZE 132
|
||||
struct lion {
|
||||
VGPath paths[LION_SIZE];
|
||||
VGPaint fills[LION_SIZE];
|
||||
};
|
||||
|
||||
struct lion *lion_create(void);
|
||||
void lion_render(struct lion *l);
|
||||
void lion_destroy(struct lion *l);
|
||||
|
||||
#endif
|
289
progs/openvg/demos/lion.c
Normal file
289
progs/openvg/demos/lion.c
Normal file
@@ -0,0 +1,289 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <VG/openvg.h>
|
||||
#include <GLES/egl.h>
|
||||
|
||||
#include "lion-render.h"
|
||||
|
||||
static VGint width, height;
|
||||
struct lion *lion = 0;
|
||||
VGfloat angle = 0;
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, width, height);
|
||||
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
vgTranslate(width/2, height/2);
|
||||
vgRotate(angle);
|
||||
vgTranslate(-width/2, -height/2);
|
||||
|
||||
lion_render(lion);
|
||||
|
||||
++angle;
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
float clear_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clear_color);
|
||||
|
||||
lion = lion_create();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
XEvent event;
|
||||
|
||||
while (XPending(dpy) > 0) {
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 350, winHeight = 450;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"Lion Example", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("VG_RENDERER = %s\n", (char *) vgGetString(VG_RENDERER));
|
||||
printf("VG_VERSION = %s\n", (char *) vgGetString(VG_VERSION));
|
||||
printf("VG_VENDOR = %s\n", (char *) vgGetString(VG_VENDOR));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
537
progs/openvg/demos/sp.c
Normal file
537
progs/openvg/demos/sp.c
Normal file
@@ -0,0 +1,537 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <VG/vgu.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define ELEMENTS(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
struct object {
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
VGPaint stroke;
|
||||
VGint draw_mode;
|
||||
VGfloat matrix[9];
|
||||
VGfloat stroke_width;
|
||||
};
|
||||
|
||||
struct character {
|
||||
struct object objects[32];
|
||||
VGint num_objects;
|
||||
};
|
||||
VGfloat identity_matrix[] = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
||||
|
||||
struct character cartman;
|
||||
|
||||
static void add_object_fill(const VGubyte *segments, VGint num_segments,
|
||||
const VGfloat *coords,
|
||||
VGuint color)
|
||||
{
|
||||
struct object object;
|
||||
|
||||
object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(object.path, num_segments, segments, coords);
|
||||
|
||||
object.fill = vgCreatePaint();
|
||||
vgSetColor(object.fill, color);
|
||||
memcpy(object.matrix, identity_matrix, 9 * sizeof(VGfloat));
|
||||
object.draw_mode = VG_FILL_PATH;
|
||||
|
||||
cartman.objects[cartman.num_objects] = object;
|
||||
++cartman.num_objects;
|
||||
}
|
||||
|
||||
|
||||
static void add_object_stroke(const VGubyte *segments, VGint num_segments,
|
||||
const VGfloat *coords,
|
||||
VGuint color, VGfloat width)
|
||||
{
|
||||
struct object object;
|
||||
|
||||
object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(object.path, num_segments, segments, coords);
|
||||
|
||||
object.stroke = vgCreatePaint();
|
||||
vgSetColor(object.stroke, color);
|
||||
memcpy(object.matrix, identity_matrix, 9 * sizeof(VGfloat));
|
||||
object.draw_mode = VG_STROKE_PATH;
|
||||
object.stroke_width = width;
|
||||
|
||||
cartman.objects[cartman.num_objects] = object;
|
||||
++cartman.num_objects;
|
||||
}
|
||||
|
||||
|
||||
static void add_object_fillm(const VGubyte *segments, VGint num_segments,
|
||||
const VGfloat *coords,
|
||||
VGuint color,
|
||||
VGfloat *matrix)
|
||||
{
|
||||
struct object object;
|
||||
|
||||
object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(object.path, num_segments, segments, coords);
|
||||
|
||||
object.fill = vgCreatePaint();
|
||||
vgSetColor(object.fill, color);
|
||||
memcpy(object.matrix, matrix, 9 * sizeof(VGfloat));
|
||||
object.draw_mode = VG_FILL_PATH;
|
||||
|
||||
cartman.objects[cartman.num_objects] = object;
|
||||
++cartman.num_objects;
|
||||
}
|
||||
|
||||
|
||||
static void add_object_m(const VGubyte *segments, VGint num_segments,
|
||||
const VGfloat *coords,
|
||||
VGuint fill_color,
|
||||
VGuint stroke_color, VGfloat stroke_width,
|
||||
VGfloat *matrix)
|
||||
{
|
||||
struct object object;
|
||||
|
||||
object.path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(object.path, num_segments, segments, coords);
|
||||
memcpy(object.matrix, matrix, 9 * sizeof(VGfloat));
|
||||
|
||||
object.fill = vgCreatePaint();
|
||||
vgSetColor(object.fill, fill_color);
|
||||
object.draw_mode = VG_FILL_PATH | VG_STROKE_PATH;
|
||||
|
||||
object.stroke = vgCreatePaint();
|
||||
vgSetColor(object.stroke, stroke_color);
|
||||
object.stroke_width = stroke_width;
|
||||
|
||||
cartman.objects[cartman.num_objects] = object;
|
||||
++cartman.num_objects;
|
||||
}
|
||||
|
||||
static void init_character()
|
||||
{
|
||||
{
|
||||
const VGubyte segments[] = {VG_MOVE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CLOSE_PATH};
|
||||
const VGfloat coords[] = {181.83267, 102.60408,
|
||||
181.83267,102.60408, 185.53793,114.5749, 186.5355,115.00243,
|
||||
187.53306,115.42996, 286.0073,115.00243, 286.0073,115.00243,
|
||||
286.0073,115.00243, 292.70526,103.45914, 290.85263,101.03648,
|
||||
289.00001,98.61381, 181.54765,102.31906, 181.83267,102.60408
|
||||
};
|
||||
VGuint color = 0x7c4e32ff;
|
||||
add_object_fill(segments, ELEMENTS(segments),
|
||||
coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {188.62208,50.604156,
|
||||
188.62208,50.604156, 176.73127,60.479579, 170.68509,69.548844,
|
||||
164.63892,78.618109, 175.11895,79.827344, 175.11895,79.827344,
|
||||
176.52973,98.368952,
|
||||
176.52973,98.368952, 189.83131,110.05823, 208.97754,110.25976,
|
||||
228.12377,110.46131, 244.24691,111.67054, 247.06846,110.25976,
|
||||
249.89,108.849, 258.95927,106.8336, 260.16851,105.01975,
|
||||
261.37774,103.2059, 296.84865,106.43053, 297.05019,91.919698,
|
||||
297.25172,77.408874, 306.11945,64.308824, 282.13628,51.611853,
|
||||
258.15311,38.914882, 189.2267,49.999539, 188.62208,50.604156
|
||||
};
|
||||
|
||||
VGuint color = 0xe30000ff;
|
||||
add_object_fill(segments, ELEMENTS(segments),
|
||||
coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
68.25, 78.875,
|
||||
68.25,93.296, 54.642,105, 37.875,105,
|
||||
21.108,105, 7.5,93.296, 7.5,78.875,
|
||||
7.5,64.454, 21.108,52.75, 37.875,52.75,
|
||||
54.642,52.75, 68.25,64.454, 68.25,78.875
|
||||
};
|
||||
|
||||
VGuint color = 0xffe1c4ff;
|
||||
VGfloat matrix[] = {
|
||||
1.6529, 0, 0,
|
||||
0, 1.582037, 0,
|
||||
172.9649,-90.0116, 1
|
||||
};
|
||||
add_object_fillm(segments, ELEMENTS(segments),
|
||||
coords, color, matrix);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
170.14687,71.536958,
|
||||
173.53626,68.814326, 176.70232,68.971782, 180.55009,71.679467,
|
||||
184.39785,74.387153, 199.19294,80.036105, 191.52334,86.500482,
|
||||
189.02942,88.6025, 183.97032,85.787933, 180.26507,86.928011,
|
||||
178.8737,87.356121, 174.71827,89.783259, 171.8028,87.494856,
|
||||
166.95426,83.689139, 163.51779,76.861986, 170.14687,71.536958
|
||||
};
|
||||
|
||||
VGuint color = 0xfff200ff;
|
||||
add_object_fill(segments, ELEMENTS(segments),
|
||||
coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
299.83075,66.834136,
|
||||
299.83075,66.834136, 287.85993,64.69649, 284.15467,72.962055,
|
||||
280.44942,81.227621, 280.1644,78.234916, 280.1644,79.374994,
|
||||
280.1644,80.515072, 278.16927,84.077816, 284.86722,83.792796,
|
||||
291.56518,83.507777, 291.99271,86.785501, 294.84291,86.642991,
|
||||
297.6931,86.500482, 303.536,85.645423, 303.67851,80.657582,
|
||||
303.82102,75.66974, 302.68094,65.551548, 299.83075,66.834136
|
||||
};
|
||||
|
||||
VGuint color = 0xfff200ff;
|
||||
add_object_fill(segments, ELEMENTS(segments),
|
||||
coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
240.83171,75.81225,
|
||||
240.83171,75.81225, 241.54426,88.495618, 242.25681,91.488323,
|
||||
242.96936,94.481028, 240.6892,108.01945, 240.83171,110.01459,
|
||||
240.97422,112.00973, 240.97422,111.01216, 240.97422,111.01216
|
||||
};
|
||||
VGuint color = 0x000000ff;
|
||||
VGfloat swidth = 1.14007807;
|
||||
add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
83.375, 95.5,
|
||||
83.375,96.121, 83.067,96.625, 82.6875,96.625,
|
||||
82.308,96.625, 82,96.121, 82,95.5,
|
||||
82,94.879, 82.308,94.375, 82.6875,94.375,
|
||||
83.066677,94.375, 83.374492,94.878024, 83.374999,95.498494,
|
||||
82.6875,95.5,
|
||||
83.375,95.5
|
||||
};
|
||||
VGuint fill_color = 0x000000ff;
|
||||
VGuint stroke_color = 0x000000ff;
|
||||
VGfloat swidth = 0.60000002;
|
||||
VGfloat matrix1[] = {
|
||||
1.140078, 0, 0,
|
||||
0, 1.140078, 0,
|
||||
145.4927, -15.10897, 1
|
||||
};
|
||||
VGfloat matrix2[] = {
|
||||
1.140078,0, 0,
|
||||
0,1.140078, 0,
|
||||
144.2814,-27.93485, 1
|
||||
};
|
||||
VGfloat matrix3[] = {
|
||||
1.140078,0, 0,
|
||||
0,1.140078, 0,
|
||||
144.1388,-3.70819, 1
|
||||
};
|
||||
add_object_m(segments, ELEMENTS(segments), coords,
|
||||
fill_color, stroke_color, swidth, matrix1);
|
||||
add_object_m(segments, ELEMENTS(segments), coords,
|
||||
fill_color, stroke_color, swidth, matrix2);
|
||||
add_object_m(segments, ELEMENTS(segments), coords,
|
||||
fill_color, stroke_color, swidth, matrix3);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
179.41001,115.28745,
|
||||
179.41001,115.28745, 207.48443,109.30204, 236.84144,115.14494,
|
||||
236.84144,115.14494, 274.74903,109.87208, 291.8502,115.42996,
|
||||
179.41001,115.28745
|
||||
};
|
||||
|
||||
VGuint color = 0x000000ff;
|
||||
add_object_fill(segments, ELEMENTS(segments),
|
||||
coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
83.792156,68.157364,
|
||||
83.792156,69.669865, 82.72301,70.897403, 81.40567,70.897403,
|
||||
80.08833,70.897403, 79.019185,69.669865, 79.019185,68.157364,
|
||||
79.019185,66.644862, 80.08833,65.417325, 81.40567,65.417325,
|
||||
82.721887,65.417325, 83.790391,66.642485, 83.792153,68.153696,
|
||||
81.40567,68.157364,
|
||||
83.792156,68.157364
|
||||
};
|
||||
VGuint fill_color = 0x000000ff;
|
||||
VGuint stroke_color = 0x000000ff;
|
||||
VGfloat swidth = 0.52891117;
|
||||
VGfloat matrix1[] = {
|
||||
1.140078,0, 0,
|
||||
0,1.140078, 0,
|
||||
145.2489,-15.58714, 1
|
||||
};
|
||||
add_object_m(segments, ELEMENTS(segments), coords,
|
||||
fill_color, stroke_color, swidth, matrix1);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
232.28113,66.976646,
|
||||
232.28113,66.976646, 237.98152,70.539389, 245.39202,66.549116
|
||||
};
|
||||
VGuint color = 0x000000ff;
|
||||
VGfloat swidth = 0.60299999;
|
||||
add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
185.96908,30.061986,
|
||||
185.96908,30.061986, 187.76995,14.508377, 203.23909,3.7427917,
|
||||
209.95028,-0.92779696, 219.37764,-4.9841866, 232.1078,-6.00046,
|
||||
246.13578,-7.1203411, 256.92106,-2.8560739, 264.81774,1.9451947,
|
||||
280.60485,11.543934, 284.31582,25.937274, 284.08015,26.526452,
|
||||
283.7266,27.410336, 240.83461,1.9346323, 185.96908,30.061986
|
||||
};
|
||||
VGuint color = 0x8ed8f8ff;
|
||||
add_object_fill(segments, ELEMENTS(segments), coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
185.39542,32.061757,
|
||||
185.82295,29.211562,
|
||||
185.82295,29.211562, 234.70379,2.277219, 284.01217,25.078779,
|
||||
284.86722,27.643954,
|
||||
284.86722,27.643954, 236.69893,4.5573746, 185.39542,32.061757
|
||||
};
|
||||
VGuint color = 0xfff200ff;
|
||||
add_object_fill(segments, ELEMENTS(segments), coords, color);
|
||||
}
|
||||
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
219.74027,-5.917093,
|
||||
220.49206,-8.44929, 225.15564,-10.904934, 230.21473,-11.189954,
|
||||
235.27383,-11.474973, 243.27521,-13.287236, 249.21385,-5.724198,
|
||||
249.89961,-4.850868, 249.28247,-4.332166, 248.62298,-3.971398,
|
||||
247.79117,-3.516361, 247.13703,-3.392737, 246.16222,-3.408047,
|
||||
243.63973,-3.447664, 242.54183,-3.850701, 242.54183,-3.850701,
|
||||
242.54183,-3.850701, 238.78367,-1.737343, 236.20014,-3.565682,
|
||||
233.88436,-5.204544, 234.27626,-4.56325, 234.27626,-4.56325,
|
||||
234.27626,-4.56325, 232.33303,-2.975658, 230.85603,-2.995643,
|
||||
228.59433,-3.025282, 227.73672,-4.501857, 227.21966,-4.93027,
|
||||
226.76318,-4.932008, 226.50948,-4.491995, 226.50948,-4.491995,
|
||||
226.50948,-4.491995, 224.53199,-2.085883, 222.51431,-2.467064,
|
||||
221.48814,-2.66093, 218.91968,-3.15318, 219.74027,-5.917093
|
||||
};
|
||||
VGuint color = 0xfff200ff;
|
||||
add_object_fill(segments, ELEMENTS(segments), coords, color);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
178.97347,166.06432,
|
||||
178.97347,181.2154, 168.0245,193.51193, 154.53381,193.51193,
|
||||
141.04312,193.51193, 130.09416,181.2154, 130.09416,166.06432,
|
||||
130.09416,150.91323, 141.04312,138.6167, 154.53381,138.6167,
|
||||
168.0245,138.6167, 178.97347,150.91323, 178.97347,166.06432
|
||||
};
|
||||
VGuint color = 0xffffffff;
|
||||
VGfloat matrix1[] = {
|
||||
0.466614,-0.23492, 0,
|
||||
0.108683,0.436638, 0,
|
||||
134.5504,-0.901632, 1
|
||||
};
|
||||
VGfloat matrix2[] = {
|
||||
-0.466614,-0.23492, 0,
|
||||
-0.108683,0.436638, 0,
|
||||
338.4496,-0.512182, 1
|
||||
};
|
||||
add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix1);
|
||||
add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix2);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
|
||||
VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
123.82758,165.06168,
|
||||
123.82758,166.79125, 122.59232,168.19497, 121.07029,168.19497,
|
||||
119.54826,168.19497, 118.313,166.79125, 118.313,165.06168,
|
||||
118.313,163.3321, 119.54826,161.92839, 121.07029,161.92839,
|
||||
122.59232,161.92839, 123.82758,163.3321, 123.82758,165.06168
|
||||
};
|
||||
VGuint color = 0x000000ff;
|
||||
VGfloat matrix1[] = {
|
||||
0.525719,0, 0,
|
||||
0,0.479931, 0,
|
||||
178.9702,-43.3532, 1
|
||||
};
|
||||
VGfloat matrix2[] = {
|
||||
0.525719,0, 0,
|
||||
0,0.479931, 0,
|
||||
165.258,-43.46162, 1
|
||||
};
|
||||
add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix1);
|
||||
add_object_fillm(segments, ELEMENTS(segments), coords, color, matrix2);
|
||||
}
|
||||
{
|
||||
const VGubyte segments[] = {
|
||||
VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS
|
||||
};
|
||||
const VGfloat coords[] = {
|
||||
197.25,54.5,
|
||||
197.25,54.5, 211.75,71.5, 229.25,71.5,
|
||||
246.75,71.5, 261.74147,71.132714, 277.75,50.75
|
||||
};
|
||||
VGuint color = 0x000000ff;
|
||||
VGfloat swidth = 0.60299999;
|
||||
add_object_stroke(segments, ELEMENTS(segments), coords, color, swidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
float clear_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clear_color);
|
||||
|
||||
init_character();
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
key_press(unsigned key)
|
||||
{
|
||||
switch(key) {
|
||||
case XK_Right:
|
||||
|
||||
break;
|
||||
case XK_Left:
|
||||
break;
|
||||
case XK_Up:
|
||||
break;
|
||||
case XK_Down:
|
||||
break;
|
||||
case 'a':
|
||||
break;
|
||||
case 's':
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return VG_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGint i;
|
||||
VGfloat save_matrix[9];
|
||||
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
vgScale(2, 2);
|
||||
vgTranslate(160, 60);
|
||||
vgRotate(180);
|
||||
vgTranslate(-160, -100);
|
||||
vgGetMatrix(save_matrix);
|
||||
for (i = 0; i < cartman.num_objects; ++i) {
|
||||
struct object object = cartman.objects[i];
|
||||
if ((object.draw_mode & VG_STROKE_PATH)) {
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, object.stroke_width);
|
||||
vgSetPaint(object.stroke, VG_STROKE_PATH);
|
||||
}
|
||||
if ((object.draw_mode & VG_FILL_PATH))
|
||||
vgSetPaint(object.fill, VG_FILL_PATH);
|
||||
vgMultMatrix(object.matrix);
|
||||
vgDrawPath(object.path, object.draw_mode);
|
||||
vgLoadMatrix(save_matrix);
|
||||
}
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(400, 400);
|
||||
return run(argc, argv, init, reshape, draw, key_press);
|
||||
}
|
127
progs/openvg/trivial/Makefile
Normal file
127
progs/openvg/trivial/Makefile
Normal file
@@ -0,0 +1,127 @@
|
||||
# These programs aren't intended to be included with the normal distro.
|
||||
# They're not too interesting but they're good for testing.
|
||||
|
||||
TOP = ../../../
|
||||
include $(TOP)/configs/current
|
||||
|
||||
INCLUDES = -I. -I$(TOP)/include
|
||||
LIBS=-L$(TOP)/$(LIB_DIR) -lm -lX11 -lEGL -lOpenVG -lpthread
|
||||
CFLAGS += $(INCLUDES)
|
||||
|
||||
HEADERS=eglcommon.h
|
||||
|
||||
PROGRAMS = \
|
||||
arc \
|
||||
cap \
|
||||
clear \
|
||||
coord \
|
||||
dash \
|
||||
ellipse \
|
||||
filter \
|
||||
gradorigin \
|
||||
lineto \
|
||||
lingrad \
|
||||
lookup \
|
||||
mask4 \
|
||||
mask \
|
||||
path3 \
|
||||
radialgrad \
|
||||
readpixels \
|
||||
roundedrect \
|
||||
star-nonzero \
|
||||
star-oddeven \
|
||||
stroke2 \
|
||||
stroke \
|
||||
vguarc
|
||||
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
default: $(PROGRAMS)
|
||||
|
||||
|
||||
arc: arc.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
cap: cap.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
clear: clear.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
coord: coord.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
dash: dash.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
ellipse: ellipse.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
filter: filter.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
gradorigin: gradorigin.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
image: image.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
lineto: lineto.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
lingrad: lingrad.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
lookup: lookup.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
mask: mask.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
mask4: mask4.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
path3: path3.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
pattern: pattern.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
radialgrad: radialgrad.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
readpixels: readpixels.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
roundedrect: roundedrect.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
star-nonzero: star-nonzero.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
star-oddeven: star-oddeven.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
stroke: stroke.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
stroke2: stroke2.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
vguarc: vguarc.c eglcommon.o
|
||||
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
||||
|
||||
eglcommon.o: eglcommon.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) eglcommon.c
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
rm -f *.so
|
||||
rm -f $(PROGRAMS)
|
139
progs/openvg/trivial/arc.c
Normal file
139
progs/openvg/trivial/arc.c
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <math.h>
|
||||
|
||||
const VGfloat clear_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {1.0, 1.0, 1.0, 0.5};
|
||||
|
||||
VGPath vgPath;
|
||||
|
||||
static void ellipse(VGPath vgPath, VGfloat rx, VGfloat ry, VGfloat angle)
|
||||
{
|
||||
static const VGubyte cmd[] =
|
||||
{ VG_MOVE_TO_ABS, VG_SCCWARC_TO_REL, VG_SCCWARC_TO_REL, VG_CLOSE_PATH };
|
||||
|
||||
VGfloat val[12];
|
||||
VGfloat c = cos(angle) * rx;
|
||||
VGfloat s = sin(angle) * rx;
|
||||
|
||||
val[0] = c;
|
||||
val[1] = s;
|
||||
val[2] = rx;
|
||||
val[3] = ry;
|
||||
val[4] = angle;
|
||||
val[5] = -2.0f * c;
|
||||
val[6] = -2.0f * s;
|
||||
val[7] = rx;
|
||||
val[8] = ry;
|
||||
val[9] = angle;
|
||||
val[10] = 2.0f * c;
|
||||
val[11] = 2.0f * s;
|
||||
|
||||
vgClearPath(vgPath, VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(vgPath, sizeof(cmd), cmd, val);
|
||||
vgDrawPath(vgPath, VG_FILL_PATH | VG_STROKE_PATH);
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGPaint vgPaint;
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clear_color);
|
||||
vgPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
|
||||
VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0,
|
||||
VG_PATH_CAPABILITY_ALL);
|
||||
|
||||
vgPaint = vgCreatePaint();
|
||||
vgSetParameteri(vgPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
vgSetColor(vgPaint, 0x00ff00ff);
|
||||
vgSetPaint(vgPaint, VG_FILL_PATH);
|
||||
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 2.0f);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_SQUARE);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_MITER);
|
||||
vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
#if 0
|
||||
vgLoadIdentity();
|
||||
vgTranslate(40.0f, 24.0f);
|
||||
vgScale(0.61804f, 0.61804f);
|
||||
vgShear(-1.0f, 0.0f);
|
||||
vgDrawPath(vgPath, VG_FILL_PATH | VG_STROKE_PATH);
|
||||
#else
|
||||
|
||||
/* row 1, col 1: Identity transform. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(8.0f, 8.0f);
|
||||
ellipse(vgPath, 4.0f, 4.0f, 0.0f);
|
||||
|
||||
/* row 1, col 2: 10^3 horizontal squeeze. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(24.0f, 8.0f);
|
||||
vgScale(1.0e-3f, 1.0f);
|
||||
ellipse(vgPath, 4.0e3f, 4.0f, 0.0f);
|
||||
|
||||
/* row 1, col 3: 10^6 horizontal squeeze. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(40.0f, 8.0f);
|
||||
vgScale(1.0e-6f, 1.0f);
|
||||
ellipse(vgPath, 4.0e6f, 4.0f, 0.0f);
|
||||
|
||||
/* row 1, col 4: 10^9 horizontal squeeze. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(56.0f, 8.0f);
|
||||
vgScale(1.0e-9f, 1.0f);
|
||||
ellipse(vgPath, 4.0e9f, 4.0f, 0.0f);
|
||||
|
||||
/* row 2, col 1: 10^3 vertical squeeze. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(8.0f, 24.0f);
|
||||
vgScale(1.0f, 1.0e-3f);
|
||||
ellipse(vgPath, 4.0f, 4.0e3f, 0.0f);
|
||||
|
||||
/* row 2, col 2: Shear 0. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(24.0f, 24.0f);
|
||||
vgShear(0.0f, 0.0f);
|
||||
ellipse(vgPath, 4.0f, 4.0f, 0.0f);
|
||||
|
||||
/* row 2, col 3: Horizontal shear -1. */
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(40.0f, 24.0f);
|
||||
vgScale(0.61804f, 0.61804f);
|
||||
vgShear(-1.0f, 0.0f);
|
||||
ellipse(vgPath, 10.47213f, 4.0f, 31.717f);
|
||||
#endif
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
75
progs/openvg/trivial/cap.c
Normal file
75
progs/openvg/trivial/cap.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
const int subtest = 0;
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGPath line;
|
||||
VGPaint fillPaint;
|
||||
VGubyte lineCommands[3] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS};
|
||||
VGfloat lineCoords[] = {-2.0f,-1.0f, 0.0f,0.0f, -1.0f, -2.0f};
|
||||
VGfloat clearColor[] = {0.0f, 0.0f, 0.0f, 1.0f};/* black color */
|
||||
VGfloat fillColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
|
||||
//VGfloat testRadius = 60.0f;
|
||||
VGfloat testRadius = 10.0f;
|
||||
int WINDSIZEX = window_width();
|
||||
int WINDSIZEY = window_height();
|
||||
|
||||
line = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
fillPaint = vgCreatePaint();
|
||||
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 1.0f);
|
||||
//vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_ROUND);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
|
||||
//vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_BEVEL);
|
||||
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);
|
||||
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
vgTranslate(60, 60);
|
||||
vgScale(testRadius * 2, testRadius * 2);
|
||||
|
||||
vgAppendPathData(line, 3, lineCommands, lineCoords);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
|
||||
vgSetPaint(fillPaint, VG_STROKE_PATH);
|
||||
|
||||
vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, fillColor);
|
||||
vgSetParameteri( fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
|
||||
vgClear(0, 0, WINDSIZEX, WINDSIZEY);
|
||||
vgDrawPath(line, VG_STROKE_PATH);
|
||||
|
||||
vgDestroyPath(line);
|
||||
vgDestroyPaint(fillPaint);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(100, 100);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
42
progs/openvg/trivial/clear.c
Normal file
42
progs/openvg/trivial/clear.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
float red_color[4] = {1.0, 0.0, 0.0, 1.0};
|
||||
float blue_color[4] = {0.0, 0.0, 1.0, 1.0};
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGint scissor[4] = {100, 100, 25, 25};
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, red_color);
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, blue_color);
|
||||
vgClear(50, 50, 50, 50);
|
||||
|
||||
//vgSetiv(VG_SCISSOR_RECTS, 4, scissor);
|
||||
//vgSeti(VG_SCISSORING, VG_TRUE);
|
||||
vgCopyPixels(100, 100, 50, 50, 50, 50);
|
||||
vgClear(150, 150, 50, 50);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
66
progs/openvg/trivial/coord.c
Normal file
66
progs/openvg/trivial/coord.c
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
/* Absent VG_CLOSE_PATH */
|
||||
VGubyte commands[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
|
||||
VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS};
|
||||
VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
|
||||
VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
|
||||
VGfloat coords[] = {-16.0f, -16.0f, 0.0f, -16.0f, 0.0f, 0.0f, -16.0f, 0.0f,
|
||||
0.0f, 0.0f, 16.0f, 0.0f, 16.0f, 16.0f, 0.0f, 16.0f};
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
vgTranslate(32.0f, 32.0f);
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0,
|
||||
VG_PATH_CAPABILITY_ALL);
|
||||
if (path == VG_INVALID_HANDLE)
|
||||
return;
|
||||
fill = vgCreatePaint();
|
||||
if (fill == VG_INVALID_HANDLE) {
|
||||
vgDestroyPath(path);
|
||||
return;
|
||||
}
|
||||
vgAppendPathData(path, 8, commands, coords);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, fillColor);
|
||||
vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
95
progs/openvg/trivial/dash.c
Normal file
95
progs/openvg/trivial/dash.c
Normal file
@@ -0,0 +1,95 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
VGint cap_style = VG_CAP_BUTT;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte cmds[] = {VG_MOVE_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_LINE_TO_ABS
|
||||
};
|
||||
#if 1
|
||||
static const VGfloat coords[] = {100, 100, 150, 100,
|
||||
150, 200
|
||||
};
|
||||
#else
|
||||
static const VGfloat coords[] = {100, 20, 100, 220,
|
||||
};
|
||||
#endif
|
||||
VGfloat dash_pattern[2] = { 20.f, 20.f };
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 3, cmds, coords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 20);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, cap_style);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
|
||||
vgSetfv(VG_STROKE_DASH_PATTERN, 2, dash_pattern);
|
||||
vgSetf(VG_STROKE_DASH_PHASE, 0.0f);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_STROKE_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
static int key_press(unsigned key)
|
||||
{
|
||||
switch(key) {
|
||||
case XK_c:
|
||||
case XK_C:
|
||||
++cap_style;
|
||||
if (cap_style > VG_CAP_SQUARE)
|
||||
cap_style = VG_CAP_BUTT;
|
||||
switch(cap_style) {
|
||||
case VG_CAP_BUTT:
|
||||
fprintf(stderr, "Cap style 'butt'\n");
|
||||
break;
|
||||
case VG_CAP_ROUND:
|
||||
fprintf(stderr, "Cap style 'round'\n");
|
||||
break;
|
||||
case VG_CAP_SQUARE:
|
||||
fprintf(stderr, "Cap style 'square'\n");
|
||||
break;
|
||||
}
|
||||
vgSeti(VG_STROKE_CAP_STYLE, cap_style);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VG_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, key_press);
|
||||
}
|
289
progs/openvg/trivial/eglcommon.c
Normal file
289
progs/openvg/trivial/eglcommon.c
Normal file
@@ -0,0 +1,289 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <VG/openvg.h> /* using full OpenGL for now */
|
||||
#include <GLES/egl.h>
|
||||
|
||||
|
||||
static init_func init = 0;
|
||||
static draw_func draw = 0;
|
||||
static reshape_func reshape = 0;
|
||||
static key_func keyPress = 0;
|
||||
static VGint width = 300, height = 300;
|
||||
|
||||
|
||||
void set_window_size(int w, int h)
|
||||
{
|
||||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENVG_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (reshape) {
|
||||
width = event.xconfigure.width;
|
||||
height = event.xconfigure.height;
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (!keyPress || !keyPress(code)) {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int window_width(void)
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
int window_height(void)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
int run(int argc, char **argv,
|
||||
init_func init_f,
|
||||
reshape_func resh_f,
|
||||
draw_func draw_f,
|
||||
key_func key_f)
|
||||
{
|
||||
const int winWidth = width, winHeight = height;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
init = init_f;
|
||||
draw = draw_f;
|
||||
reshape = resh_f;
|
||||
keyPress = key_f;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"OpenVG Example", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("VG_RENDERER = %s\n", (char *) vgGetString(VG_RENDERER));
|
||||
printf("VG_VERSION = %s\n", (char *) vgGetString(VG_VERSION));
|
||||
printf("VG_VENDOR = %s\n", (char *) vgGetString(VG_VENDOR));
|
||||
}
|
||||
|
||||
if (init)
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
if (reshape)
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglMakeCurrent(egl_dpy, 0, 0, 0);
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
20
progs/openvg/trivial/eglcommon.h
Normal file
20
progs/openvg/trivial/eglcommon.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef EGLCOMMON_H
|
||||
#define EGLCOMMON_H
|
||||
|
||||
typedef void (*init_func)();
|
||||
typedef void (*reshape_func)(int, int);
|
||||
typedef void (*draw_func)();
|
||||
typedef int (*key_func)(unsigned key);
|
||||
|
||||
|
||||
void set_window_size(int width, int height);
|
||||
int window_width(void);
|
||||
int window_height(void);
|
||||
|
||||
int run(int argc, char **argv,
|
||||
init_func init,
|
||||
reshape_func resh,
|
||||
draw_func draw,
|
||||
key_func key);
|
||||
|
||||
#endif
|
84
progs/openvg/trivial/ellipse.c
Normal file
84
progs/openvg/trivial/ellipse.c
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint paint;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 1.0f};/* white color */
|
||||
VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
|
||||
static const VGubyte segments[4] = {VG_MOVE_TO_ABS,
|
||||
VG_SCCWARC_TO_ABS,
|
||||
VG_SCCWARC_TO_ABS,
|
||||
VG_CLOSE_PATH};
|
||||
VGfloat data[12];
|
||||
const VGfloat cx = 0, cy=29, width=80, height=40;
|
||||
const VGfloat hw = width * 0.5f;
|
||||
const VGfloat hh = height * 0.5f;
|
||||
|
||||
data[0] = cx + hw;
|
||||
data[1] = cy;
|
||||
data[2] = hw;
|
||||
data[3] = hh;
|
||||
data[4] = 0;
|
||||
data[5] = cx - hw;
|
||||
data[6] = cy;
|
||||
data[7] = hw;
|
||||
data[8] = hh;
|
||||
data[9] = 0;
|
||||
data[10] = data[0];
|
||||
data[11] = cy;
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
if (path == VG_INVALID_HANDLE) {
|
||||
return;
|
||||
}
|
||||
paint = vgCreatePaint();
|
||||
if (paint == VG_INVALID_HANDLE) {
|
||||
vgDestroyPath(path);
|
||||
return;
|
||||
}
|
||||
|
||||
vgAppendPathData(path, 4, segments, data);
|
||||
vgSetParameterfv(paint, VG_PAINT_COLOR, 4, fillColor);
|
||||
vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
vgSetPaint(paint, VG_FILL_PATH);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgLoadIdentity();
|
||||
vgTranslate(50, 21);
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(100, 100);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
107
progs/openvg/trivial/filter.c
Normal file
107
progs/openvg/trivial/filter.c
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {1.0, 1.0, 1.0, 0.5};
|
||||
|
||||
VGImage srcImg;
|
||||
VGImage dstImg;
|
||||
|
||||
VGPaint fill;
|
||||
|
||||
VGfloat bgCol[4] = {0.906f, 0.914f, 0.761f, 1.0f};
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGfloat red[4];
|
||||
VGfloat grey[4];
|
||||
VGfloat orange[4];
|
||||
VGfloat blue[4];
|
||||
VGfloat black[4];
|
||||
VGfloat white[4];
|
||||
VGshort transKernel[49] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
red[0] = 0.6710f;
|
||||
red[1] = 0.1060f;
|
||||
red[2] = 0.1330f;
|
||||
red[3] = 1.0f;
|
||||
|
||||
grey[0] = 0.6347f;
|
||||
grey[1] = 0.6561f;
|
||||
grey[2] = 0.6057f;
|
||||
grey[3] = 1.0f;
|
||||
|
||||
orange[0] = 1.0000f;
|
||||
orange[1] = 0.8227f;
|
||||
orange[2] = 0.5057f;
|
||||
orange[3] = 1.0f;
|
||||
|
||||
blue[0] = 0.0000f;
|
||||
blue[1] = 0.6908f;
|
||||
blue[2] = 0.8595f;
|
||||
blue[3] = 1.0f;
|
||||
|
||||
black[0] = 0;
|
||||
black[1] = 0;
|
||||
black[2] = 0;
|
||||
black[3] = 1.0f;
|
||||
|
||||
white[0] = 1;
|
||||
white[1] = 1;
|
||||
white[2] = 1;
|
||||
white[3] = 1.0f;
|
||||
|
||||
vgSetfv(VG_TILE_FILL_COLOR, 4, blue);
|
||||
|
||||
vgSeti(VG_FILTER_CHANNEL_MASK, 14);
|
||||
|
||||
/* Setup images */
|
||||
srcImg = vgCreateImage(VG_sRGBA_8888, 32, 32,
|
||||
VG_IMAGE_QUALITY_NONANTIALIASED);
|
||||
dstImg = vgCreateImage(VG_sRGBA_8888, 32, 32,
|
||||
VG_IMAGE_QUALITY_NONANTIALIASED);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, black);
|
||||
vgClearImage(srcImg, 0, 0, 32, 32);
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, red);
|
||||
vgClearImage(srcImg, 3, 3, 27, 27);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, orange);
|
||||
vgClearImage(dstImg, 0, 0, 32, 32);
|
||||
|
||||
transKernel[8] = 1;
|
||||
vgConvolve(dstImg, srcImg, 3, 3, 3, 0, transKernel,
|
||||
1, 0, VG_TILE_FILL);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, bgCol);
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
vgTranslate(10, 10);
|
||||
vgDrawImage(dstImg);
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
98
progs/openvg/trivial/gradorigin.c
Normal file
98
progs/openvg/trivial/gradorigin.c
Normal file
@@ -0,0 +1,98 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
static VGPath path;
|
||||
static VGPaint fill;
|
||||
|
||||
VGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGubyte commands[5] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH};
|
||||
VGfloat coords[8] = {0.0f,0.0f, 32.0f,0.0f, 32.0f,32.0f, 0.0f,32.0f };
|
||||
|
||||
VGfloat rampStop[20] = {-0.5f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.25f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.75f, 0.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.5f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
VGfloat defaultColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
VGfloat linearGradient[4] = {0.0f, 0.0f, 0.0f, 32.0f};
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
if (path == VG_INVALID_HANDLE)
|
||||
return;
|
||||
|
||||
fill = vgCreatePaint();
|
||||
if (fill == VG_INVALID_HANDLE) {
|
||||
vgDestroyPath(path);
|
||||
return;
|
||||
}
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, defaultColor);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
|
||||
vgAppendPathData(path, 5, commands, coords);
|
||||
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
|
||||
vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE,
|
||||
VG_COLOR_RAMP_SPREAD_REPEAT);
|
||||
vgSetParameterfv(fill, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
const char *arg = argv[1];
|
||||
if (!strcmp("-pad", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
else if (!strcmp("-repeat", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REPEAT;
|
||||
else if (!strcmp("-reflect", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REFLECT;
|
||||
}
|
||||
|
||||
switch(spread) {
|
||||
case VG_COLOR_RAMP_SPREAD_PAD:
|
||||
printf("Using spread mode: pad\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REPEAT:
|
||||
printf("Using spread mode: repeat\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REFLECT:
|
||||
printf("Using spread mode: reflect\n");
|
||||
}
|
||||
|
||||
set_window_size(200, 200);
|
||||
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
56
progs/openvg/trivial/lineto.c
Normal file
56
progs/openvg/trivial/lineto.c
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat sqrCoords[5] = {50.0f, 50.0f, 250.0f, 250.0f, 50.0f};
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 5, sqrCmds, sqrCoords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 10);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
|
||||
vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_STROKE_PAINT_TO_USER);
|
||||
vgLoadIdentity();
|
||||
vgScale(2.25, 2.25);
|
||||
vgDrawPath(path, VG_STROKE_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
87
progs/openvg/trivial/lingrad.c
Normal file
87
progs/openvg/trivial/lingrad.c
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
static VGPath path;
|
||||
static VGPaint fill;
|
||||
|
||||
VGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat sqrCoords[5] = {0.0f, 0.0f, 400.0f, 400.0f, 0.0f};
|
||||
|
||||
VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.33f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.66f, 0.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.00f, 0.0f, 0.0f, 1.0f, 1.0f};
|
||||
VGfloat linearGradient[4] = {100.0f, 100.0f, 300.0f, 300.0f};
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 5, sqrCmds, sqrCoords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
|
||||
vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spread);
|
||||
vgSetParameterfv(fill, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
const char *arg = argv[1];
|
||||
if (!strcmp("-pad", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
else if (!strcmp("-repeat", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REPEAT;
|
||||
else if (!strcmp("-reflect", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REFLECT;
|
||||
}
|
||||
|
||||
switch(spread) {
|
||||
case VG_COLOR_RAMP_SPREAD_PAD:
|
||||
printf("Using spread mode: pad\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REPEAT:
|
||||
printf("Using spread mode: repeat\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REFLECT:
|
||||
printf("Using spread mode: reflect\n");
|
||||
}
|
||||
|
||||
set_window_size(400, 400);
|
||||
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
71
progs/openvg/trivial/lookup.c
Normal file
71
progs/openvg/trivial/lookup.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {1.0, 1.0, 1.0, 0.5};
|
||||
VGfloat clearColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
|
||||
VGImage parent;
|
||||
|
||||
VGPaint fill;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGImage child1, child2;
|
||||
VGubyte *data;
|
||||
VGuint LUT[256];
|
||||
VGint i;
|
||||
|
||||
data = (VGubyte *)malloc(sizeof(VGubyte)*window_width()*window_height());
|
||||
|
||||
for (i=0;i<window_width()*window_height();i++) {
|
||||
data[i] = 0x00;
|
||||
}
|
||||
|
||||
for (i=0; i<256; i++) {
|
||||
if ( i == 0 )
|
||||
LUT[0] = 0xFFFFFFFF;
|
||||
else
|
||||
LUT[i] = 0xFF00FFFF;
|
||||
}
|
||||
|
||||
parent = vgCreateImage( VG_A_8, 64, 64, VG_IMAGE_QUALITY_NONANTIALIASED );
|
||||
|
||||
vgImageSubData(parent, data, window_width(), VG_A_8, 0, 0,
|
||||
window_width(), window_height());
|
||||
child1 = vgChildImage(parent, 0, 0, 32, 64);
|
||||
child2 = vgChildImage(parent, 32, 0, 32, 64);
|
||||
|
||||
vgLookupSingle(child2, child1, LUT, VG_GREEN, VG_FALSE, VG_TRUE);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
//vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
||||
//vgLoadIdentity();
|
||||
//vgTranslate(10, 10);
|
||||
vgDrawImage(parent);
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
58
progs/openvg/trivial/mask.c
Normal file
58
progs/openvg/trivial/mask.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat sqrCoords[5] = {50.0f, 50.0f, 250.0f, 250.0f, 50.0f};
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 5, sqrCmds, sqrCoords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 10);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
|
||||
vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
|
||||
|
||||
vgSeti(VG_MASKING, VG_TRUE);
|
||||
|
||||
vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK,
|
||||
25, 25, 100, 100);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
132
progs/openvg/trivial/mask4.c
Normal file
132
progs/openvg/trivial/mask4.c
Normal file
@@ -0,0 +1,132 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <VG/vgu.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
//VGint x_pos = -10, y_pos = -10;
|
||||
VGint x_pos = 0, y_pos = 4;
|
||||
VGint img_width = 120, img_height = 120;
|
||||
|
||||
static void RectToPath(VGPath path, VGfloat x, VGfloat y, VGfloat width, VGfloat height)
|
||||
{
|
||||
static const VGubyte segments[5] = {VG_MOVE_TO_ABS,
|
||||
VG_HLINE_TO_ABS,
|
||||
VG_VLINE_TO_ABS,
|
||||
VG_HLINE_TO_ABS,
|
||||
VG_CLOSE_PATH};
|
||||
VGfloat data[5];
|
||||
|
||||
data[0] = x;
|
||||
data[1] = y;
|
||||
data[2] = x + width;
|
||||
data[3] = y + height;
|
||||
data[4] = x;
|
||||
|
||||
vgAppendPathData(path, 5, segments, data);
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
int key_press(unsigned key)
|
||||
{
|
||||
switch(key) {
|
||||
case XK_Right:
|
||||
x_pos +=1;
|
||||
break;
|
||||
case XK_Left:
|
||||
x_pos -=1;
|
||||
break;
|
||||
case XK_Up:
|
||||
y_pos +=1;
|
||||
break;
|
||||
case XK_Down:
|
||||
y_pos -=1;
|
||||
break;
|
||||
case 'a':
|
||||
img_width -= 5;
|
||||
img_height -= 5;
|
||||
break;
|
||||
case 's':
|
||||
img_width += 5;
|
||||
img_height += 5;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fprintf(stderr, "Posi = %dx%d\n", x_pos, y_pos);
|
||||
fprintf(stderr, "Size = %dx%d\n", img_width, img_height);
|
||||
return VG_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGint WINDSIZEX = window_width();
|
||||
VGint WINDSIZEY = window_height();
|
||||
|
||||
VGPaint fill;
|
||||
VGPath box;
|
||||
VGfloat color[4] = {1.f, 0.f, 0.f, 1.f};
|
||||
VGfloat bgCol[4] = {0.7f, 0.7f, 0.7f, 1.0f};
|
||||
VGfloat transCol[4] = {0.f, 0.f, 0.f, 0.f};
|
||||
VGImage image = vgCreateImage(VG_sRGBA_8888, img_width, img_height,
|
||||
VG_IMAGE_QUALITY_NONANTIALIASED);
|
||||
|
||||
/* Background clear */
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
box = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
/* Rectangle to cover completely 16x16 pixel area. */
|
||||
RectToPath(box, 0, 0, 64, 64);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, transCol);
|
||||
vgClearImage(image, 0, 0, img_width, img_height);
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, color);
|
||||
vgClearImage(image, 10, 10, 12, 12);
|
||||
//vgImageSubData(image, pukki_64x64_data, pukki_64x64_stride,
|
||||
// VG_sRGBA_8888, 0, 0, 32, 32);
|
||||
vgSeti(VG_MASKING, VG_TRUE);
|
||||
vgLoadIdentity();
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, bgCol);
|
||||
vgClear(0, 0, WINDSIZEX, WINDSIZEY);
|
||||
|
||||
|
||||
vgMask(image, VG_FILL_MASK, 0, 0, window_width(), window_height());
|
||||
vgMask(image, VG_SET_MASK, x_pos, y_pos, 100, 100);
|
||||
|
||||
vgDrawPath(box, VG_FILL_PATH);
|
||||
|
||||
//vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
||||
//vgTranslate(-10, -10);
|
||||
//vgDrawImage(image);
|
||||
|
||||
|
||||
vgDestroyPaint(fill);
|
||||
vgDestroyPath(box);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, key_press);
|
||||
}
|
77
progs/openvg/trivial/path3.c
Normal file
77
progs/openvg/trivial/path3.c
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <VG/vgu.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGint WINDSIZEX = window_width();
|
||||
VGint WINDSIZEY = window_height();
|
||||
VGPath path;
|
||||
VGPaint paint;
|
||||
|
||||
VGfloat clearColor[] = {1.0f, 1.0f, 1.0f, 0.0f};/* white color */
|
||||
VGfloat fillColor[] = {1.0f, 0.0f, 0.0f, 1.0f};/* red color */
|
||||
|
||||
#if 1
|
||||
VGubyte commands[4] = {VG_MOVE_TO_ABS, VG_LCWARC_TO_ABS, VG_SCWARC_TO_ABS, VG_CLOSE_PATH};
|
||||
#else
|
||||
VGubyte commands[4] = {VG_MOVE_TO_ABS, VG_SCCWARC_TO_ABS, VG_LCCWARC_TO_ABS,VG_CLOSE_PATH};
|
||||
#endif
|
||||
VGfloat coords[] = {32.0f, 0.0f,
|
||||
-32.0f, -32.0f, 0.0f, 64.0f, 32.0f,
|
||||
-32.0f, -32.0f, 0.0f, 32.0f, 0.0f};
|
||||
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
vgClear(0, 0, WINDSIZEX, WINDSIZEY);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
|
||||
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
||||
vgLoadIdentity();
|
||||
//vgTranslate(32.0f, 32.0f);
|
||||
|
||||
path = vgCreatePath( VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL );
|
||||
if ( path == VG_INVALID_HANDLE ) {
|
||||
return;
|
||||
}
|
||||
paint = vgCreatePaint();
|
||||
if ( paint == VG_INVALID_HANDLE ) {
|
||||
vgDestroyPath(path);
|
||||
return;
|
||||
}
|
||||
|
||||
vgAppendPathData(path, 4, commands, coords);
|
||||
vgSetParameterfv(paint, VG_PAINT_COLOR, 4, fillColor);
|
||||
vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
vgSetPaint(paint, VG_FILL_PATH);
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgDestroyPath(path);
|
||||
vgDestroyPaint(paint);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
set_window_size(64, 64);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
99
progs/openvg/trivial/radialgrad.c
Normal file
99
progs/openvg/trivial/radialgrad.c
Normal file
@@ -0,0 +1,99 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
static VGPath path;
|
||||
static VGPaint fill;
|
||||
|
||||
|
||||
VGfloat centeredGradient[5] = {200.0f, 200.0f, 200.0f, 200.0f, 100};
|
||||
VGfloat noncenteredGradient[5] = {200.0f, 200.0f, 250.0f, 250.0f, 100};
|
||||
VGfloat *radialGradient = centeredGradient;
|
||||
|
||||
VGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat sqrCoords[5] = {0.0f, 0.0f, 400.0f, 400.0f, 0.0f};
|
||||
|
||||
VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.33f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.66f, 0.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.00f, 0.0f, 0.0f, 1.0f, 1.0f};
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 5, sqrCmds, sqrCoords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT);
|
||||
vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spread);
|
||||
vgSetParameterfv(fill, VG_PAINT_RADIAL_GRADIENT, 5, radialGradient);
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
VGint i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
const char *arg = argv[i];
|
||||
if (!strcmp("-pad", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_PAD;
|
||||
else if (!strcmp("-repeat", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REPEAT;
|
||||
else if (!strcmp("-reflect", arg))
|
||||
spread = VG_COLOR_RAMP_SPREAD_REFLECT;
|
||||
else if (!strcmp("-center", arg)) {
|
||||
printf("Centered radial gradient\n");
|
||||
radialGradient = centeredGradient;
|
||||
} else if (!strcmp("-noncenter", arg)) {
|
||||
printf("Non centered radial gradient\n");
|
||||
radialGradient = noncenteredGradient;
|
||||
}
|
||||
}
|
||||
|
||||
switch(spread) {
|
||||
case VG_COLOR_RAMP_SPREAD_PAD:
|
||||
printf("Using spread mode: pad\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REPEAT:
|
||||
printf("Using spread mode: repeat\n");
|
||||
break;
|
||||
case VG_COLOR_RAMP_SPREAD_REFLECT:
|
||||
printf("Using spread mode: reflect\n");
|
||||
}
|
||||
|
||||
set_window_size(400, 400);
|
||||
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
75
progs/openvg/trivial/readpixels.c
Normal file
75
progs/openvg/trivial/readpixels.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
float red_color[4] = {1.0, 0.0, 0.0, 1.0};
|
||||
float blue_color[4] = {0.0, 0.0, 1.0, 1.0};
|
||||
VGint *data;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
data = malloc(sizeof(VGint)*2048*2048);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
static const VGint red_pixel = 255 << 24 | 255 << 16 | 0 << 8 | 0;
|
||||
static const VGint blue_pixel = 255 << 24 | 0 << 16 | 0 << 8 | 255;
|
||||
VGint i;
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, red_color);
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgFlush();
|
||||
|
||||
memset(data, 0, window_width() * window_height() * sizeof(VGint));
|
||||
|
||||
vgReadPixels(data, window_width() * sizeof(VGint),
|
||||
VG_lARGB_8888,
|
||||
0, 0, window_width(), window_height());
|
||||
|
||||
fprintf(stderr, "Red 0 = 0x%x and at 600 = 0x%x\n",
|
||||
data[0], data[600]);
|
||||
for (i = 0; i < window_width() * window_height(); ++i) {
|
||||
assert(data[i] == red_pixel);
|
||||
}
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, blue_color);
|
||||
vgClear(50, 50, 50, 50);
|
||||
vgFlush();
|
||||
|
||||
memset(data, 0, window_width() * window_height() * sizeof(VGint));
|
||||
|
||||
vgReadPixels(data, 50 * sizeof(VGint),
|
||||
VG_lARGB_8888,
|
||||
50, 50, 50, 50);
|
||||
|
||||
fprintf(stderr, "Blue 0 = 0x%x and at 100 = 0x%x\n",
|
||||
data[0], data[100]);
|
||||
for (i = 0; i < 50 * 50; ++i) {
|
||||
assert(data[i] == blue_pixel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
67
progs/openvg/trivial/roundedrect.c
Normal file
67
progs/openvg/trivial/roundedrect.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.9, 0.1, 0.1, 0.8};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte sqrCmds[10] = {VG_MOVE_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
VG_CLOSE_PATH};
|
||||
static const VGfloat sqrCoords[] = {
|
||||
45.885571, 62.857143,
|
||||
154.11442, 62.857143,
|
||||
162.1236, 62.857143, 168.57142, 70.260744, 168.57142, 79.457144,
|
||||
168.57142, 123.4,
|
||||
168.57142, 132.5964, 162.1236, 140, 154.11442, 140,
|
||||
45.885571, 140,
|
||||
37.876394, 140, 31.428572, 132.5964, 31.428572, 123.4,
|
||||
31.428572, 79.457144,
|
||||
31.428572, 70.260744, 37.876394,62.857143, 45.885571,62.857143
|
||||
};
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 10, sqrCmds, sqrCoords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 6);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_STROKE_PATH);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
55
progs/openvg/trivial/star-nonzero.c
Normal file
55
progs/openvg/trivial/star-nonzero.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat green_color[4] = {0.0, 1.0, 0.0, 0.8};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte cmds[6] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
|
||||
VG_LINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat coords[] = { 0, 200,
|
||||
300, 200,
|
||||
50, 0,
|
||||
150, 300,
|
||||
250, 0};
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 6, cmds, coords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, green_color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSeti(VG_FILL_RULE, VG_NON_ZERO);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_FILL_PATH | VG_STROKE_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
102
progs/openvg/trivial/star-oddeven.c
Normal file
102
progs/openvg/trivial/star-oddeven.c
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat green_color[4] = {0.0, 1.0, 0.0, 0.8};
|
||||
const VGfloat black_color[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
|
||||
static void draw_point(VGfloat x, VGfloat y)
|
||||
{
|
||||
|
||||
static const VGubyte cmds[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
|
||||
VG_LINE_TO_ABS, VG_CLOSE_PATH};
|
||||
const VGfloat coords[] = { x - 2, y - 2,
|
||||
x + 2, y - 2,
|
||||
x + 2, y + 2,
|
||||
x - 2, y + 2};
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(path, 5, cmds, coords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, black_color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
vgDestroyPath(path);
|
||||
vgDestroyPaint(fill);
|
||||
}
|
||||
|
||||
static void draw_marks(VGPath path)
|
||||
{
|
||||
VGfloat point[2], tangent[2];
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < 1300; i += 50) {
|
||||
vgPointAlongPath(path, 0, 6, i,
|
||||
point + 0, point + 1,
|
||||
tangent + 0, tangent + 1);
|
||||
draw_point(point[0], point[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const VGubyte cmds[6] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
|
||||
VG_LINE_TO_ABS, VG_CLOSE_PATH};
|
||||
static const VGfloat coords[] = { 0, 200,
|
||||
300, 200,
|
||||
50, 0,
|
||||
150, 300,
|
||||
250, 0};
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_ALL);
|
||||
vgAppendPathData(path, 6, cmds, coords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, green_color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
VGfloat point[2], tangent[2];
|
||||
int i = 0;
|
||||
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
vgDrawPath(path, VG_FILL_PATH);
|
||||
|
||||
draw_marks(path);
|
||||
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
116
progs/openvg/trivial/stroke.c
Normal file
116
progs/openvg/trivial/stroke.c
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint fill;
|
||||
|
||||
VGint cap_style = VG_CAP_BUTT;
|
||||
VGint join_style = VG_JOIN_MITER;
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
#if 0
|
||||
static const VGubyte cmds[] = {VG_MOVE_TO_ABS,
|
||||
VG_CUBIC_TO_ABS,
|
||||
};
|
||||
static const VGfloat coords[] = {30, 30, 264, 0, 0, 264, 234, 234
|
||||
};
|
||||
#else
|
||||
static const VGubyte cmds[] = {VG_MOVE_TO_ABS,
|
||||
VG_LINE_TO_ABS,
|
||||
VG_LINE_TO_ABS
|
||||
};
|
||||
static const VGfloat coords[] = {30, 30, 202, 30, 150, 224
|
||||
};
|
||||
#endif
|
||||
VGfloat dash_pattern[2] = { 20.f, 20.f };
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO);
|
||||
vgAppendPathData(path, 3, cmds, coords);
|
||||
|
||||
fill = vgCreatePaint();
|
||||
vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
|
||||
vgSetPaint(fill, VG_FILL_PATH);
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, white_color);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 20);
|
||||
vgSeti(VG_STROKE_CAP_STYLE, cap_style);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, join_style);
|
||||
vgSetfv(VG_STROKE_DASH_PATTERN, 2, dash_pattern);
|
||||
vgSetf(VG_STROKE_DASH_PHASE, 0.0f);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_STROKE_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
static int key_press(unsigned key)
|
||||
{
|
||||
switch(key) {
|
||||
case XK_c:
|
||||
case XK_C:
|
||||
++cap_style;
|
||||
if (cap_style > VG_CAP_SQUARE)
|
||||
cap_style = VG_CAP_BUTT;
|
||||
switch(cap_style) {
|
||||
case VG_CAP_BUTT:
|
||||
fprintf(stderr, "Cap style 'butt'\n");
|
||||
break;
|
||||
case VG_CAP_ROUND:
|
||||
fprintf(stderr, "Cap style 'round'\n");
|
||||
break;
|
||||
case VG_CAP_SQUARE:
|
||||
fprintf(stderr, "Cap style 'square'\n");
|
||||
break;
|
||||
}
|
||||
vgSeti(VG_STROKE_CAP_STYLE, cap_style);
|
||||
break;
|
||||
case XK_j:
|
||||
case XK_J:
|
||||
++join_style;
|
||||
if (join_style > VG_JOIN_BEVEL)
|
||||
join_style = VG_JOIN_MITER;
|
||||
switch(join_style) {
|
||||
case VG_JOIN_MITER:
|
||||
fprintf(stderr, "Join style 'miter'\n");
|
||||
break;
|
||||
case VG_JOIN_ROUND:
|
||||
fprintf(stderr, "Join style 'round'\n");
|
||||
break;
|
||||
case VG_JOIN_BEVEL:
|
||||
fprintf(stderr, "Join style 'bevel'\n");
|
||||
break;
|
||||
}
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, join_style);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VG_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, key_press);
|
||||
}
|
207
progs/openvg/trivial/stroke2.c
Normal file
207
progs/openvg/trivial/stroke2.c
Normal file
@@ -0,0 +1,207 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <stdio.h>
|
||||
|
||||
VGPaint stroke;
|
||||
VGPath target;
|
||||
VGPath lines;
|
||||
|
||||
VGfloat xform[9];
|
||||
VGfloat color1[4];
|
||||
VGfloat color2[4];
|
||||
VGfloat bgCol[4];
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGubyte lineCmds[6];
|
||||
VGfloat lineCoords[8];
|
||||
VGfloat arcCoords[5];
|
||||
VGubyte sccCmd[1];
|
||||
VGubyte scCmd[1];
|
||||
VGubyte lccCmd[1];
|
||||
VGubyte lcCmd[1];
|
||||
VGubyte moveCmd[1];
|
||||
VGfloat moveCoords[2];
|
||||
VGint i;
|
||||
|
||||
bgCol[0] = 1.0f;
|
||||
bgCol[1] = 1.0f;
|
||||
bgCol[2] = 1.0f;
|
||||
bgCol[3] = 1.0f;
|
||||
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, bgCol);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
|
||||
stroke = vgCreatePaint();
|
||||
/* Red */
|
||||
color1[0] = 1.0f;
|
||||
color1[1] = 0.0f;
|
||||
color1[2] = 0.0f;
|
||||
color1[3] = 1.0f;
|
||||
|
||||
/* Orange */
|
||||
color2[0] = 1.0000f;
|
||||
color2[1] = 1.0f;
|
||||
color2[2] = 0.0f;
|
||||
color2[3] = 1.0f;
|
||||
vgSetPaint(stroke, VG_STROKE_PATH);
|
||||
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_SQUARE);
|
||||
|
||||
{
|
||||
VGfloat temp[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
xform[i] = temp[i];
|
||||
}
|
||||
}
|
||||
vgGetMatrix(xform);
|
||||
|
||||
target = vgCreatePath(VG_PATH_FORMAT_STANDARD,
|
||||
VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_TRANSFORM_TO);
|
||||
|
||||
#if 0
|
||||
/* Line path */
|
||||
{
|
||||
VGubyte temp[6] = {VG_MOVE_TO_ABS, VG_VLINE_TO_REL,
|
||||
VG_MOVE_TO_ABS, VG_VLINE_TO_REL,
|
||||
VG_HLINE_TO_REL, VG_VLINE_TO_REL};
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
lineCmds[i] = temp[i];
|
||||
}
|
||||
}
|
||||
{
|
||||
VGfloat temp[8] = {0.5f, 0.8f, -0.6f, 0.28f, 0.6f, -0.4f, 0.44f, 0.4f};
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
lineCoords[i] = temp[i] * window_width();
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
VGfloat temp[5] = {0.35f, 0.15f, 29, 0.3f, 0.4f};
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
arcCoords[i] = temp[i] * window_width();
|
||||
}
|
||||
arcCoords[2] = 29;
|
||||
}
|
||||
|
||||
{
|
||||
VGubyte temp[1] = {VG_SCCWARC_TO_ABS};
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
sccCmd[i] = temp[i];
|
||||
}
|
||||
}
|
||||
{
|
||||
VGubyte temp[1] = {VG_SCWARC_TO_ABS};
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
scCmd[i] = temp[i];
|
||||
}
|
||||
}
|
||||
{
|
||||
VGubyte temp[1] = {VG_LCCWARC_TO_ABS};
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
lccCmd[i] = temp[i];
|
||||
}
|
||||
}
|
||||
{
|
||||
VGubyte temp[1] = {VG_LCWARC_TO_ABS};
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
lcCmd[i] = temp[i];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
VGubyte temp[1] = {VG_MOVE_TO_ABS};
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
moveCmd[i] = temp[i];
|
||||
}
|
||||
}
|
||||
{
|
||||
VGfloat temp[2] = {0.7f, 0.6f};
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
moveCoords[i] = temp[i] * window_width();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
lines = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1,
|
||||
0, 0, 0,
|
||||
VG_PATH_CAPABILITY_APPEND_TO|
|
||||
VG_PATH_CAPABILITY_TRANSFORM_FROM);
|
||||
#if 0
|
||||
vgAppendPathData(lines, 6, lineCmds, lineCoords);
|
||||
#else
|
||||
vgAppendPathData(lines, 1, moveCmd, moveCoords);
|
||||
vgAppendPathData(lines, 1, sccCmd, arcCoords);
|
||||
vgAppendPathData(lines, 1, moveCmd, moveCoords);
|
||||
vgAppendPathData(lines, 1, scCmd, arcCoords);
|
||||
vgAppendPathData(lines, 1, moveCmd, moveCoords);
|
||||
vgAppendPathData(lines, 1, lccCmd, arcCoords);
|
||||
vgAppendPathData(lines, 1, moveCmd, moveCoords);
|
||||
vgAppendPathData(lines, 1, lcCmd, arcCoords);
|
||||
#endif
|
||||
|
||||
vgLoadIdentity();
|
||||
vgTranslate(0.25f * window_width(), 0.25f * window_height());
|
||||
vgRotate(30);
|
||||
vgTranslate(-0.25f * window_width(), -0.25f * window_height());
|
||||
vgTransformPath(target, lines);}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgLoadMatrix(xform);
|
||||
vgLoadIdentity();
|
||||
vgTranslate(0.25f * window_width(), 0.25f * window_height());
|
||||
vgRotate(30);
|
||||
vgTranslate(-0.25f * window_width(), -0.25f * window_height());
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 7);
|
||||
vgSetParameterfv(stroke, VG_PAINT_COLOR, 4, color1);
|
||||
vgDrawPath(lines, VG_STROKE_PATH);
|
||||
|
||||
vgLoadMatrix(xform);
|
||||
vgSetParameterfv(stroke, VG_PAINT_COLOR, 4, color2);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 3);
|
||||
vgDrawPath(target, VG_STROKE_PATH);
|
||||
}
|
||||
|
||||
static int key_press(unsigned key)
|
||||
{
|
||||
switch(key) {
|
||||
case XK_c:
|
||||
case XK_C:
|
||||
break;
|
||||
case XK_j:
|
||||
case XK_J:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return VG_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, key_press);
|
||||
}
|
74
progs/openvg/trivial/vguarc.c
Normal file
74
progs/openvg/trivial/vguarc.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "eglcommon.h"
|
||||
|
||||
#include <VG/openvg.h>
|
||||
#include <VG/vgu.h>
|
||||
|
||||
const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
const VGfloat color[4] = {0.4, 0.1, 1.0, 1.0};
|
||||
|
||||
VGPath path;
|
||||
VGPaint paint;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
VGfloat clearColor[] = {0.0f, 0.0f, 0.0f, 1.0f};/* black color */
|
||||
VGfloat greenColor[] = {0.0f, 1.0f, 0.0f, 1.0f};/* green color */
|
||||
VGint arcType = VGU_ARC_OPEN;
|
||||
VGfloat x, y, w, h, startAngle, angleExtent;
|
||||
|
||||
x = 150;
|
||||
y = 150;
|
||||
w = 150;
|
||||
h = 150;
|
||||
#if 0
|
||||
startAngle = -540.0f;
|
||||
angleExtent = 270.0f;
|
||||
#else
|
||||
startAngle = 270.0f;
|
||||
angleExtent = 90.0f;
|
||||
#endif
|
||||
|
||||
paint = vgCreatePaint();
|
||||
|
||||
vgSetPaint(paint, VG_STROKE_PATH);
|
||||
vgSetParameterfv(paint, VG_PAINT_COLOR, 4, greenColor);
|
||||
vgSetParameteri( paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
|
||||
vgSetf(VG_STROKE_LINE_WIDTH, 6.0f);
|
||||
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
||||
vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
|
||||
|
||||
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
|
||||
1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
|
||||
|
||||
vguArc(path, x, y, w, h, startAngle, angleExtent, arcType);
|
||||
|
||||
vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
|
||||
vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_BEVEL);
|
||||
vgSetf(VG_STROKE_MITER_LIMIT, 4.0f);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
vgLoadIdentity();
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
vgClear(0, 0, window_width(), window_height());
|
||||
vgDrawPath(path, VG_STROKE_PATH);
|
||||
|
||||
vgFlush();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// set_window_size(64, 63);
|
||||
return run(argc, argv, init, reshape,
|
||||
draw, 0);
|
||||
}
|
Reference in New Issue
Block a user