progs: Remove remaining EGL demos.

They have been moved to git+ssh://git.freedesktop.org/git/mesa/demos.
This commit is contained in:
Chia-I Wu 2010-05-21 22:12:32 -06:00
parent ab780bccb7
commit e8d8ea2a39
38 changed files with 0 additions and 5591 deletions

View File

@ -420,18 +420,6 @@ DEMO_FILES = \
$(DIRECTORY)/progs/demos/*.cxx \
$(DIRECTORY)/progs/demos/*.dat \
$(DIRECTORY)/progs/demos/README \
$(DIRECTORY)/progs/egl/eglut/Makefile \
$(DIRECTORY)/progs/egl/eglut/*.[ch] \
$(DIRECTORY)/progs/egl/opengl/Makefile \
$(DIRECTORY)/progs/egl/opengl/*.[ch] \
$(DIRECTORY)/progs/egl/opengles1/Makefile \
$(DIRECTORY)/progs/egl/opengles1/*.[ch] \
$(DIRECTORY)/progs/egl/opengles2/Makefile \
$(DIRECTORY)/progs/egl/opengles2/*.[ch] \
$(DIRECTORY)/progs/egl/openvg/Makefile \
$(DIRECTORY)/progs/egl/openvg/*.[ch] \
$(DIRECTORY)/progs/egl/openvg/*/Makefile \
$(DIRECTORY)/progs/egl/openvg/*/*.[ch] \
$(DIRECTORY)/progs/fbdev/Makefile \
$(DIRECTORY)/progs/fbdev/glfbdevtest.c \
$(DIRECTORY)/progs/objviewer/*.[ch] \

View File

@ -1,39 +0,0 @@
# progs/egl/eglut
TOP = ../../..
include $(TOP)/configs/current
INCLUDES = \
-I$(TOP)/include \
$(X11_CFLAGS)
SOURCES = \
eglut.c \
eglut_screen.c \
eglut_x11.c
EGLUT_X11_OBJECTS = eglut.o eglut_x11.o
EGLUT_SCREEN_OBJECTS = eglut.o eglut_screen.o
default: depend libeglut-x11.a libeglut-screen.a
libeglut-x11.a: $(EGLUT_X11_OBJECTS)
$(MKLIB) -o eglut-x11 -static $(EGLUT_X11_OBJECTS)
libeglut-screen.a: $(EGLUT_SCREEN_OBJECTS)
$(MKLIB) -o eglut-screen -static $(EGLUT_SCREEN_OBJECTS)
.c.o:
$(CC) -c -o $@ $< $(INCLUDES) $(DEFINES) $(CFLAGS)
depend: $(SOURCES)
@rm -f depend
@touch depend
@$(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) \
> /dev/null 2>/dev/null
clean:
rm -f *.o *.a
rm -f depend depend.bak
sinclude depend

View File

@ -1,348 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/time.h>
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include "eglutint.h"
static struct eglut_state _eglut_state = {
.api_mask = EGLUT_OPENGL_ES1_BIT,
.window_width = 300,
.window_height = 300,
.verbose = 0,
.num_windows = 0,
};
struct eglut_state *_eglut = &_eglut_state;
void
_eglutFatal(char *format, ...)
{
va_list args;
va_start(args, format);
fprintf(stderr, "EGLUT: ");
vfprintf(stderr, format, args);
va_end(args);
putc('\n', stderr);
exit(1);
}
/* return current time (in milliseconds) */
int
_eglutNow(void)
{
struct timeval tv;
#ifdef __VMS
(void) gettimeofday(&tv, NULL );
#else
struct timezone tz;
(void) gettimeofday(&tv, &tz);
#endif
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
static void
_eglutDestroyWindow(struct eglut_window *win)
{
if (_eglut->surface_type != EGL_PBUFFER_BIT &&
_eglut->surface_type != EGL_SCREEN_BIT_MESA)
eglDestroySurface(_eglut->dpy, win->surface);
_eglutNativeFiniWindow(win);
eglDestroyContext(_eglut->dpy, win->context);
}
static EGLConfig
_eglutChooseConfig(void)
{
EGLConfig config;
EGLint config_attribs[32];
EGLint renderable_type, num_configs, i;
i = 0;
config_attribs[i++] = EGL_RED_SIZE;
config_attribs[i++] = 1;
config_attribs[i++] = EGL_GREEN_SIZE;
config_attribs[i++] = 1;
config_attribs[i++] = EGL_BLUE_SIZE;
config_attribs[i++] = 1;
config_attribs[i++] = EGL_DEPTH_SIZE;
config_attribs[i++] = 1;
config_attribs[i++] = EGL_SURFACE_TYPE;
config_attribs[i++] = _eglut->surface_type;
config_attribs[i++] = EGL_RENDERABLE_TYPE;
renderable_type = 0x0;
if (_eglut->api_mask & EGLUT_OPENGL_BIT)
renderable_type |= EGL_OPENGL_BIT;
if (_eglut->api_mask & EGLUT_OPENGL_ES1_BIT)
renderable_type |= EGL_OPENGL_ES_BIT;
if (_eglut->api_mask & EGLUT_OPENGL_ES2_BIT)
renderable_type |= EGL_OPENGL_ES2_BIT;
if (_eglut->api_mask & EGLUT_OPENVG_BIT)
renderable_type |= EGL_OPENVG_BIT;
config_attribs[i++] = renderable_type;
config_attribs[i] = EGL_NONE;
if (!eglChooseConfig(_eglut->dpy,
config_attribs, &config, 1, &num_configs) || !num_configs)
_eglutFatal("failed to choose a config");
return config;
}
static struct eglut_window *
_eglutCreateWindow(const char *title, int x, int y, int w, int h)
{
struct eglut_window *win;
EGLint context_attribs[4];
EGLint api, i;
win = calloc(1, sizeof(*win));
if (!win)
_eglutFatal("failed to allocate window");
win->config = _eglutChooseConfig();
i = 0;
context_attribs[i] = EGL_NONE;
/* multiple APIs? */
api = EGL_OPENGL_ES_API;
if (_eglut->api_mask & EGLUT_OPENGL_BIT) {
api = EGL_OPENGL_API;
}
else if (_eglut->api_mask & EGLUT_OPENVG_BIT) {
api = EGL_OPENVG_API;
}
else if (_eglut->api_mask & EGLUT_OPENGL_ES2_BIT) {
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
context_attribs[i++] = 2;
}
context_attribs[i] = EGL_NONE;
eglBindAPI(api);
win->context = eglCreateContext(_eglut->dpy,
win->config, EGL_NO_CONTEXT, context_attribs);
if (!win->context)
_eglutFatal("failed to create context");
_eglutNativeInitWindow(win, title, x, y, w, h);
switch (_eglut->surface_type) {
case EGL_WINDOW_BIT:
win->surface = eglCreateWindowSurface(_eglut->dpy,
win->config, win->native.u.window, NULL);
break;
case EGL_PIXMAP_BIT:
win->surface = eglCreatePixmapSurface(_eglut->dpy,
win->config, win->native.u.pixmap, NULL);
break;
case EGL_PBUFFER_BIT:
case EGL_SCREEN_BIT_MESA:
win->surface = win->native.u.surface;
break;
default:
break;
}
if (win->surface == EGL_NO_SURFACE)
_eglutFatal("failed to create surface");
return win;
}
void
eglutInitAPIMask(int mask)
{
_eglut->api_mask = mask;
}
void
eglutInitWindowSize(int width, int height)
{
_eglut->window_width = width;
_eglut->window_height = height;
}
void
eglutInit(int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0)
_eglut->display_name = argv[++i];
else if (strcmp(argv[i], "-info") == 0) {
_eglut->verbose = 1;
}
}
_eglutNativeInitDisplay();
_eglut->dpy = eglGetDisplay(_eglut->native_dpy);
if (!eglInitialize(_eglut->dpy, &_eglut->major, &_eglut->minor))
_eglutFatal("failed to initialize EGL display");
_eglut->init_time = _eglutNow();
printf("EGL_VERSION = %s\n", eglQueryString(_eglut->dpy, EGL_VERSION));
if (_eglut->verbose) {
printf("EGL_VENDOR = %s\n", eglQueryString(_eglut->dpy, EGL_VENDOR));
printf("EGL_EXTENSIONS = %s\n",
eglQueryString(_eglut->dpy, EGL_EXTENSIONS));
printf("EGL_CLIENT_APIS = %s\n",
eglQueryString(_eglut->dpy, EGL_CLIENT_APIS));
}
}
int
eglutGet(int state)
{
int val;
switch (state) {
case EGLUT_ELAPSED_TIME:
val = _eglutNow() - _eglut->init_time;
break;
default:
val = -1;
break;
}
return val;
}
void
eglutIdleFunc(EGLUTidleCB func)
{
_eglut->idle_cb = func;
}
void
eglutPostRedisplay(void)
{
_eglut->redisplay = 1;
}
void
eglutMainLoop(void)
{
struct eglut_window *win = _eglut->current;
if (!win)
_eglutFatal("no window is created\n");
if (win->reshape_cb)
win->reshape_cb(win->native.width, win->native.height);
_eglutNativeEventLoop();
}
static void
_eglutFini(void)
{
eglTerminate(_eglut->dpy);
_eglutNativeFiniDisplay();
}
void
eglutDestroyWindow(int win)
{
struct eglut_window *window = _eglut->current;
if (window->index != win)
return;
/* XXX it causes some bug in st/egl KMS backend */
if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA)
eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
_eglutDestroyWindow(_eglut->current);
}
static void
_eglutDefaultKeyboard(unsigned char key)
{
if (key == 27) {
if (_eglut->current)
eglutDestroyWindow(_eglut->current->index);
_eglutFini();
exit(0);
}
}
int
eglutCreateWindow(const char *title)
{
struct eglut_window *win;
win = _eglutCreateWindow(title, 0, 0,
_eglut->window_width, _eglut->window_height);
win->index = _eglut->num_windows++;
win->reshape_cb = NULL;
win->display_cb = NULL;
win->keyboard_cb = _eglutDefaultKeyboard;
win->special_cb = NULL;
if (!eglMakeCurrent(_eglut->dpy, win->surface, win->surface, win->context))
_eglutFatal("failed to make window current");
_eglut->current = win;
return win->index;
}
int
eglutGetWindowWidth(void)
{
struct eglut_window *win = _eglut->current;
return win->native.width;
}
int
eglutGetWindowHeight(void)
{
struct eglut_window *win = _eglut->current;
return win->native.height;
}
void
eglutDisplayFunc(EGLUTdisplayCB func)
{
struct eglut_window *win = _eglut->current;
win->display_cb = func;
}
void
eglutReshapeFunc(EGLUTreshapeCB func)
{
struct eglut_window *win = _eglut->current;
win->reshape_cb = func;
}
void
eglutKeyboardFunc(EGLUTkeyboardCB func)
{
struct eglut_window *win = _eglut->current;
win->keyboard_cb = func;
}
void
eglutSpecialFunc(EGLUTspecialCB func)
{
struct eglut_window *win = _eglut->current;
win->special_cb = func;
}

View File

@ -1,68 +0,0 @@
#ifndef EGLUT_H
#define EGLUT_H
/* used by eglutInitAPIMask */
enum {
EGLUT_OPENGL_BIT = 0x1,
EGLUT_OPENGL_ES1_BIT = 0x2,
EGLUT_OPENGL_ES2_BIT = 0x4,
EGLUT_OPENVG_BIT = 0x8
};
/* used by EGLUTspecialCB */
enum {
/* function keys */
EGLUT_KEY_F1,
EGLUT_KEY_F2,
EGLUT_KEY_F3,
EGLUT_KEY_F4,
EGLUT_KEY_F5,
EGLUT_KEY_F6,
EGLUT_KEY_F7,
EGLUT_KEY_F8,
EGLUT_KEY_F9,
EGLUT_KEY_F10,
EGLUT_KEY_F11,
EGLUT_KEY_F12,
/* directional keys */
EGLUT_KEY_LEFT,
EGLUT_KEY_UP,
EGLUT_KEY_RIGHT,
EGLUT_KEY_DOWN,
};
/* used by eglutGet */
enum {
EGLUT_ELAPSED_TIME
};
typedef void (*EGLUTidleCB)(void);
typedef void (*EGLUTreshapeCB)(int, int);
typedef void (*EGLUTdisplayCB)(void);
typedef void (*EGLUTkeyboardCB)(unsigned char);
typedef void (*EGLUTspecialCB)(int);
void eglutInitAPIMask(int mask);
void eglutInitWindowSize(int width, int height);
void eglutInit(int argc, char **argv);
int eglutGet(int state);
void eglutIdleFunc(EGLUTidleCB func);
void eglutPostRedisplay(void);
void eglutMainLoop(void);
int eglutCreateWindow(const char *title);
void eglutDestroyWindow(int win);
int eglutGetWindowWidth(void);
int eglutGetWindowHeight(void);
void eglutDisplayFunc(EGLUTdisplayCB func);
void eglutReshapeFunc(EGLUTreshapeCB func);
void eglutKeyboardFunc(EGLUTkeyboardCB func);
void eglutSpecialFunc(EGLUTspecialCB func);
#endif /* EGLUT_H */

View File

@ -1,154 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#define EGL_EGLEXT_PROTOTYPES
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include "eglutint.h"
#define MAX_MODES 100
static EGLScreenMESA kms_screen;
static EGLModeMESA kms_mode;
static EGLint kms_width, kms_height;
void
_eglutNativeInitDisplay(void)
{
_eglut->native_dpy = EGL_DEFAULT_DISPLAY;
_eglut->surface_type = EGL_SCREEN_BIT_MESA;
}
void
_eglutNativeFiniDisplay(void)
{
kms_screen = 0;
kms_mode = 0;
kms_width = 0;
kms_height = 0;
}
static void
init_kms(void)
{
EGLModeMESA modes[MAX_MODES];
EGLint num_screens, num_modes;
EGLint width, height, best_mode;
EGLint i;
if (!eglGetScreensMESA(_eglut->dpy, &kms_screen, 1, &num_screens) ||
!num_screens)
_eglutFatal("eglGetScreensMESA failed\n");
if (!eglGetModesMESA(_eglut->dpy, kms_screen,
modes, MAX_MODES, &num_modes) || !num_modes)
_eglutFatal("eglGetModesMESA failed!\n");
printf("Found %d modes:\n", num_modes);
best_mode = 0;
width = 0;
height = 0;
for (i = 0; i < num_modes; i++) {
EGLint w, h;
eglGetModeAttribMESA(_eglut->dpy, modes[i], EGL_WIDTH, &w);
eglGetModeAttribMESA(_eglut->dpy, modes[i], EGL_HEIGHT, &h);
printf("%3d: %d x %d\n", i, w, h);
if (w > width && h > height) {
width = w;
height = h;
best_mode = i;
}
}
printf("Will use screen size: %d x %d\n", width, height);
kms_mode = modes[best_mode];
kms_width = width;
kms_height = height;
}
void
_eglutNativeInitWindow(struct eglut_window *win, const char *title,
int x, int y, int w, int h)
{
EGLint surf_attribs[16];
EGLint i;
const char *exts;
exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS);
if (!exts || !strstr(exts, "EGL_MESA_screen_surface"))
_eglutFatal("EGL_MESA_screen_surface is not supported\n");
init_kms();
i = 0;
surf_attribs[i++] = EGL_WIDTH;
surf_attribs[i++] = kms_width;
surf_attribs[i++] = EGL_HEIGHT;
surf_attribs[i++] = kms_height;
surf_attribs[i++] = EGL_NONE;
/* create surface */
win->native.u.surface = eglCreateScreenSurfaceMESA(_eglut->dpy,
win->config, surf_attribs);
if (win->native.u.surface == EGL_NO_SURFACE)
_eglutFatal("eglCreateScreenSurfaceMESA failed\n");
if (!eglShowScreenSurfaceMESA(_eglut->dpy, kms_screen,
win->native.u.surface, kms_mode))
_eglutFatal("eglShowScreenSurfaceMESA failed\n");
win->native.width = kms_width;
win->native.height = kms_height;
}
void
_eglutNativeFiniWindow(struct eglut_window *win)
{
eglShowScreenSurfaceMESA(_eglut->dpy,
kms_screen, EGL_NO_SURFACE, 0);
eglDestroySurface(_eglut->dpy, win->native.u.surface);
}
void
_eglutNativeEventLoop(void)
{
int start = _eglutNow();
int frames = 0;
_eglut->redisplay = 1;
while (1) {
struct eglut_window *win = _eglut->current;
int now = _eglutNow();
if (now - start > 5000) {
double elapsed = (double) (now - start) / 1000.0;
printf("%d frames in %3.1f seconds = %6.3f FPS\n",
frames, elapsed, frames / elapsed);
start = now;
frames = 0;
/* send escape */
if (win->keyboard_cb)
win->keyboard_cb(27);
}
if (_eglut->idle_cb)
_eglut->idle_cb();
if (_eglut->redisplay) {
_eglut->redisplay = 0;
if (win->display_cb)
win->display_cb();
eglSwapBuffers(_eglut->dpy, win->surface);
frames++;
}
}
}

View File

@ -1,220 +0,0 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include "eglutint.h"
void
_eglutNativeInitDisplay(void)
{
_eglut->native_dpy = XOpenDisplay(_eglut->display_name);
if (!_eglut->native_dpy)
_eglutFatal("failed to initialize native display");
_eglut->surface_type = EGL_WINDOW_BIT;
}
void
_eglutNativeFiniDisplay(void)
{
XCloseDisplay(_eglut->native_dpy);
}
void
_eglutNativeInitWindow(struct eglut_window *win, const char *title,
int x, int y, int w, int h)
{
XVisualInfo *visInfo, visTemplate;
int num_visuals;
Window root, xwin;
XSetWindowAttributes attr;
unsigned long mask;
EGLint vid;
if (!eglGetConfigAttrib(_eglut->dpy,
win->config, EGL_NATIVE_VISUAL_ID, &vid))
_eglutFatal("failed to get visual id");
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
visInfo = XGetVisualInfo(_eglut->native_dpy,
VisualIDMask, &visTemplate, &num_visuals);
if (!visInfo)
_eglutFatal("failed to get an visual of id 0x%x", vid);
root = RootWindow(_eglut->native_dpy, DefaultScreen(_eglut->native_dpy));
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(_eglut->native_dpy,
root, visInfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
xwin = XCreateWindow(_eglut->native_dpy, root, x, y, w, h,
0, visInfo->depth, InputOutput, visInfo->visual, mask, &attr);
if (!xwin)
_eglutFatal("failed to create a window");
XFree(visInfo);
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = w;
sizehints.height = h;
sizehints.flags = USSize | USPosition;
XSetNormalHints(_eglut->native_dpy, xwin, &sizehints);
XSetStandardProperties(_eglut->native_dpy, xwin,
title, title, None, (char **) NULL, 0, &sizehints);
}
XMapWindow(_eglut->native_dpy, xwin);
win->native.u.window = xwin;
win->native.width = w;
win->native.height = h;
}
void
_eglutNativeFiniWindow(struct eglut_window *win)
{
XDestroyWindow(_eglut->native_dpy, win->native.u.window);
}
static int
lookup_keysym(KeySym sym)
{
int special;
switch (sym) {
case XK_F1:
special = EGLUT_KEY_F1;
break;
case XK_F2:
special = EGLUT_KEY_F2;
break;
case XK_F3:
special = EGLUT_KEY_F3;
break;
case XK_F4:
special = EGLUT_KEY_F4;
break;
case XK_F5:
special = EGLUT_KEY_F5;
break;
case XK_F6:
special = EGLUT_KEY_F6;
break;
case XK_F7:
special = EGLUT_KEY_F7;
break;
case XK_F8:
special = EGLUT_KEY_F8;
break;
case XK_F9:
special = EGLUT_KEY_F9;
break;
case XK_F10:
special = EGLUT_KEY_F10;
break;
case XK_F11:
special = EGLUT_KEY_F11;
break;
case XK_F12:
special = EGLUT_KEY_F12;
break;
case XK_KP_Left:
case XK_Left:
special = EGLUT_KEY_LEFT;
break;
case XK_KP_Up:
case XK_Up:
special = EGLUT_KEY_UP;
break;
case XK_KP_Right:
case XK_Right:
special = EGLUT_KEY_RIGHT;
break;
case XK_KP_Down:
case XK_Down:
special = EGLUT_KEY_DOWN;
break;
default:
special = -1;
break;
}
return special;
}
static void
next_event(struct eglut_window *win)
{
int redraw = 0;
XEvent event;
if (!XPending(_eglut->native_dpy)) {
if (_eglut->idle_cb)
_eglut->idle_cb();
return;
}
XNextEvent(_eglut->native_dpy, &event);
switch (event.type) {
case Expose:
redraw = 1;
break;
case ConfigureNotify:
win->native.width = event.xconfigure.width;
win->native.height = event.xconfigure.height;
if (win->reshape_cb)
win->reshape_cb(win->native.width, win->native.height);
break;
case KeyPress:
{
char buffer[1];
KeySym sym;
int r;
r = XLookupString(&event.xkey,
buffer, sizeof(buffer), &sym, NULL);
if (r && win->keyboard_cb) {
win->keyboard_cb(buffer[0]);
}
else if (!r && win->special_cb) {
r = lookup_keysym(sym);
if (r >= 0)
win->special_cb(r);
}
}
redraw = 1;
break;
default:
; /*no-op*/
}
_eglut->redisplay = redraw;
}
void
_eglutNativeEventLoop(void)
{
while (1) {
struct eglut_window *win = _eglut->current;
next_event(win);
if (_eglut->redisplay) {
_eglut->redisplay = 0;
if (win->display_cb)
win->display_cb();
eglSwapBuffers(_eglut->dpy, win->surface);
}
}
}

View File

@ -1,78 +0,0 @@
#ifndef _EGLUTINT_H_
#define _EGLUTINT_H_
#include "EGL/egl.h"
#include "eglut.h"
struct eglut_window {
EGLConfig config;
EGLContext context;
/* initialized by native display */
struct {
union {
EGLNativeWindowType window;
EGLNativePixmapType pixmap;
EGLSurface surface; /* pbuffer or screen surface */
} u;
int width, height;
} native;
EGLSurface surface;
int index;
EGLUTreshapeCB reshape_cb;
EGLUTdisplayCB display_cb;
EGLUTkeyboardCB keyboard_cb;
EGLUTspecialCB special_cb;
};
struct eglut_state {
int api_mask;
int window_width, window_height;
const char *display_name;
int verbose;
int init_time;
EGLUTidleCB idle_cb;
int num_windows;
/* initialized by native display */
EGLNativeDisplayType native_dpy;
EGLint surface_type;
EGLDisplay dpy;
EGLint major, minor;
struct eglut_window *current;
int redisplay;
};
extern struct eglut_state *_eglut;
void
_eglutFatal(char *format, ...);
int
_eglutNow(void);
void
_eglutNativeInitDisplay(void);
void
_eglutNativeFiniDisplay(void);
void
_eglutNativeInitWindow(struct eglut_window *win, const char *title,
int x, int y, int w, int h);
void
_eglutNativeFiniWindow(struct eglut_window *win);
void
_eglutNativeEventLoop(void);
#endif /* _EGLUTINT_H_ */

View File

@ -1,26 +0,0 @@
lion_x11
lion_screen
sp_x11
sp_screen
trivial/arc
trivial/cap
trivial/clear
trivial/coord
trivial/dash
trivial/ellipse
trivial/filter
trivial/gradorigin
trivial/lineto
trivial/lingrad
trivial/lookup
trivial/mask4
trivial/mask
trivial/path3
trivial/radialgrad
trivial/readpixels
trivial/roundedrect
trivial/star-nonzero
trivial/star-oddeven
trivial/stroke2
trivial/stroke
trivial/vguarc

View File

@ -1,51 +0,0 @@
# progs/egl/openvg/Makefile
TOP = ../../..
include $(TOP)/configs/current
VG_LIBS=-lm -L$(TOP)/$(LIB_DIR) -l$(EGL_LIB) -l$(VG_LIB)
INCLUDE_DIRS = -I$(TOP)/include $(X11_CFLAGS)
EGLUT_DIR = $(TOP)/progs/egl/eglut
EGLUT_DEMOS = \
sp
EGLUT_X11_DEMOS := $(addsuffix _x11,$(EGLUT_DEMOS))
EGLUT_SCREEN_DEMOS := $(addsuffix _screen,$(EGLUT_DEMOS))
PROGRAMS = \
lion_x11 \
lion_screen
.c.o:
$(CC) -c $(INCLUDE_DIRS) -I$(EGLUT_DIR) $(CFLAGS) $< -o $@
default: $(PROGRAMS) $(EGLUT_X11_DEMOS) $(EGLUT_SCREEN_DEMOS)
lion_x11: lion.o lion-render.o $(EGLUT_DIR)/libeglut-x11.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ lion.o lion-render.o \
-L$(EGLUT_DIR) -leglut-x11 $(VG_LIBS) $(X11_LIBS)
lion_screen: lion.o lion-render.o $(EGLUT_DIR)/libeglut-screen.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ lion.o lion-render.o \
-L$(EGLUT_DIR) -leglut-screen $(VG_LIBS)
# define the rules for EGLUT demos
define eglut-demo-rule
$(1)_x11 $(1)_screen: $(1)_%: $(1).o $(EGLUT_DIR)/libeglut-%.a
endef
$(foreach demo, $(EGLUT_DEMOS), $(eval $(call eglut-demo-rule,$(demo))))
# build EGLUT demos
$(EGLUT_X11_DEMOS):
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -L$(EGLUT_DIR) -leglut-$* $(VG_LIBS) $(X11_LIBS)
$(EGLUT_SCREEN_DEMOS):
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -L$(EGLUT_DIR) -leglut-$* $(VG_LIBS)
clean:
rm -f *.o *~
rm -f $(EGLUT_X11_DEMOS) $(EGLUT_SCREEN_DEMOS)

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
#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

View File

@ -1,65 +0,0 @@
#include <VG/openvg.h>
#include <EGL/egl.h>
#include "lion-render.h"
#include "eglut.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;
eglutPostRedisplay();
}
/* 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();
}
int
main(int argc, char *argv[])
{
eglutInitWindowSize(350, 450);
eglutInitAPIMask(EGLUT_OPENVG_BIT);
eglutInit(argc, argv);
eglutCreateWindow("Lion Example");
eglutReshapeFunc(reshape);
eglutDisplayFunc(draw);
init();
eglutMainLoop();
return 0;
}

View File

@ -1,522 +0,0 @@
#include <VG/openvg.h>
#include <VG/vgu.h>
#include <math.h>
#include <string.h>
#include "eglut.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 void
draw(void)
{
VGint i;
VGfloat save_matrix[9];
vgClear(0, 0, eglutGetWindowWidth(), eglutGetWindowHeight());
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)
{
eglutInitWindowSize(400, 400);
eglutInitAPIMask(EGLUT_OPENVG_BIT);
eglutInit(argc, argv);
eglutCreateWindow("sp");
eglutReshapeFunc(reshape);
eglutDisplayFunc(draw);
init();
eglutMainLoop();
return 0;
}

View File

@ -1,128 +0,0 @@
# progs/egl/openvg/trivial/Makefile
# These programs aren't intended to be included with the normal distro.
# They're not too interesting but they're good for testing.
TOP = ../../../..
include $(TOP)/configs/current
INCLUDES = -I. -I$(TOP)/include
LIBS=-L$(TOP)/$(LIB_DIR) -lm -lX11 -lEGL -lOpenVG -lpthread
CFLAGS += $(INCLUDES)
HEADERS=eglcommon.h
PROGRAMS = \
arc \
cap \
clear \
coord \
dash \
ellipse \
filter \
gradorigin \
lineto \
lingrad \
lookup \
mask4 \
mask \
path3 \
radialgrad \
readpixels \
roundedrect \
star-nonzero \
star-oddeven \
stroke2 \
stroke \
vguarc
.c.o:
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
default: $(PROGRAMS)
arc: arc.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
cap: cap.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
clear: clear.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
coord: coord.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
dash: dash.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
ellipse: ellipse.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
filter: filter.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
gradorigin: gradorigin.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
image: image.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
lineto: lineto.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
lingrad: lingrad.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
lookup: lookup.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
mask: mask.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
mask4: mask4.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
path3: path3.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
pattern: pattern.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
radialgrad: radialgrad.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
readpixels: readpixels.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
roundedrect: roundedrect.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
star-nonzero: star-nonzero.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
star-oddeven: star-oddeven.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
stroke: stroke.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
stroke2: stroke2.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
vguarc: vguarc.c eglcommon.o
$(CC) $(CFLAGS) $^ $(LIBS) $(APP_LIB_DEPS) -o $@
eglcommon.o: eglcommon.c $(HEADERS)
$(CC) -c $(CFLAGS) eglcommon.c
clean:
rm -f *.o *~
rm -f *.so
rm -f $(PROGRAMS)

View File

@ -1,139 +0,0 @@
#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);
}

View File

@ -1,75 +0,0 @@
#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);
}

View File

@ -1,42 +0,0 @@
#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);
}

View File

@ -1,66 +0,0 @@
#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);
}

View File

@ -1,95 +0,0 @@
#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);
}

View File

@ -1,289 +0,0 @@
#include "eglcommon.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <VG/openvg.h> /* using full OpenGL for now */
#include <GLES/egl.h>
static init_func init = 0;
static draw_func draw = 0;
static reshape_func reshape = 0;
static key_func keyPress = 0;
static VGint width = 300, height = 300;
void set_window_size(int w, int h)
{
width = w;
height = h;
}
/*
* Create an RGB, double-buffered X window.
* Return the window and context handles.
*/
static void
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
const char *name,
int x, int y, int width, int height,
Window *winRet,
EGLContext *ctxRet,
EGLSurface *surfRet)
{
static const EGLint attribs[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
EGL_NONE
};
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
XVisualInfo *visInfo, visTemplate;
int num_visuals;
EGLContext ctx;
EGLConfig config;
EGLint num_configs;
EGLint vid;
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
assert(config);
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!visInfo) {
printf("Error: couldn't get X visual\n");
exit(1);
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
0, visInfo->depth, InputOutput,
visInfo->visual, mask, &attr );
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(x_dpy, win, &sizehints);
XSetStandardProperties(x_dpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
eglBindAPI(EGL_OPENVG_API);
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
if (!ctx) {
printf("Error: eglCreateContext failed\n");
exit(1);
}
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
if (!*surfRet) {
printf("Error: eglCreateWindowSurface failed\n");
exit(1);
}
XFree(visInfo);
*winRet = win;
*ctxRet = ctx;
}
static void
event_loop(Display *dpy, Window win,
EGLDisplay egl_dpy, EGLSurface egl_surf)
{
while (1) {
int redraw = 0;
XEvent event;
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
redraw = 1;
break;
case ConfigureNotify:
if (reshape) {
width = event.xconfigure.width;
height = event.xconfigure.height;
reshape(event.xconfigure.width, event.xconfigure.height);
}
break;
case KeyPress:
{
char buffer[10];
int r, code;
code = XLookupKeysym(&event.xkey, 0);
if (!keyPress || !keyPress(code)) {
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
NULL, NULL);
if (buffer[0] == 27) {
/* escape */
return;
}
}
}
redraw = 1;
break;
default:
; /*no-op*/
}
if (redraw) {
draw();
eglSwapBuffers(egl_dpy, egl_surf);
}
}
}
int window_width(void)
{
return width;
}
int window_height(void)
{
return height;
}
static void
usage(void)
{
printf("Usage:\n");
printf(" -display <displayname> set the display to run on\n");
printf(" -info display OpenGL renderer info\n");
}
int run(int argc, char **argv,
init_func init_f,
reshape_func resh_f,
draw_func draw_f,
key_func key_f)
{
const int winWidth = width, winHeight = height;
Display *x_dpy;
Window win;
EGLSurface egl_surf;
EGLContext egl_ctx;
EGLDisplay egl_dpy;
char *dpyName = NULL;
GLboolean printInfo = GL_FALSE;
EGLint egl_major, egl_minor;
int i;
const char *s;
init = init_f;
draw = draw_f;
reshape = resh_f;
keyPress = key_f;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-display") == 0) {
dpyName = argv[i+1];
i++;
}
else if (strcmp(argv[i], "-info") == 0) {
printInfo = GL_TRUE;
}
}
x_dpy = XOpenDisplay(dpyName);
if (!x_dpy) {
printf("Error: couldn't open display %s\n",
dpyName ? dpyName : getenv("DISPLAY"));
return -1;
}
egl_dpy = eglGetDisplay(x_dpy);
if (!egl_dpy) {
printf("Error: eglGetDisplay() failed\n");
return -1;
}
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
printf("Error: eglInitialize() failed\n");
return -1;
}
s = eglQueryString(egl_dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", s);
make_x_window(x_dpy, egl_dpy,
"OpenVG Example", 0, 0, winWidth, winHeight,
&win, &egl_ctx, &egl_surf);
XMapWindow(x_dpy, win);
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
printf("Error: eglMakeCurrent() failed\n");
return -1;
}
if (printInfo) {
printf("VG_RENDERER = %s\n", (char *) vgGetString(VG_RENDERER));
printf("VG_VERSION = %s\n", (char *) vgGetString(VG_VERSION));
printf("VG_VENDOR = %s\n", (char *) vgGetString(VG_VENDOR));
}
if (init)
init();
/* Set initial projection/viewing transformation.
* We can't be sure we'll get a ConfigureNotify event when the window
* first appears.
*/
if (reshape)
reshape(winWidth, winHeight);
event_loop(x_dpy, win, egl_dpy, egl_surf);
eglMakeCurrent(egl_dpy, 0, 0, 0);
eglDestroyContext(egl_dpy, egl_ctx);
eglDestroySurface(egl_dpy, egl_surf);
eglTerminate(egl_dpy);
XDestroyWindow(x_dpy, win);
XCloseDisplay(x_dpy);
return 0;
}

View File

@ -1,20 +0,0 @@
#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

View File

@ -1,84 +0,0 @@
#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);
}

View File

@ -1,107 +0,0 @@
#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);
}

View File

@ -1,98 +0,0 @@
#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);
}

View File

@ -1,56 +0,0 @@
#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);
}

View File

@ -1,87 +0,0 @@
#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);
}

View File

@ -1,71 +0,0 @@
#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);
}

View File

@ -1,58 +0,0 @@
#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);
}

View File

@ -1,132 +0,0 @@
#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);
}

View File

@ -1,77 +0,0 @@
#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);
}

View File

@ -1,99 +0,0 @@
#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);
}

View File

@ -1,75 +0,0 @@
#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;
}

View File

@ -1,67 +0,0 @@
#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);
}

View File

@ -1,55 +0,0 @@
#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);
}

View File

@ -1,102 +0,0 @@
#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);
}

View File

@ -1,116 +0,0 @@
#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);
}

View File

@ -1,207 +0,0 @@
#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);
}

View File

@ -1,74 +0,0 @@
#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);
}