mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-06 16:30:42 +01:00
Merge branch 'master' of git+ssh://agd5f@git.freedesktop.org/git/mesa/mesa into r6xx-rewrite
This builds, but I get an assertion in radeonGetLock() due to the drawable being null.
This commit is contained in:
commit
c5c19919ce
585 changed files with 51101 additions and 11089 deletions
|
|
@ -32,10 +32,10 @@ import common
|
|||
default_statetrackers = 'mesa'
|
||||
|
||||
if common.default_platform in ('linux', 'freebsd', 'darwin'):
|
||||
default_drivers = 'softpipe,failover,i915simple,trace'
|
||||
default_drivers = 'softpipe,failover,i915simple,trace,identity'
|
||||
default_winsys = 'xlib'
|
||||
elif common.default_platform in ('winddk',):
|
||||
default_drivers = 'softpipe,i915simple,trace'
|
||||
default_drivers = 'softpipe,i915simple,trace,identity'
|
||||
default_winsys = 'all'
|
||||
else:
|
||||
default_drivers = 'all'
|
||||
|
|
@ -46,7 +46,7 @@ common.AddOptions(opts)
|
|||
opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
|
||||
['mesa', 'python']))
|
||||
opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
|
||||
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300']))
|
||||
['softpipe', 'failover', 'i915simple', 'i965simple', 'cell', 'trace', 'r300', 'identity']))
|
||||
opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
|
||||
['xlib', 'intel', 'gdi', 'radeon']))
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ X11_DIR = $(INSTALL_DIR)
|
|||
|
||||
# Compiler and flags
|
||||
CC = gcc
|
||||
CXX = gcc
|
||||
CXX = g++
|
||||
PIC_FLAGS = -fPIC
|
||||
DEFINES = -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
|
||||
-D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS \
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ EGL_DRIVERS_DIRS = demo
|
|||
GALLIUM_DIRS = auxiliary drivers state_trackers
|
||||
GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices
|
||||
GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace
|
||||
GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace identity
|
||||
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_WINSYS_DIRS = xlib egl_xlib
|
||||
GALLIUM_WINSYS_DRM_DIRS =
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ GALLIUM_DIRS="auxiliary drivers state_trackers"
|
|||
GALLIUM_WINSYS_DIRS=""
|
||||
GALLIUM_WINSYS_DRM_DIRS=""
|
||||
GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
|
||||
GALLIUM_DRIVERS_DIRS="softpipe failover trace"
|
||||
GALLIUM_DRIVERS_DIRS="softpipe failover trace identity"
|
||||
GALLIUM_STATE_TRACKERS_DIRS=""
|
||||
|
||||
case "$mesa_driver" in
|
||||
|
|
@ -656,7 +656,7 @@ dnl Which drivers to build - default is chosen by platform
|
|||
AC_ARG_WITH([dri-drivers],
|
||||
[AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
|
||||
[comma delimited DRI drivers list, e.g.
|
||||
"swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
|
||||
"swrast,i965,radeon" @<:@default=auto@:>@])],
|
||||
[with_dri_drivers="$withval"],
|
||||
[with_dri_drivers=yes])
|
||||
if test "x$with_dri_drivers" = x; then
|
||||
|
|
|
|||
|
|
@ -123,48 +123,46 @@ These are the instructions for making a new Mesa release.
|
|||
|
||||
<H3>Get latest source files</H3>
|
||||
<p>
|
||||
Use "cvs update -dAP " to get the latest Mesa files from CVS.
|
||||
Use git to get the latest Mesa files from the git repository, from whatever
|
||||
branch is relevant.
|
||||
</p>
|
||||
|
||||
|
||||
<H3>Verify and update version info</H3>
|
||||
<p>
|
||||
Create/edit the docs/RELNOTES-X.Y file to document what's new in the release.
|
||||
Add the new RELNOTES-X.Y file to <a href="relnotes.html">relnotes.html</a>.
|
||||
Update the docs/VERSIONS file too.
|
||||
Create/edit the docs/relnotes-x.y.html file to document what's new in the release.
|
||||
Add the new relnotes-x.y.html file to <a href="relnotes.html">relnotes.html</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Edit the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
|
||||
Update the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
|
||||
configs/default.
|
||||
Also update the VERSION line in the top-level Makefile.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Make sure the values in src/mesa/main/version.h are correct.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Edit the top-level Makefile and verify that DIRECTORY, LIB_NAME and
|
||||
DEMO_NAME are correct.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Update the docs/news.html file and docs/download.html files.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Check in all updates to CVS.
|
||||
Check in all updates to git.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Tag the CVS files with the release name (in the form <b>mesa_X_Y</b>).
|
||||
Tag the files with the release name (in the form <b>mesa_X_Y</b>)
|
||||
with: <code>git tag -a mesa_X_Y</code>
|
||||
Then: <code>git push origin mesa_X_Y</code>
|
||||
</p>
|
||||
|
||||
|
||||
<H3>Make the tarballs</H3>
|
||||
<p>
|
||||
Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
|
||||
ln -s Mesa Mesa-6.3
|
||||
<code>ln -s Mesa Mesa-7.5</code>
|
||||
This is needed in order to make a correct tar file in the next step.
|
||||
</p>
|
||||
|
||||
|
|
@ -177,7 +175,7 @@ Make the distribution files. From inside the Mesa directory:
|
|||
<p>
|
||||
After the tarballs are created, the md5 checksums for the files will
|
||||
be computed.
|
||||
Add them to the docs/news.html file.
|
||||
Add them to the docs/relnotes-X.Y.html file.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -191,9 +189,21 @@ Follow the directions on SourceForge for creating a new "release" and
|
|||
uploading the tarballs.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Basically, to upload the tarball files with:
|
||||
<br>
|
||||
<code>
|
||||
rsync -avP ssh Mesa*-X.Y.* USERNAME@frs.sourceforge.net:uploads/
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Update the web site by copying the docs/ directory's files to
|
||||
/home/users/b/br/brianp/mesa-www/htdocs/
|
||||
/home/users/b/br/brianp/mesa-www/htdocs/ with:
|
||||
<br>
|
||||
<code>
|
||||
sftp USERNAME,mesa3d@web.sourceforge.net
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
|
||||
</ul>
|
||||
<li><a href="#windows">Windows</a>
|
||||
<li><a href="#scons">SCons</a>
|
||||
<li><a href="#other">Other</a>
|
||||
</ol>
|
||||
<br>
|
||||
|
|
@ -328,13 +329,60 @@ For example, compiling and linking a GLUT application can be done with:
|
|||
<H2>2. Windows Compilation and Installation</H1>
|
||||
|
||||
<p>
|
||||
Please see the <a href="README.WIN32">README.WIN32</a> file.
|
||||
Please see the <a href="#scons">instructions on building with SCons</a>.
|
||||
Alternatively see <a href="README.WIN32">README.WIN32</a> file.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<a name="scons">
|
||||
<H2>3. Building with SCons</H1>
|
||||
|
||||
<p>
|
||||
To build Mesa with SCons on Linux or Windows do
|
||||
</p>
|
||||
<pre>
|
||||
scons
|
||||
</pre>
|
||||
<p>
|
||||
The build output will be placed in
|
||||
build/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for
|
||||
example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
|
||||
by -debug for debug builds.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The sample programs are built seperately. To build them do
|
||||
<pre>
|
||||
scons -C progs
|
||||
</pre>
|
||||
And the build output will be placed in progs/build/...
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
|
||||
</p>
|
||||
<pre>
|
||||
scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
|
||||
scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
|
||||
</pre>
|
||||
<p>
|
||||
This will create:
|
||||
</p>
|
||||
<ul>
|
||||
<li>build/windows-x86-debug/gallium/winsys/gdi/opengl32.dll — Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll
|
||||
<li>build/windows-x86-debug/glut/glx/glut32.dll
|
||||
<li>progs/build/windows-x86-debug/wgl/wglinfo.exe
|
||||
<li>progs/build/windows-x86-debug/trivial/tri.exe
|
||||
<li>and many other samples in progs/build/windows-x86-debug/...
|
||||
</ul>
|
||||
<p>
|
||||
Put them all in the same directory to test them.
|
||||
</p>
|
||||
|
||||
|
||||
<a name="other">
|
||||
<H2>3. Other systems</H1>
|
||||
<H2>4. Other systems</H1>
|
||||
|
||||
<p>
|
||||
Documentation for other environments (some may be very out of date):
|
||||
|
|
|
|||
|
|
@ -11,6 +11,21 @@
|
|||
<H1>News</H1>
|
||||
|
||||
|
||||
<h2>June 23, 2009</h2>
|
||||
<p>
|
||||
<a href="relnotes-7.4.4.html">Mesa 7.4.4</a> is released.
|
||||
This is a stable release that fixes a regression in the i915/i965 drivers
|
||||
that slipped into the 7.4.3 release.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>June 19, 2009</h2>
|
||||
<p>
|
||||
<a href="relnotes-7.4.3.html">Mesa 7.4.3</a> is released.
|
||||
This is a stable release fixing bugs since the 7.4.2 release.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>May 15, 2009</h2>
|
||||
<p>
|
||||
<a href="relnotes-7.4.2.html">Mesa 7.4.2</a> is released.
|
||||
|
|
|
|||
68
docs/openvg.html
Normal file
68
docs/openvg.html
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>OpenVG State Tracker</H1>
|
||||
|
||||
<p>
|
||||
The current version of the OpenVG state tracker implements OpenVG 1.0.
|
||||
</p>
|
||||
<p>
|
||||
More informations about OpenVG can be found at
|
||||
<a href="http://www.khronos.org/openvg/" target="_parent">
|
||||
http://www.khronos.org/openvg/</a> .
|
||||
</p>
|
||||
<p>
|
||||
The OpenVG state tracker depends on the Gallium architecture and a working EGL implementation.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>Building the library</h2>
|
||||
<ol>
|
||||
<li>Build Mesa3D with Gallium3D. Any build that builds Gallium3D libraries and EGL will suffice</li>
|
||||
<li>cd src/gallium/state_trackers/vega; make</li>
|
||||
<li>The last step will build libOpenVG library. You can add the libdir to LD_LIBRARY_PATH or install libOpenVG</li>
|
||||
</ol>
|
||||
|
||||
<h3>Sample build</h3>
|
||||
A sample build looks as follows:
|
||||
<pre>
|
||||
make linux-x86-64-debug
|
||||
cd src/gallium/state_trackers/vega
|
||||
make
|
||||
cd ../../../..
|
||||
export LD_LIBRARY_PATH=$PWD/lib64
|
||||
export EGL_DRIVER="egl_softpipe"
|
||||
</pre>
|
||||
|
||||
<h2>OpenVG Demos</h2>
|
||||
|
||||
<p>
|
||||
To build the OpenVG demos:
|
||||
</p>
|
||||
<pre>
|
||||
cd progs/openvg
|
||||
make
|
||||
</pre>
|
||||
<p>
|
||||
To run a demo:
|
||||
</p>
|
||||
<pre>
|
||||
cd openvg/demos
|
||||
./lion
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>Notes</h2>
|
||||
<ul>
|
||||
<li>EGL_DRIVER environmental variable: forces usage of a specific EGL driver. Unless you force egl_softpipe the implementation will look for a DRI hardware accelerate driver and unless you have a Gallium driver that supports it, you'll see crashes</li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
79
docs/relnotes-7.4.3.html
Normal file
79
docs/relnotes-7.4.3.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.4.3 Release Notes / 19 June 2009</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.4.3 is a stable development release fixing bugs since the 7.4.2 release.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.4.3 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI hardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
34c5a6c47ed51f31c4fa36e269831352 MesaLib-7.4.3.tar.gz
|
||||
70a983ba3deaa8bd63b18bbab283f698 MesaLib-7.4.3.tar.bz2
|
||||
34f21b3205b271d575030aa98a2dda51 MesaLib-7.4.3.zip
|
||||
56752b7adede212e6097afb10d0c0d59 MesaDemos-7.4.3.tar.gz
|
||||
8ffa51c4833b1e298300a005e2d7ca2a MesaDemos-7.4.3.tar.bz2
|
||||
0037d24d41400d6fb9800ae55b8c863f MesaDemos-7.4.3.zip
|
||||
20e24f6692c0c90e7e3b220f79c4108d MesaGLUT-7.4.3.tar.gz
|
||||
03a4beeef74fc5ef0b1d6d04710e5a8a MesaGLUT-7.4.3.tar.bz2
|
||||
273788230adbdb9d57371309adedcf5f MesaGLUT-7.4.3.zip
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Fixed texture object reference counting bug (bug 21756)
|
||||
<li>Allow depth/stencil textures to be attached to GL_STENCIL_ATTACHMENT point
|
||||
(SF bug 2793846)
|
||||
<li>Added missing glGet case for GL_VERTEX_ARRAY_BINDING_APPLE
|
||||
<li>Fixed some OSMesa build issues
|
||||
<li>Fixed a vertex buffer object crash
|
||||
<li>Fixed broken glTexImage3D() when image type = GL_BITMAP
|
||||
<li>Fixed some GLSL preprocessor bugs
|
||||
<li>Fixed framebuffer mem leak in i945/i965 DRI drivers
|
||||
<li>Fixed texture coordinate repeat bug in swrast (bug 21872)
|
||||
<li>Fixed incorrect viewport clamping (lower bound is zero, not one)
|
||||
<li>GLX fix for glean's makeCurrent test case
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Driver Status</h2>
|
||||
|
||||
<pre>
|
||||
Driver Status
|
||||
---------------------- ----------------------
|
||||
DRI drivers varies with the driver
|
||||
XMesa/GLX (on Xlib) implements OpenGL 2.1
|
||||
OSMesa (off-screen) implements OpenGL 2.1
|
||||
Windows/Win32 implements OpenGL 2.1
|
||||
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
|
||||
SVGA unsupported
|
||||
Wind River UGL unsupported
|
||||
DJGPP unsupported
|
||||
GGI unsupported
|
||||
BeOS unsupported
|
||||
Allegro unsupported
|
||||
D3D unsupported
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
68
docs/relnotes-7.4.4.html
Normal file
68
docs/relnotes-7.4.4.html
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.4.4 Release Notes / 23 June 2009</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.4.4 is a stable development release fixing bugs since the 7.4.3 release.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.4.4 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI hardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
0b56fe5a88ab0c3c5b2da5068f63f416 MesaLib-7.4.4.tar.gz
|
||||
b66528d314c574dccbe0ed963cac5e93 MesaLib-7.4.4.tar.bz2
|
||||
2818076f3ba23fa87fdfe4602a637a18 MesaLib-7.4.4.zip
|
||||
3e77b208386c47b18165bce5ae317e2c MesaDemos-7.4.4.tar.gz
|
||||
628142ec9a54cd28cc027e6ce26cff47 MesaDemos-7.4.4.tar.bz2
|
||||
d08a30d30ab7174859aa709cba6c726d MesaDemos-7.4.4.zip
|
||||
e6e91ba16e274d40cf3a97ad3218af01 MesaGLUT-7.4.4.tar.gz
|
||||
e14bbb52517e8121b31f1387515365ab MesaGLUT-7.4.4.tar.bz2
|
||||
f10ed20469753c2b3d68c99854f80fd4 MesaGLUT-7.4.4.zip
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Fixed i965/i915 segfault in screen destruction (bug 22408)
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Driver Status</h2>
|
||||
|
||||
<pre>
|
||||
Driver Status
|
||||
---------------------- ----------------------
|
||||
DRI drivers varies with the driver
|
||||
XMesa/GLX (on Xlib) implements OpenGL 2.1
|
||||
OSMesa (off-screen) implements OpenGL 2.1
|
||||
Windows/Win32 implements OpenGL 2.1
|
||||
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
|
||||
SVGA unsupported
|
||||
Wind River UGL unsupported
|
||||
DJGPP unsupported
|
||||
GGI unsupported
|
||||
BeOS unsupported
|
||||
Allegro unsupported
|
||||
D3D unsupported
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -68,6 +68,10 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
|
|||
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
|
||||
<li>Updated SPARC assembly optimizations (David S. Miller)
|
||||
<li>Initial support for separate compilation units in GLSL compiler.
|
||||
<li>Increased max number of generic GLSL varying variables to 16 (formerly 8).
|
||||
<li>GLSL linker now detects when too many varying variables are used.
|
||||
<li>Optimize-out redundant glMaterial and glShadeModel calls in display lists
|
||||
<li>Fixed gl_TextureMatrix[i][j] array indexing bug in GLSL compiler.
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
@ -75,6 +79,7 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
|
|||
<ul>
|
||||
<li>Lots of i965 driver bug fixes
|
||||
<li>Fixed some GLSL preprocessor bugs
|
||||
<li>GLSL: continue inside of a for-loop didn't work
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,15 @@ tbd
|
|||
<li><a href="openvg.html">OpenVG</a> front-end (state tracker for Gallium).
|
||||
This was written by Zack Rusin at Tungsten Graphics.
|
||||
<li>GL_APPLE_vertex_array_object for Gallium drivers and Intel DRI drivers.
|
||||
<li>GL_ARB_vertex_array_object for Gallium drivers, software drivers and
|
||||
Intel DRI drivers.
|
||||
<li>GL_ARB_copy_buffer extension (supported in Gallium and swrast drivers)
|
||||
<LI>GL_ARB_map_buffer_range extension (supported in Gallium and software drivers)
|
||||
<li>GL_EXT_provoking_vertex extension (supported in Gallium and software drivers)
|
||||
<li>Rewritten radeon/r200/r300 driver using a buffer manager
|
||||
<li>radeon/r200/r300 GL_EXT_framebuffer_object support when used with
|
||||
kernel memory manager
|
||||
<li>r300 driver support for GL_EXT_vertex_array_bgra, GL_EXT_texture_sRGB
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,6 @@
|
|||
|
||||
<H1>Release Notes</H1>
|
||||
|
||||
<p>
|
||||
Mesa uses an even/odd version number scheme like the Linux kernel.
|
||||
Odd numbered versions (such as 6.5) designate new developmental releases.
|
||||
Even numbered versions (such as 6.4) designate stable releases.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
The release notes summarize what's new or changed in each Mesa release.
|
||||
</p>
|
||||
|
|
@ -22,6 +15,8 @@ The release notes summarize what's new or changed in each Mesa release.
|
|||
<UL>
|
||||
<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
|
||||
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.4.html">7.4.4 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.3.html">7.4.3 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
#define glBeginFragmentShaderATI MANGLE(BeginFragmentShaderATI)
|
||||
#define glBegin MANGLE(Begin)
|
||||
#define glBeginOcclusionQueryNV MANGLE(BeginOcclusionQueryNV)
|
||||
#define glBeginPerfMonitorAMD MANGLE(BeginPerfMonitorAMD)
|
||||
#define glBeginQueryARB MANGLE(BeginQueryARB)
|
||||
#define glBeginQuery MANGLE(BeginQuery)
|
||||
#define glBeginTransformFeedbackEXT MANGLE(BeginTransformFeedbackEXT)
|
||||
|
|
@ -257,6 +258,7 @@
|
|||
#define glConvolutionParameteri MANGLE(ConvolutionParameteri)
|
||||
#define glConvolutionParameterivEXT MANGLE(ConvolutionParameterivEXT)
|
||||
#define glConvolutionParameteriv MANGLE(ConvolutionParameteriv)
|
||||
#define glCopyBufferSubData MANGLE(CopyBufferSubData)
|
||||
#define glCopyColorSubTableEXT MANGLE(CopyColorSubTableEXT)
|
||||
#define glCopyColorSubTable MANGLE(CopyColorSubTable)
|
||||
#define glCopyColorTable MANGLE(CopyColorTable)
|
||||
|
|
@ -309,6 +311,7 @@
|
|||
#define glDeleteLists MANGLE(DeleteLists)
|
||||
#define glDeleteObjectARB MANGLE(DeleteObjectARB)
|
||||
#define glDeleteOcclusionQueriesNV MANGLE(DeleteOcclusionQueriesNV)
|
||||
#define glDeletePerfMonitorsAMD MANGLE(DeletePerfMonitorsAMD)
|
||||
#define glDeleteProgram MANGLE(DeleteProgram)
|
||||
#define glDeleteProgramsARB MANGLE(DeleteProgramsARB)
|
||||
#define glDeleteProgramsNV MANGLE(DeleteProgramsNV)
|
||||
|
|
@ -343,6 +346,7 @@
|
|||
#define glDrawArraysEXT MANGLE(DrawArraysEXT)
|
||||
#define glDrawArraysInstancedARB MANGLE(DrawArraysInstancedARB)
|
||||
#define glDrawArraysInstancedEXT MANGLE(DrawArraysInstancedEXT)
|
||||
#define glDrawArraysInstanced MANGLE(DrawArraysInstanced)
|
||||
#define glDrawArrays MANGLE(DrawArrays)
|
||||
#define glDrawBuffer MANGLE(DrawBuffer)
|
||||
#define glDrawBuffersARB MANGLE(DrawBuffersARB)
|
||||
|
|
@ -352,6 +356,7 @@
|
|||
#define glDrawElementArrayATI MANGLE(DrawElementArrayATI)
|
||||
#define glDrawElementsInstancedARB MANGLE(DrawElementsInstancedARB)
|
||||
#define glDrawElementsInstancedEXT MANGLE(DrawElementsInstancedEXT)
|
||||
#define glDrawElementsInstanced MANGLE(DrawElementsInstanced)
|
||||
#define glDrawElements MANGLE(DrawElements)
|
||||
#define glDrawMeshArraysSUN MANGLE(DrawMeshArraysSUN)
|
||||
#define glDrawPixels MANGLE(DrawPixels)
|
||||
|
|
@ -381,6 +386,7 @@
|
|||
#define glEndList MANGLE(EndList)
|
||||
#define glEnd MANGLE(End)
|
||||
#define glEndOcclusionQueryNV MANGLE(EndOcclusionQueryNV)
|
||||
#define glEndPerfMonitorAMD MANGLE(EndPerfMonitorAMD)
|
||||
#define glEndQueryARB MANGLE(EndQueryARB)
|
||||
#define glEndQuery MANGLE(EndQuery)
|
||||
#define glEndTransformFeedbackEXT MANGLE(EndTransformFeedbackEXT)
|
||||
|
|
@ -485,6 +491,7 @@
|
|||
#define glGenFramebuffers MANGLE(GenFramebuffers)
|
||||
#define glGenLists MANGLE(GenLists)
|
||||
#define glGenOcclusionQueriesNV MANGLE(GenOcclusionQueriesNV)
|
||||
#define glGenPerfMonitorsAMD MANGLE(GenPerfMonitorsAMD)
|
||||
#define glGenProgramsARB MANGLE(GenProgramsARB)
|
||||
#define glGenProgramsNV MANGLE(GenProgramsNV)
|
||||
#define glGenQueriesARB MANGLE(GenQueriesARB)
|
||||
|
|
@ -501,7 +508,11 @@
|
|||
#define glGetActiveAttribARB MANGLE(GetActiveAttribARB)
|
||||
#define glGetActiveAttrib MANGLE(GetActiveAttrib)
|
||||
#define glGetActiveUniformARB MANGLE(GetActiveUniformARB)
|
||||
#define glGetActiveUniformBlockiv MANGLE(GetActiveUniformBlockiv)
|
||||
#define glGetActiveUniformBlockName MANGLE(GetActiveUniformBlockName)
|
||||
#define glGetActiveUniform MANGLE(GetActiveUniform)
|
||||
#define glGetActiveUniformName MANGLE(GetActiveUniformName)
|
||||
#define glGetActiveUniformsiv MANGLE(GetActiveUniformsiv)
|
||||
#define glGetActiveVaryingNV MANGLE(GetActiveVaryingNV)
|
||||
#define glGetArrayObjectfvATI MANGLE(GetArrayObjectfvATI)
|
||||
#define glGetArrayObjectivATI MANGLE(GetArrayObjectivATI)
|
||||
|
|
@ -634,6 +645,12 @@
|
|||
#define glGetObjectParameterivARB MANGLE(GetObjectParameterivARB)
|
||||
#define glGetOcclusionQueryivNV MANGLE(GetOcclusionQueryivNV)
|
||||
#define glGetOcclusionQueryuivNV MANGLE(GetOcclusionQueryuivNV)
|
||||
#define glGetPerfMonitorCounterDataAMD MANGLE(GetPerfMonitorCounterDataAMD)
|
||||
#define glGetPerfMonitorCounterInfoAMD MANGLE(GetPerfMonitorCounterInfoAMD)
|
||||
#define glGetPerfMonitorCountersAMD MANGLE(GetPerfMonitorCountersAMD)
|
||||
#define glGetPerfMonitorCounterStringAMD MANGLE(GetPerfMonitorCounterStringAMD)
|
||||
#define glGetPerfMonitorGroupsAMD MANGLE(GetPerfMonitorGroupsAMD)
|
||||
#define glGetPerfMonitorGroupStringAMD MANGLE(GetPerfMonitorGroupStringAMD)
|
||||
#define glGetPixelMapfv MANGLE(GetPixelMapfv)
|
||||
#define glGetPixelMapuiv MANGLE(GetPixelMapuiv)
|
||||
#define glGetPixelMapusv MANGLE(GetPixelMapusv)
|
||||
|
|
@ -709,9 +726,11 @@
|
|||
#define glGetTransformFeedbackVaryingEXT MANGLE(GetTransformFeedbackVaryingEXT)
|
||||
#define glGetTransformFeedbackVarying MANGLE(GetTransformFeedbackVarying)
|
||||
#define glGetTransformFeedbackVaryingNV MANGLE(GetTransformFeedbackVaryingNV)
|
||||
#define glGetUniformBlockIndex MANGLE(GetUniformBlockIndex)
|
||||
#define glGetUniformBufferSizeEXT MANGLE(GetUniformBufferSizeEXT)
|
||||
#define glGetUniformfvARB MANGLE(GetUniformfvARB)
|
||||
#define glGetUniformfv MANGLE(GetUniformfv)
|
||||
#define glGetUniformIndices MANGLE(GetUniformIndices)
|
||||
#define glGetUniformivARB MANGLE(GetUniformivARB)
|
||||
#define glGetUniformiv MANGLE(GetUniformiv)
|
||||
#define glGetUniformLocationARB MANGLE(GetUniformLocationARB)
|
||||
|
|
@ -744,6 +763,10 @@
|
|||
#define glGetVertexAttribPointervARB MANGLE(GetVertexAttribPointervARB)
|
||||
#define glGetVertexAttribPointerv MANGLE(GetVertexAttribPointerv)
|
||||
#define glGetVertexAttribPointervNV MANGLE(GetVertexAttribPointervNV)
|
||||
#define glGetVideoi64vNV MANGLE(GetVideoi64vNV)
|
||||
#define glGetVideoivNV MANGLE(GetVideoivNV)
|
||||
#define glGetVideoui64vNV MANGLE(GetVideoui64vNV)
|
||||
#define glGetVideouivNV MANGLE(GetVideouivNV)
|
||||
#define glGlobalAlphaFactorbSUN MANGLE(GlobalAlphaFactorbSUN)
|
||||
#define glGlobalAlphaFactordSUN MANGLE(GlobalAlphaFactordSUN)
|
||||
#define glGlobalAlphaFactorfSUN MANGLE(GlobalAlphaFactorfSUN)
|
||||
|
|
@ -1096,6 +1119,9 @@
|
|||
#define glPopClientAttrib MANGLE(PopClientAttrib)
|
||||
#define glPopMatrix MANGLE(PopMatrix)
|
||||
#define glPopName MANGLE(PopName)
|
||||
#define glPresentFrameDualFillNV MANGLE(PresentFrameDualFillNV)
|
||||
#define glPresentFrameKeyedNV MANGLE(PresentFrameKeyedNV)
|
||||
#define glPrimitiveRestartIndex MANGLE(PrimitiveRestartIndex)
|
||||
#define glPrimitiveRestartIndexNV MANGLE(PrimitiveRestartIndexNV)
|
||||
#define glPrimitiveRestartNV MANGLE(PrimitiveRestartNV)
|
||||
#define glPrioritizeTexturesEXT MANGLE(PrioritizeTexturesEXT)
|
||||
|
|
@ -1173,6 +1199,7 @@
|
|||
#define glProgramUniformMatrix4x2fvEXT MANGLE(ProgramUniformMatrix4x2fvEXT)
|
||||
#define glProgramUniformMatrix4x3fvEXT MANGLE(ProgramUniformMatrix4x3fvEXT)
|
||||
#define glProgramVertexLimitNV MANGLE(ProgramVertexLimitNV)
|
||||
#define glProvokingVertexEXT MANGLE(ProvokingVertexEXT)
|
||||
#define glPushAttrib MANGLE(PushAttrib)
|
||||
#define glPushClientAttribDefaultEXT MANGLE(PushClientAttribDefaultEXT)
|
||||
#define glPushClientAttrib MANGLE(PushClientAttrib)
|
||||
|
|
@ -1301,6 +1328,7 @@
|
|||
#define glSecondaryColorPointerListIBM MANGLE(SecondaryColorPointerListIBM)
|
||||
#define glSecondaryColorPointer MANGLE(SecondaryColorPointer)
|
||||
#define glSelectBuffer MANGLE(SelectBuffer)
|
||||
#define glSelectPerfMonitorCountersAMD MANGLE(SelectPerfMonitorCountersAMD)
|
||||
#define glSeparableFilter2DEXT MANGLE(SeparableFilter2DEXT)
|
||||
#define glSeparableFilter2D MANGLE(SeparableFilter2D)
|
||||
#define glSetFenceAPPLE MANGLE(SetFenceAPPLE)
|
||||
|
|
@ -1345,11 +1373,14 @@
|
|||
#define glTangent3svEXT MANGLE(Tangent3svEXT)
|
||||
#define glTangentPointerEXT MANGLE(TangentPointerEXT)
|
||||
#define glTbufferMask3DFX MANGLE(TbufferMask3DFX)
|
||||
#define glTessellationFactorAMD MANGLE(TessellationFactorAMD)
|
||||
#define glTessellationModeAMD MANGLE(TessellationModeAMD)
|
||||
#define glTestFenceAPPLE MANGLE(TestFenceAPPLE)
|
||||
#define glTestFenceNV MANGLE(TestFenceNV)
|
||||
#define glTestObjectAPPLE MANGLE(TestObjectAPPLE)
|
||||
#define glTexBufferARB MANGLE(TexBufferARB)
|
||||
#define glTexBufferEXT MANGLE(TexBufferEXT)
|
||||
#define glTexBuffer MANGLE(TexBuffer)
|
||||
#define glTexBumpParameterfvATI MANGLE(TexBumpParameterfvATI)
|
||||
#define glTexBumpParameterivATI MANGLE(TexBumpParameterivATI)
|
||||
#define glTexCoord1d MANGLE(TexCoord1d)
|
||||
|
|
@ -1515,6 +1546,7 @@
|
|||
#define glUniform4ui MANGLE(Uniform4ui)
|
||||
#define glUniform4uivEXT MANGLE(Uniform4uivEXT)
|
||||
#define glUniform4uiv MANGLE(Uniform4uiv)
|
||||
#define glUniformBlockBinding MANGLE(UniformBlockBinding)
|
||||
#define glUniformBufferEXT MANGLE(UniformBufferEXT)
|
||||
#define glUniformMatrix2fvARB MANGLE(UniformMatrix2fvARB)
|
||||
#define glUniformMatrix2fv MANGLE(UniformMatrix2fv)
|
||||
|
|
@ -1688,7 +1720,7 @@
|
|||
#define glVertexAttrib4usvARB MANGLE(VertexAttrib4usvARB)
|
||||
#define glVertexAttrib4usv MANGLE(VertexAttrib4usv)
|
||||
#define glVertexAttribArrayObjectATI MANGLE(VertexAttribArrayObjectATI)
|
||||
#define glVertexAttribDivisor MANGLE(VertexAttribDivisor)
|
||||
#define glVertexAttribDivisorARB MANGLE(VertexAttribDivisorARB)
|
||||
#define glVertexAttribI1iEXT MANGLE(VertexAttribI1iEXT)
|
||||
#define glVertexAttribI1i MANGLE(VertexAttribI1i)
|
||||
#define glVertexAttribI1ivEXT MANGLE(VertexAttribI1ivEXT)
|
||||
|
|
|
|||
|
|
@ -2702,7 +2702,7 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
|
|||
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
|
||||
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
|
||||
|
|
@ -2723,7 +2723,7 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ
|
|||
#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
|
||||
#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
|
||||
#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
|
||||
#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer)
|
||||
#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
|
||||
#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
|
||||
#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
|
||||
#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
|
||||
|
|
@ -10563,7 +10563,7 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;
|
|||
GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
|
||||
GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
|
||||
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;
|
||||
|
|
|
|||
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 */
|
||||
106
include/VG/vgplatform.h
Normal file
106
include/VG/vgplatform.h
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/* $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
|
||||
|
||||
#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 */
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
SConscript([
|
||||
'util/SConscript',
|
||||
'demos/SConscript',
|
||||
'glsl/SConscript',
|
||||
'redbook/SConscript',
|
||||
'samples/SConscript',
|
||||
'tests/SConscript',
|
||||
|
|
|
|||
|
|
@ -145,6 +145,13 @@ engine.o: engine.c trackball.h
|
|||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
|
||||
|
||||
|
||||
fbotexture: fbotexture.o
|
||||
$(APP_CC) $(CFLAGS) $(LDFLAGS) fbotexture.o $(LIBS) -o $@
|
||||
|
||||
fbotexture.o: fbotexture.c extfuncs.h
|
||||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) fbotexture.c
|
||||
|
||||
|
||||
fslight: fslight.o
|
||||
$(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ static GLboolean NoClear = GL_FALSE;
|
|||
static GLint FrameParity = 0;
|
||||
static GLenum FilterIndex = 0;
|
||||
static GLint ClampIndex = 0;
|
||||
static GLboolean supportFBO = GL_FALSE;
|
||||
|
||||
|
||||
static struct {
|
||||
|
|
@ -403,6 +404,10 @@ static void init_checkers( void )
|
|||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
if (!supportFBO)
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
|
||||
|
||||
|
||||
/* make colored checkerboard cube faces */
|
||||
for (f = 0; f < 6; f++) {
|
||||
for (i = 0; i < CUBE_TEX_SIZE; i++) {
|
||||
|
|
@ -426,7 +431,8 @@ static void init_checkers( void )
|
|||
GL_BGRA, GL_UNSIGNED_BYTE, image);
|
||||
}
|
||||
|
||||
glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
|
||||
if (supportFBO)
|
||||
glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -503,10 +509,13 @@ static void init( GLboolean useImageFiles )
|
|||
exit(0);
|
||||
}
|
||||
|
||||
/* Needed for glGenerateMipmapEXT
|
||||
/* Needed for glGenerateMipmapEXT / auto mipmapping
|
||||
*/
|
||||
if (!strstr(exten, "GL_EXT_framebuffer_object")) {
|
||||
printf("Sorry, this demo requires GL_EXT_framebuffer_object\n");
|
||||
if (strstr(exten, "GL_EXT_framebuffer_object")) {
|
||||
supportFBO = GL_TRUE;
|
||||
}
|
||||
else if (!strstr(exten, "GL_SGIS_generate_mipmap")) {
|
||||
printf("Sorry, this demo requires GL_EXT_framebuffer_object or GL_SGIS_generate_mipmap\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
/* For debug */
|
||||
#define DEPTH 1
|
||||
|
|
@ -80,9 +80,9 @@ RenderTexture(void)
|
|||
glTranslatef(0.0, 0.0, -15.0);
|
||||
|
||||
/* draw to texture image */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
|
||||
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, MyFB);
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
printf("Framebuffer incomplete!!!\n");
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ RenderTexture(void)
|
|||
|
||||
#if DRAW
|
||||
/* Bind normal framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
|
@ -252,12 +252,12 @@ static void
|
|||
CleanUp(void)
|
||||
{
|
||||
#if DEPTH
|
||||
glDeleteRenderbuffersEXT(1, &DepthRB);
|
||||
glDeleteRenderbuffers_func(1, &DepthRB);
|
||||
#endif
|
||||
#if STENCIL
|
||||
glDeleteRenderbuffersEXT(1, &StencilRB);
|
||||
glDeleteRenderbuffers_func(1, &StencilRB);
|
||||
#endif
|
||||
glDeleteFramebuffersEXT(1, &MyFB);
|
||||
glDeleteFramebuffers_func(1, &MyFB);
|
||||
|
||||
glDeleteTextures(1, &TexObj);
|
||||
|
||||
|
|
@ -318,14 +318,14 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||
|
||||
*depthRbOut = *stencilRbOut = 0;
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
||||
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fbo);
|
||||
|
||||
if (tryDepthStencil) {
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
glGenRenderbuffers_func(1, &rb);
|
||||
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||
GL_DEPTH24_STENCIL8_EXT,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
|
|
@ -333,7 +333,7 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||
|
||||
if (bindDepthStencil) {
|
||||
/* attach to both depth and stencil at once */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
|
|
@ -341,21 +341,21 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||
}
|
||||
else {
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* and attach to stencil attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
return GL_FALSE;
|
||||
|
||||
|
|
@ -367,22 +367,22 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||
{
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
glGenRenderbuffers_func(1, &rb);
|
||||
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||
GL_DEPTH_COMPONENT,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||
GL_DEPTH_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
return GL_FALSE;
|
||||
|
||||
|
|
@ -393,26 +393,26 @@ AttachDepthAndStencilBuffers(GLuint fbo,
|
|||
{
|
||||
GLuint rb;
|
||||
|
||||
glGenRenderbuffersEXT(1, &rb);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
|
||||
glGenRenderbuffers_func(1, &rb);
|
||||
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
|
||||
glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
|
||||
GL_STENCIL_INDEX,
|
||||
width, height);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
/* attach to depth attachment point */
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
|
||||
GL_STENCIL_ATTACHMENT_EXT,
|
||||
GL_RENDERBUFFER_EXT, rb);
|
||||
if (glGetError())
|
||||
return GL_FALSE;
|
||||
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
|
||||
glDeleteRenderbuffersEXT(1, depthRbOut);
|
||||
glDeleteRenderbuffers_func(1, depthRbOut);
|
||||
*depthRbOut = 0;
|
||||
glDeleteRenderbuffersEXT(1, &rb);
|
||||
glDeleteRenderbuffers_func(1, &rb);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -463,6 +463,37 @@ ParseArgs(int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
SetupFunctionPointers(void)
|
||||
{
|
||||
GetExtensionFuncs();
|
||||
|
||||
if (Use_ARB_fbo) {
|
||||
/* no-op: use the ARB functions as-is */
|
||||
}
|
||||
else {
|
||||
/* set the ARB-flavor function pointers to point to the EXT functions */
|
||||
glIsRenderbuffer_func = glIsRenderbufferEXT_func;
|
||||
glBindRenderbuffer_func = glBindRenderbufferEXT_func;
|
||||
glDeleteRenderbuffers_func = glDeleteRenderbuffersEXT_func;
|
||||
glGenRenderbuffers_func = glGenRenderbuffersEXT_func;
|
||||
glRenderbufferStorage_func = glRenderbufferStorageEXT_func;
|
||||
glGetRenderbufferParameteriv_func = glGetRenderbufferParameterivEXT_func;
|
||||
glIsFramebuffer_func = glIsFramebufferEXT_func;
|
||||
glBindFramebuffer_func = glBindFramebufferEXT_func;
|
||||
glDeleteFramebuffers_func = glDeleteFramebuffersEXT_func;
|
||||
glGenFramebuffers_func = glGenFramebuffersEXT_func;
|
||||
glCheckFramebufferStatus_func = glCheckFramebufferStatusEXT_func;
|
||||
glFramebufferTexture1D_func = glFramebufferTexture1DEXT_func;
|
||||
glFramebufferTexture2D_func = glFramebufferTexture2DEXT_func;
|
||||
glFramebufferTexture3D_func = glFramebufferTexture3DEXT_func;
|
||||
glFramebufferRenderbuffer_func = glFramebufferRenderbufferEXT_func;
|
||||
glGetFramebufferAttachmentParameteriv_func = glGetFramebufferAttachmentParameterivEXT_func;
|
||||
glGenerateMipmap_func = glGenerateMipmapEXT_func;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make FBO to render into given texture.
|
||||
*/
|
||||
|
|
@ -472,10 +503,10 @@ MakeFBO_RenderTexture(GLuint TexObj)
|
|||
GLuint fb;
|
||||
GLint sizeFudge = 0;
|
||||
|
||||
glGenFramebuffersEXT(1, &fb);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
|
||||
glGenFramebuffers_func(1, &fb);
|
||||
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fb);
|
||||
/* Render color to texture */
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
glFramebufferTexture2D_func(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
TexTarget, TexObj, TextureLevel);
|
||||
|
||||
if (Use_ARB_fbo) {
|
||||
|
|
@ -512,26 +543,26 @@ MakeFBO_RenderTexture(GLuint TexObj)
|
|||
{
|
||||
GLint bits, w, h;
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, DepthRB);
|
||||
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_WIDTH_EXT, &w);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_HEIGHT_EXT, &h);
|
||||
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
|
||||
printf("Depth buffer size: %d x %d\n", w, h);
|
||||
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
|
||||
printf("Depth renderbuffer size = %d bits\n", bits);
|
||||
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
|
||||
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
|
||||
glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, StencilRB);
|
||||
glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
|
||||
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
|
||||
printf("Stencil renderbuffer size = %d bits\n", bits);
|
||||
}
|
||||
|
||||
/* bind the regular framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
|
@ -547,6 +578,8 @@ Init(void)
|
|||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
SetupFunctionPointers();
|
||||
|
||||
/* lighting */
|
||||
{
|
||||
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
|
||||
|
|
@ -605,7 +638,6 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(Width, Height);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Display);
|
||||
|
|
|
|||
|
|
@ -583,10 +583,14 @@ ParseOptions(int argc, char *argv[])
|
|||
int i;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-fs") == 0) {
|
||||
FragProgFile = argv[i+1];
|
||||
FragProgFile = argv[++i];
|
||||
}
|
||||
else if (strcmp(argv[i], "-vs") == 0) {
|
||||
VertProgFile = argv[i+1];
|
||||
VertProgFile = argv[++i];
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "unknown option %s\n", argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -514,12 +514,27 @@ static void draw_surface( unsigned int with_state )
|
|||
break;
|
||||
|
||||
case (GLVERTEX|STRIPS):
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
if (with_state & MATERIALS) {
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
if (i % 600 == 0 && i != 0) {
|
||||
unsigned j = i / 600;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
|
||||
}
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else {
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glEnd();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -832,8 +847,8 @@ static void Init(int argc, char *argv[])
|
|||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
glEnable( GL_DEPTH_TEST );
|
||||
glEnable( GL_VERTEX_ARRAY_EXT );
|
||||
glEnable( GL_NORMAL_ARRAY_EXT );
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_NORMAL_ARRAY );
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
|
|
|||
|
|
@ -194,11 +194,11 @@ redraw(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if (newModel)
|
||||
recalcModelView();
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
/* Draw the floor. */
|
||||
/* glEnable(GL_TEXTURE_2D);*/
|
||||
|
|
@ -215,7 +215,7 @@ redraw(void)
|
|||
glEnd();
|
||||
|
||||
/* Allow particles to blend with each other. */
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (blend)
|
||||
glEnable(GL_BLEND);
|
||||
|
|
|
|||
|
|
@ -209,13 +209,13 @@ redraw(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(15.0, 1.0, 0.0, 0.0);
|
||||
glRotatef(angle, 0.0, 1.0, 0.0);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
/* Draw the floor. */
|
||||
/* glEnable(GL_TEXTURE_2D);*/
|
||||
|
|
@ -232,7 +232,7 @@ redraw(void)
|
|||
glEnd();
|
||||
|
||||
/* Allow particles to blend with each other. */
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (blend)
|
||||
glEnable(GL_BLEND);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ LIB_DEP = \
|
|||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/progs/util
|
||||
|
||||
|
|
|
|||
55
progs/glsl/SConscript
Normal file
55
progs/glsl/SConscript
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
Import('*')
|
||||
|
||||
if not env['GLUT']:
|
||||
Return()
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(CPPPATH = [
|
||||
'../util',
|
||||
])
|
||||
|
||||
env.Prepend(LIBS = [
|
||||
util,
|
||||
'$GLUT_LIB'
|
||||
])
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||
env.Prepend(LIBS = ['winmm'])
|
||||
|
||||
progs = [
|
||||
'array',
|
||||
'bitmap',
|
||||
'brick',
|
||||
'bump',
|
||||
'convolutions',
|
||||
'deriv',
|
||||
'fragcoord',
|
||||
'identity',
|
||||
'linktest',
|
||||
'mandelbrot',
|
||||
'multinoise',
|
||||
'multitex',
|
||||
'noise',
|
||||
'noise2',
|
||||
'pointcoord',
|
||||
'points',
|
||||
'samplers',
|
||||
'shadow_sampler',
|
||||
'skinning',
|
||||
'texaaline',
|
||||
'texdemo1',
|
||||
'toyball',
|
||||
'trirast',
|
||||
'twoside',
|
||||
'vert-or-frag-only',
|
||||
'vert-tex',
|
||||
]
|
||||
|
||||
for prog in progs:
|
||||
env.Program(
|
||||
target = prog,
|
||||
source = prog + '.c',
|
||||
)
|
||||
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
|
@ -248,6 +248,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -309,6 +310,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -191,6 +192,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
* Author: Zack Rusin
|
||||
*/
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "readtex.h"
|
||||
|
||||
|
|
@ -455,6 +457,7 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
init();
|
||||
|
||||
glutReshapeFunc(reshape);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -228,6 +229,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -174,6 +175,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -195,6 +196,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -245,6 +246,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(300, 300);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -206,6 +207,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -270,6 +271,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
|
|
@ -139,7 +140,7 @@ DrawPolygonArray(void)
|
|||
}
|
||||
else {
|
||||
glVertexPointer(2, GL_FLOAT, 0, vertPtr);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
glVertexAttribPointer_func(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
|
|
@ -152,7 +153,7 @@ DrawPolygonArray(void)
|
|||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0);
|
||||
glBindBufferARB_func(GL_ARRAY_BUFFER_ARB, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -400,6 +401,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -207,6 +208,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -195,6 +196,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -248,6 +249,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ void main()
|
|||
float two_n_dot_u = 2.0 * dot(n, u);
|
||||
vec4 f;
|
||||
f.xyz = u - n * two_n_dot_u;
|
||||
f.w = 1.0;
|
||||
|
||||
// outputs
|
||||
normal = n;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
|
|
@ -357,6 +358,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -329,6 +330,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 300);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -266,6 +267,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -359,6 +360,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
|
|
@ -426,6 +427,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -212,6 +213,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -247,6 +248,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -293,6 +294,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -181,6 +182,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(400, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
|
|
@ -266,6 +267,7 @@ main(int argc, char *argv[])
|
|||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
|
|
|||
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 -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)
|
||||
288
progs/openvg/demos/eglcommon.c
Normal file
288
progs/openvg/demos/eglcommon.c
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
#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_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)) {
|
||||
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_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
|
||||
288
progs/openvg/demos/lion.c
Normal file
288
progs/openvg/demos/lion.c
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
#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_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)) {
|
||||
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_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 -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);
|
||||
}
|
||||
288
progs/openvg/trivial/eglcommon.c
Normal file
288
progs/openvg/trivial/eglcommon.c
Normal file
|
|
@ -0,0 +1,288 @@
|
|||
#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_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)) {
|
||||
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_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);
|
||||
}
|
||||
1
progs/rbug/.gitignore
vendored
1
progs/rbug/.gitignore
vendored
|
|
@ -5,6 +5,7 @@ shdr_info
|
|||
shdr_dump
|
||||
shdr_disable
|
||||
ctx_info
|
||||
ctx_rule
|
||||
tex_dump
|
||||
tex_info
|
||||
*.bmp
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ SOURCES = \
|
|||
shdr_dump.c \
|
||||
shdr_disable.c \
|
||||
ctx_info.c \
|
||||
ctx_rule.c \
|
||||
tex_info.c \
|
||||
tex_dump.c
|
||||
|
||||
|
|
|
|||
86
progs/rbug/ctx_rule.c
Normal file
86
progs/rbug/ctx_rule.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* 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
|
||||
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
||||
* license, 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 (including the next
|
||||
* paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE AND/OR THEIR SUPPLIERS 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.
|
||||
*/
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_network.h"
|
||||
|
||||
#include "rbug/rbug.h"
|
||||
|
||||
static void talk(rbug_context_t ctx, rbug_shader_t shdr)
|
||||
{
|
||||
int c = u_socket_connect("localhost", 13370);
|
||||
struct rbug_connection *con;
|
||||
struct rbug_header *header;
|
||||
|
||||
if (c < 0)
|
||||
c = u_socket_connect("localhost", 13370);
|
||||
|
||||
con = rbug_from_socket(c);
|
||||
assert(c >= 0);
|
||||
assert(con);
|
||||
debug_printf("Connection get!\n");
|
||||
|
||||
rbug_send_context_draw_rule(con, ctx, 0, shdr, 0, 0, RBUG_BLOCK_AFTER, NULL);
|
||||
|
||||
rbug_send_ping(con, NULL);
|
||||
|
||||
debug_printf("Sent waiting for reply\n");
|
||||
header = rbug_get_message(con, NULL);
|
||||
|
||||
if (header->opcode != RBUG_OP_PING_REPLY)
|
||||
debug_printf("Error\n");
|
||||
else
|
||||
debug_printf("Ok!\n");
|
||||
|
||||
rbug_free_header(header);
|
||||
rbug_disconnect(con);
|
||||
}
|
||||
|
||||
static void print_usage()
|
||||
{
|
||||
printf("Usage ctx_rule <context> <fragment>\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
long ctx;
|
||||
long shdr;
|
||||
|
||||
if (argc < 3)
|
||||
print_usage();
|
||||
|
||||
ctx = atol(argv[1]);
|
||||
shdr = atol(argv[2]);
|
||||
|
||||
if (ctx <= 0 && ctx <= 0)
|
||||
print_usage();
|
||||
|
||||
talk((uint64_t)ctx, (uint64_t)shdr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -128,29 +128,29 @@ static void va_render ()
|
|||
{
|
||||
case C:
|
||||
glColorPointer (4, GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_COLOR_ARRAY);
|
||||
glEnableClientState (GL_COLOR_ARRAY);
|
||||
break;
|
||||
case S:
|
||||
glSecondaryColorPointerEXT (4, GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
glEnableClientState (GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
break;
|
||||
case N:
|
||||
glNormalPointer (GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_NORMAL_ARRAY);
|
||||
glEnableClientState (GL_NORMAL_ARRAY);
|
||||
break;
|
||||
case V:
|
||||
glVertexPointer (4, GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_VERTEX_ARRAY);
|
||||
glEnableClientState (GL_VERTEX_ARRAY);
|
||||
break;
|
||||
case T:
|
||||
assert (att->index >= 0 && att->index < 8);
|
||||
glClientActiveTextureARB (GL_TEXTURE0_ARB + att->index);
|
||||
glTexCoordPointer (4, GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
break;
|
||||
case F:
|
||||
glFogCoordPointerEXT (GL_FLOAT, 0, att->data);
|
||||
glEnable (GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
glEnableClientState (GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
break;
|
||||
case A:
|
||||
assert (att->index > 0 && att->index < 16);
|
||||
|
|
@ -169,23 +169,23 @@ static void va_render ()
|
|||
switch (att->dispatch)
|
||||
{
|
||||
case C:
|
||||
glDisable (GL_COLOR_ARRAY);
|
||||
glDisableClientState (GL_COLOR_ARRAY);
|
||||
break;
|
||||
case S:
|
||||
glDisable (GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
glDisableClientState (GL_SECONDARY_COLOR_ARRAY_EXT);
|
||||
break;
|
||||
case N:
|
||||
glDisable (GL_NORMAL_ARRAY);
|
||||
glDisableClientState (GL_NORMAL_ARRAY);
|
||||
break;
|
||||
case V:
|
||||
glDisable (GL_VERTEX_ARRAY);
|
||||
glDisableClientState (GL_VERTEX_ARRAY);
|
||||
break;
|
||||
case T:
|
||||
glClientActiveTextureARB (GL_TEXTURE0_ARB + att->index);
|
||||
glDisable (GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
break;
|
||||
case F:
|
||||
glDisable (GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
glDisableClientState (GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
break;
|
||||
case A:
|
||||
glDisableVertexAttribArrayARB (att->index);
|
||||
|
|
|
|||
6
progs/tests/.gitignore
vendored
6
progs/tests/.gitignore
vendored
|
|
@ -5,6 +5,7 @@ arbfpspec
|
|||
arbfptest1
|
||||
arbfptexture
|
||||
arbfptrig
|
||||
arbgpuprog
|
||||
arbnpot
|
||||
arbnpot-mipmap
|
||||
arbvptest1
|
||||
|
|
@ -38,6 +39,7 @@ fptest1
|
|||
fptexture
|
||||
getprocaddress
|
||||
getproclist.h
|
||||
getteximage
|
||||
glutfx
|
||||
interleave
|
||||
invert
|
||||
|
|
@ -49,12 +51,15 @@ mapvbo
|
|||
minmag
|
||||
mipgen
|
||||
mipmap_comp
|
||||
mipmap_comp_tests
|
||||
mipmap_limits
|
||||
mipmap_view
|
||||
multipal
|
||||
no_s3tc
|
||||
packedpixels
|
||||
persp_hint
|
||||
pbo
|
||||
prim
|
||||
prog_parameter
|
||||
quads
|
||||
random
|
||||
|
|
@ -77,6 +82,7 @@ subtex
|
|||
subtexrate
|
||||
tex1d
|
||||
texcompress2
|
||||
texcompsub
|
||||
texdown
|
||||
texfilt
|
||||
texline
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ SOURCES = \
|
|||
arbfptest1.c \
|
||||
arbfptexture.c \
|
||||
arbfptrig.c \
|
||||
arbgpuprog.c \
|
||||
arbnpot.c \
|
||||
arbnpot-mipmap.c \
|
||||
arbvptest1.c \
|
||||
|
|
@ -60,12 +61,15 @@ SOURCES = \
|
|||
minmag.c \
|
||||
mipgen.c \
|
||||
mipmap_comp.c \
|
||||
mipmap_comp_tests.c \
|
||||
mipmap_limits.c \
|
||||
mipmap_view.c \
|
||||
multipal.c \
|
||||
no_s3tc.c \
|
||||
packedpixels.c \
|
||||
pbo.c \
|
||||
persp_hint.c \
|
||||
prim.c \
|
||||
prog_parameter.c \
|
||||
quads.c \
|
||||
random.c \
|
||||
|
|
@ -84,6 +88,7 @@ SOURCES = \
|
|||
subtexrate.c \
|
||||
tex1d.c \
|
||||
texcompress2.c \
|
||||
texcompsub.c \
|
||||
texdown \
|
||||
texfilt.c \
|
||||
texline.c \
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ progs = [
|
|||
'minmag',
|
||||
'mipgen',
|
||||
'mipmap_comp',
|
||||
'mipmap_comp_tests',
|
||||
'mipmap_limits',
|
||||
'mipmap_view',
|
||||
'multipal',
|
||||
|
|
@ -90,6 +91,7 @@ progs = [
|
|||
'no_s3tc',
|
||||
'packedpixels',
|
||||
'pbo',
|
||||
'persp_hint',
|
||||
'prog_parameter',
|
||||
'quads',
|
||||
'random',
|
||||
|
|
@ -108,6 +110,7 @@ progs = [
|
|||
'tex1d',
|
||||
'texcmp',
|
||||
'texcompress2',
|
||||
'texcompsub',
|
||||
'texdown',
|
||||
'texfilt',
|
||||
'texgenmix',
|
||||
|
|
|
|||
230
progs/tests/arbgpuprog.c
Normal file
230
progs/tests/arbgpuprog.c
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
/**
|
||||
* Just compile ARB vert/frag program from named file(s).
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static GLuint FragProg;
|
||||
static GLuint VertProg;
|
||||
static GLint Win;
|
||||
|
||||
static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB_func;
|
||||
static PFNGLPROGRAMLOCALPARAMETER4DARBPROC glProgramLocalParameter4dARB_func;
|
||||
static PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glGetProgramLocalParameterdvARB_func;
|
||||
static PFNGLGENPROGRAMSARBPROC glGenProgramsARB_func;
|
||||
static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func;
|
||||
static PFNGLBINDPROGRAMARBPROC glBindProgramARB_func;
|
||||
static PFNGLISPROGRAMARBPROC glIsProgramARB_func;
|
||||
static PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB_func;
|
||||
|
||||
|
||||
static void Redisplay( void )
|
||||
{
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
glutSwapBuffers();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static void Reshape( int width, int height )
|
||||
{
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
glTranslatef( 0.0, 0.0, -15.0 );
|
||||
}
|
||||
|
||||
|
||||
static void Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 27:
|
||||
glDeleteProgramsARB_func(1, &VertProg);
|
||||
glDeleteProgramsARB_func(1, &FragProg);
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
/* A helper for finding errors in program strings */
|
||||
static int FindLine( const char *program, int position )
|
||||
{
|
||||
int i, line = 1;
|
||||
for (i = 0; i < position; i++) {
|
||||
if (program[i] == '\n')
|
||||
line++;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
static void Init( const char *vertProgFile,
|
||||
const char *fragProgFile )
|
||||
{
|
||||
GLint errorPos;
|
||||
char buf[10*1000];
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_vertex_program")) {
|
||||
printf("Sorry, this demo requires GL_ARB_vertex_program\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
|
||||
printf("Sorry, this demo requires GL_ARB_fragment_program\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/*
|
||||
* Get extension function pointers.
|
||||
*/
|
||||
glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress("glProgramLocalParameter4fvARB");
|
||||
assert(glProgramLocalParameter4fvARB_func);
|
||||
|
||||
glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) glutGetProcAddress("glProgramLocalParameter4dARB");
|
||||
assert(glProgramLocalParameter4dARB_func);
|
||||
|
||||
glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) glutGetProcAddress("glGetProgramLocalParameterdvARB");
|
||||
assert(glGetProgramLocalParameterdvARB_func);
|
||||
|
||||
glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) glutGetProcAddress("glGenProgramsARB");
|
||||
assert(glGenProgramsARB_func);
|
||||
|
||||
glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
|
||||
assert(glProgramStringARB_func);
|
||||
|
||||
glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
|
||||
assert(glBindProgramARB_func);
|
||||
|
||||
glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) glutGetProcAddress("glIsProgramARB");
|
||||
assert(glIsProgramARB_func);
|
||||
|
||||
glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) glutGetProcAddress("glDeleteProgramsARB");
|
||||
assert(glDeleteProgramsARB_func);
|
||||
|
||||
/*
|
||||
* Vertex program
|
||||
*/
|
||||
if (vertProgFile) {
|
||||
FILE *f;
|
||||
int len;
|
||||
|
||||
glGenProgramsARB_func(1, &VertProg);
|
||||
assert(VertProg > 0);
|
||||
glBindProgramARB_func(GL_VERTEX_PROGRAM_ARB, VertProg);
|
||||
|
||||
f = fopen(vertProgFile, "r");
|
||||
if (!f) {
|
||||
printf("Unable to open %s\n", fragProgFile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
len = fread(buf, 1, 10*1000,f);
|
||||
glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
|
||||
GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
len,
|
||||
(const GLubyte *) buf);
|
||||
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
|
||||
if (glGetError() != GL_NO_ERROR || errorPos != -1) {
|
||||
int l = FindLine(buf, errorPos);
|
||||
printf("Vertex Program Error (pos=%d line=%d): %s\n", errorPos, l,
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
printf("Vertex Program OK\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fragment program
|
||||
*/
|
||||
if (fragProgFile) {
|
||||
FILE *f;
|
||||
int len;
|
||||
|
||||
glGenProgramsARB_func(1, &FragProg);
|
||||
assert(FragProg > 0);
|
||||
glBindProgramARB_func(GL_FRAGMENT_PROGRAM_ARB, FragProg);
|
||||
|
||||
f = fopen(fragProgFile, "r");
|
||||
if (!f) {
|
||||
printf("Unable to open %s\n", fragProgFile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
len = fread(buf, 1, 10*1000,f);
|
||||
glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
|
||||
GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
len,
|
||||
(const GLubyte *) buf);
|
||||
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
|
||||
if (glGetError() != GL_NO_ERROR || errorPos != -1) {
|
||||
int l = FindLine(buf, errorPos);
|
||||
printf("Fragment Program Error (pos=%d line=%d): %s\n", errorPos, l,
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
printf("Fragment Program OK\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
const char *vertProgFile = NULL, *fragProgFile = NULL;
|
||||
int i;
|
||||
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitWindowSize( 200, 200 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutDisplayFunc( Redisplay );
|
||||
|
||||
if (argc == 1) {
|
||||
printf("arbgpuprog:\n");
|
||||
printf(" Compile GL_ARB_vertex/fragment_programs, report any errors.\n");
|
||||
printf("Usage:\n");
|
||||
printf(" arbgpuprog [--vp vertprogfile] [--fp fragprogfile]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "--vp") == 0) {
|
||||
vertProgFile = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "--fp") == 0) {
|
||||
fragProgFile = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
Init(vertProgFile, fragProgFile);
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Test GL_ARB_vertex_buffer_object
|
||||
* Also test GL_ARB_vertex_array_object if supported
|
||||
*
|
||||
* Brian Paul
|
||||
* 16 Sep 2003
|
||||
|
|
@ -9,6 +10,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
|
@ -17,6 +19,7 @@
|
|||
|
||||
struct object
|
||||
{
|
||||
GLuint ArrayObjectID; /** GL_ARB_vertex_array_object */
|
||||
GLuint VertexBufferID;
|
||||
GLuint ColorBufferID;
|
||||
GLuint ElementsBufferID;
|
||||
|
|
@ -35,6 +38,7 @@ static GLuint Win;
|
|||
|
||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||
static GLboolean Anim = GL_TRUE;
|
||||
static GLboolean Have_ARB_vertex_array_object = GL_FALSE;
|
||||
|
||||
|
||||
static void CheckError(int line)
|
||||
|
|
@ -48,34 +52,54 @@ static void CheckError(int line)
|
|||
|
||||
static void DrawObject( const struct object *obj )
|
||||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
|
||||
glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
if (Have_ARB_vertex_array_object && obj->ArrayObjectID) {
|
||||
glBindVertexArray(obj->ArrayObjectID);
|
||||
|
||||
/* test push/pop attrib */
|
||||
/* XXX this leads to a segfault with NVIDIA's 53.36 driver */
|
||||
#if 0
|
||||
if (1)
|
||||
{
|
||||
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
|
||||
/*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999);
|
||||
glPopClientAttrib();
|
||||
}
|
||||
#endif
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
|
||||
glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
if (obj->NumElements > 0) {
|
||||
/* indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
|
||||
glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
|
||||
}
|
||||
else {
|
||||
/* non-indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
|
||||
}
|
||||
|
||||
if (obj->NumElements > 0) {
|
||||
/* indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
|
||||
glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
else {
|
||||
/* non-indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
|
||||
/* no vertex array objects, must set vertex/color pointers per draw */
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
|
||||
glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
/* test push/pop attrib */
|
||||
/* XXX this leads to a segfault with NVIDIA's 53.36 driver */
|
||||
#if 0
|
||||
if (1)
|
||||
{
|
||||
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
|
||||
/*glVertexPointer(3, GL_FLOAT, 0, (void *) (obj->VertexOffset + 10000));*/
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 999999);
|
||||
glPopClientAttrib();
|
||||
}
|
||||
#endif
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
|
||||
glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if (obj->NumElements > 0) {
|
||||
/* indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID);
|
||||
glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL);
|
||||
}
|
||||
else {
|
||||
/* non-indexed arrays */
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, obj->NumVerts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,6 +211,28 @@ static void SpecialKey( int key, int x, int y )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* If GL_ARB_vertex_array_object is supported, create an array object
|
||||
* and set all the per-array state.
|
||||
*/
|
||||
static void
|
||||
CreateVertexArrayObject(struct object *obj)
|
||||
{
|
||||
glGenVertexArrays(1, &obj->ArrayObjectID);
|
||||
glBindVertexArray(obj->ArrayObjectID);
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->VertexBufferID);
|
||||
glVertexPointer(3, GL_FLOAT, obj->VertexStride, (void *) obj->VertexOffset);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, obj->ColorBufferID);
|
||||
glColorPointer(3, GL_FLOAT, obj->ColorStride, (void *) obj->ColorOffset);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Non-interleaved position/color data.
|
||||
*/
|
||||
|
|
@ -262,6 +308,10 @@ static void MakeObject1(struct object *obj)
|
|||
|
||||
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB, &i);
|
||||
assert(!i);
|
||||
|
||||
if (Have_ARB_vertex_array_object) {
|
||||
CreateVertexArrayObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -297,6 +347,10 @@ static void MakeObject2(struct object *obj)
|
|||
obj->NumElements = 0;
|
||||
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
|
||||
if (Have_ARB_vertex_array_object) {
|
||||
CreateVertexArrayObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -347,6 +401,10 @@ static void MakeObject3(struct object *obj)
|
|||
i[3] = 3;
|
||||
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
obj->NumElements = 4;
|
||||
|
||||
if (Have_ARB_vertex_array_object) {
|
||||
CreateVertexArrayObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -387,6 +445,10 @@ static void MakeObject4(struct object *obj)
|
|||
/* Setup a buffer of indices to test the ELEMENTS path */
|
||||
obj->ElementsBufferID = 0;
|
||||
obj->NumElements = 0;
|
||||
|
||||
if (Have_ARB_vertex_array_object) {
|
||||
CreateVertexArrayObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -399,6 +461,13 @@ static void Init( void )
|
|||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
Have_ARB_vertex_array_object =
|
||||
glutExtensionSupported("GL_ARB_vertex_array_object");
|
||||
|
||||
printf("Using GL_ARB_vertex_array_object: %s\n",
|
||||
(Have_ARB_vertex_array_object ? "yes" : "no"));
|
||||
|
||||
|
||||
/* Test buffer object deletion */
|
||||
if (1) {
|
||||
static GLubyte data[1000];
|
||||
|
|
@ -413,6 +482,7 @@ static void Init( void )
|
|||
assert(!glIsBufferARB(id));
|
||||
}
|
||||
|
||||
memset(Objects, 0, sizeof(Objects));
|
||||
MakeObject1(Objects + 0);
|
||||
MakeObject2(Objects + 1);
|
||||
MakeObject3(Objects + 2);
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ Draw(void)
|
|||
{
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
|
||||
glVertexPointer(3, GL_FLOAT, 24, 0);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glColorPointer(3, GL_FLOAT, 24, (void*) 12);
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_QUADS, 0, NumRects * 4);
|
||||
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@ Draw(void)
|
|||
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
|
||||
glVertexPointer(3, GL_FLOAT, 24, 0);
|
||||
glEnable(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glColorPointer(3, GL_FLOAT, 24, (void*) 12);
|
||||
glEnable(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
|
|
|||
318
progs/tests/mipmap_comp_tests.c
Normal file
318
progs/tests/mipmap_comp_tests.c
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||
/*
|
||||
* (c) Copyright 1993, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
|
||||
/* mipmap_comp
|
||||
* Test compressed texture mipmaps
|
||||
*
|
||||
* Based on mipmap_limits
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
|
||||
#define SIZE 16 /* not larger then 16 */
|
||||
|
||||
static GLint BaseLevel = 0, MaxLevel ;
|
||||
static GLfloat MinLod, MaxLod;
|
||||
static GLfloat LodBias;
|
||||
static GLboolean NearestFilter;
|
||||
static GLuint texImage;
|
||||
static GLuint View;
|
||||
|
||||
struct view {
|
||||
GLfloat minLod;
|
||||
GLfloat maxLod;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
static struct view views[] =
|
||||
{
|
||||
{ 0, 0, "Green" },
|
||||
{ 0, 1, "Green, Red" },
|
||||
{ 0, 2, "Green, Red, Blue" },
|
||||
{ 0, 3, "Green, Red, Blue, Black" },
|
||||
{ 0, 4, "Green, Red, Blue, Black, White" },
|
||||
{ 1, 4, "Red, Blue, Black, White" },
|
||||
{ 2, 4, "Blue, Black, White" },
|
||||
{ 3, 4, "Black, White" },
|
||||
{ 4, 4, "White" },
|
||||
{ 3, 3, "Black" },
|
||||
{ 2, 2, "Blue" },
|
||||
{ 1, 1, "Red" },
|
||||
{ 1, 3, "Red, Blue, Black" },
|
||||
{ 1, 2, "Red, Blue" },
|
||||
{ 2, 3, "Blue, Black" },
|
||||
{ 0, 0, NULL },
|
||||
};
|
||||
|
||||
static void
|
||||
initValues(void)
|
||||
{
|
||||
View = 12;
|
||||
BaseLevel = 0;
|
||||
MaxLevel = 9;
|
||||
MinLod = views[View].minLod;
|
||||
MaxLod = views[View].maxLod;
|
||||
LodBias = 5.0;
|
||||
NearestFilter = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
changeView(void)
|
||||
{
|
||||
if (views[++View].string == NULL)
|
||||
View = 0;
|
||||
|
||||
MinLod = views[View].minLod;
|
||||
MaxLod = views[View].maxLod;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
makeImage(int level, int width, int height)
|
||||
{
|
||||
GLubyte img[SIZE*SIZE*3];
|
||||
GLubyte color[5][3] = {
|
||||
{ 0, 255, 0 },
|
||||
{ 255, 0, 0 },
|
||||
{ 0, 0, 255 },
|
||||
{ 0, 0, 0 },
|
||||
{ 255, 255, 255 },
|
||||
};
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
int k = (i * width + j) * 3;
|
||||
img[k + 0] = color[level][0];
|
||||
img[k + 1] = color[level][1];
|
||||
img[k + 2] = color[level][2];
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, level,
|
||||
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
||||
width, height, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, img);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
makeImages(void)
|
||||
{
|
||||
int i, sz;
|
||||
|
||||
for (i = 0, sz = SIZE; sz >= 1; i++, sz /= 2) {
|
||||
makeImage(i, sz, sz);
|
||||
printf("Level %d size: %d x %d\n", i, sz, sz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
myInit(void)
|
||||
{
|
||||
|
||||
initValues();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glTranslatef(0.0, 0.0, -3.6);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glGenTextures(1, &texImage);
|
||||
glBindTexture(GL_TEXTURE_2D, texImage);
|
||||
makeImages();
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
display(void)
|
||||
{
|
||||
GLfloat tcm = 1.0;
|
||||
glBindTexture(GL_TEXTURE_2D, texImage);
|
||||
|
||||
printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n",
|
||||
BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
|
||||
NearestFilter ? "NEAREST" : "LINEAR");
|
||||
printf("You should see: %s\n", views[View].string );
|
||||
fflush(stdout);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
|
||||
|
||||
if (NearestFilter) {
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST_MIPMAP_NEAREST);
|
||||
}
|
||||
else {
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
|
||||
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
|
||||
glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
|
||||
glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0);
|
||||
glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0);
|
||||
glEnd();
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
myReshape(int w, int h)
|
||||
{
|
||||
glViewport(0, 0, w, h);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
key(unsigned char k, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (k) {
|
||||
#if 0
|
||||
case 'b':
|
||||
BaseLevel--;
|
||||
if (BaseLevel < 0)
|
||||
BaseLevel = 0;
|
||||
break;
|
||||
case 'B':
|
||||
BaseLevel++;
|
||||
if (BaseLevel > 10)
|
||||
BaseLevel = 10;
|
||||
break;
|
||||
case 'm':
|
||||
MaxLevel--;
|
||||
if (MaxLevel < 0)
|
||||
MaxLevel = 0;
|
||||
break;
|
||||
case 'M':
|
||||
MaxLevel++;
|
||||
if (MaxLevel > 10)
|
||||
MaxLevel = 10;
|
||||
break;
|
||||
case 'l':
|
||||
LodBias -= 0.25;
|
||||
break;
|
||||
case 'L':
|
||||
LodBias += 0.25;
|
||||
break;
|
||||
case 'n':
|
||||
MinLod -= 0.25;
|
||||
break;
|
||||
case 'N':
|
||||
MinLod += 0.25;
|
||||
break;
|
||||
case 'x':
|
||||
MaxLod -= 0.25;
|
||||
break;
|
||||
case 'X':
|
||||
MaxLod += 0.25;
|
||||
break;
|
||||
case 'f':
|
||||
NearestFilter = !NearestFilter;
|
||||
break;
|
||||
#endif
|
||||
case ' ':
|
||||
initValues();
|
||||
break;
|
||||
case 27: /* Escape */
|
||||
exit(0);
|
||||
break;
|
||||
default:
|
||||
changeView();
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("usage:\n");
|
||||
printf(" Any Change view\n");
|
||||
printf(" SPACE reset values\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
|
||||
glutInitWindowSize (600, 600);
|
||||
glutCreateWindow (argv[0]);
|
||||
glewInit();
|
||||
myInit();
|
||||
glutReshapeFunc (myReshape);
|
||||
glutDisplayFunc(display);
|
||||
glutKeyboardFunc(key);
|
||||
usage();
|
||||
glutMainLoop();
|
||||
return 0; /* ANSI C requires main to return int. */
|
||||
}
|
||||
149
progs/tests/persp_hint.c
Normal file
149
progs/tests/persp_hint.c
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Test the GL_PERSPECTIVE_CORRECTION_HINT setting and its effect on
|
||||
* color interpolation.
|
||||
*
|
||||
* Press 'i' to toggle between GL_NICEST/GL_FASTEST/GL_DONT_CARE.
|
||||
*
|
||||
* Depending on the driver, the hint may make a difference, or not.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static GLenum PerspHint = GL_DONT_CARE;
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
GLubyte image[256][256][4];
|
||||
GLuint i, j;
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (j = 0; j < 256; j++) {
|
||||
image[i][j][0] = j;
|
||||
image[i][j][1] = j;
|
||||
image[i][j][2] = j;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, 256, 256, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
display(void)
|
||||
{
|
||||
switch (PerspHint) {
|
||||
case GL_NICEST:
|
||||
printf("hint = GL_NICEST\n");
|
||||
break;
|
||||
case GL_FASTEST:
|
||||
printf("hint = GL_FASTEST\n");
|
||||
break;
|
||||
case GL_DONT_CARE:
|
||||
printf("hint = GL_DONT_CARE\n");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
#if 1
|
||||
glBegin(GL_QUADS);
|
||||
/* exercise perspective interpolation */
|
||||
glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
|
||||
glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, 1.0, -1.0);
|
||||
glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, 1.0, -7.0);
|
||||
glColor3f(0.0, 1.0, 0.0); glVertex3f( 7.0, -1.0, -7.0);
|
||||
|
||||
/* stripe of linear interpolation */
|
||||
glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, -0.1, -1.001);
|
||||
glColor3f(0.0, 0.0, 0.0); glVertex3f(-1.0, 0.1, -1.001);
|
||||
glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0, 0.1, -1.001);
|
||||
glColor3f(0.0, 1.0, 0.0); glVertex3f( 1.0, -0.1, -1.001);
|
||||
glEnd();
|
||||
#else
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 0.0, -1.0);
|
||||
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
|
||||
glTexCoord2f(1.0, 1.0); glVertex3f( 5.0, 1.0, -7.0);
|
||||
glTexCoord2f(1.0, 0.0); glVertex3f( 5.0, 0.0, -7.0);
|
||||
|
||||
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.001);
|
||||
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 0.0, -1.001);
|
||||
glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 0.0, -1.001);
|
||||
glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, -1.001);
|
||||
glEnd();
|
||||
#endif
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
reshape(int w, int h)
|
||||
{
|
||||
glViewport(0, 0, w, h);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(90.0, (GLfloat) w / h, 1.0, 300.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
key(unsigned char k, int x, int y)
|
||||
{
|
||||
switch (k) {
|
||||
case 27: /* Escape */
|
||||
exit(0);
|
||||
break;
|
||||
case 'i':
|
||||
if (PerspHint == GL_FASTEST)
|
||||
PerspHint = GL_NICEST;
|
||||
else if (PerspHint == GL_NICEST)
|
||||
PerspHint = GL_DONT_CARE;
|
||||
else
|
||||
PerspHint = GL_FASTEST;
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, PerspHint);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
|
||||
glutInitWindowSize (500, 500);
|
||||
glutCreateWindow (argv[0]);
|
||||
glutReshapeFunc (reshape);
|
||||
glutDisplayFunc(display);
|
||||
glutKeyboardFunc(key);
|
||||
|
||||
printf("Main quad: perspective projection\n");
|
||||
printf("Middle stripe: linear interpolation\n");
|
||||
printf("Press 'i' to toggle interpolation hint\n");
|
||||
init();
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue