132001f49Smrg#include "eglcommon.h"
232001f49Smrg
332001f49Smrg#include <VG/openvg.h>
432001f49Smrg
532001f49Smrg#include <math.h>
632001f49Smrg#include <stdlib.h>
732001f49Smrg#include <stdio.h>
832001f49Smrg
932001f49Smrgstatic void
1032001f49Smrginit(void)
1132001f49Smrg{
1232001f49Smrg}
1332001f49Smrg
1432001f49Smrg/* new window size or exposure */
1532001f49Smrgstatic void
1632001f49Smrgreshape(int w, int h)
1732001f49Smrg{
1832001f49Smrg}
1932001f49Smrg
2032001f49Smrgstatic const VGfloat red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
2132001f49Smrgstatic const VGfloat black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
2232001f49Smrgstatic const VGfloat white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
2332001f49Smrg
2432001f49Smrgstatic void
2532001f49Smrgdraw(void)
2632001f49Smrg{
2732001f49Smrg   const VGint w = 48;
2832001f49Smrg   VGImage img1, img2;
2932001f49Smrg   VGint x, y;
3032001f49Smrg
3132001f49Smrg   vgSetfv(VG_CLEAR_COLOR, 4, white);
3232001f49Smrg   vgClear(0, 0, window_width(), window_height());
3332001f49Smrg
3432001f49Smrg   img1 = vgCreateImage(VG_sRGBA_8888, w, w,
3532001f49Smrg         VG_IMAGE_QUALITY_NONANTIALIASED);
3632001f49Smrg   img2 = vgCreateImage(VG_sRGBA_8888, w, w,
3732001f49Smrg         VG_IMAGE_QUALITY_NONANTIALIASED);
3832001f49Smrg
3932001f49Smrg   x = 5;
4032001f49Smrg   y = (window_height() - w) / 2;
4132001f49Smrg
4232001f49Smrg   /* test vgSetPixels */
4332001f49Smrg   vgSetfv(VG_CLEAR_COLOR, 4, red);
4432001f49Smrg   vgClearImage(img1, 0, 0, w, w / 2);
4532001f49Smrg   vgSetfv(VG_CLEAR_COLOR, 4, black);
4632001f49Smrg   vgClearImage(img1, 0, w / 2, w, w / 2);
4732001f49Smrg   vgSetPixels(x, y, img1, 0, 0, w, w);
4832001f49Smrg
4932001f49Smrg   x += w + 5;
5032001f49Smrg
5132001f49Smrg   /* test vgDrawImage */
5232001f49Smrg   vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
5332001f49Smrg   vgLoadIdentity();
5432001f49Smrg   vgTranslate(x, y);
5532001f49Smrg   vgDrawImage(img1);
5632001f49Smrg
5732001f49Smrg   /* test vgGetPixels */
5832001f49Smrg   vgGetPixels(img1, 0, 0, x, y, w, w);
5932001f49Smrg   x += w + 5;
6032001f49Smrg   vgSetPixels(x, y, img1, 0, 0, w, w);
6132001f49Smrg
6232001f49Smrg   x += w + 5;
6332001f49Smrg
6432001f49Smrg   /* test vgCopyImage */
6532001f49Smrg   vgCopyImage(img2, 0, 0, img1, 0, 0, w, w, VG_FALSE);
6632001f49Smrg   vgSetPixels(x, y, img2, 0, 0, w, w);
6732001f49Smrg
6832001f49Smrg   /* vgCopyPixels */
6932001f49Smrg   vgCopyPixels(x + w + 5, y, x, y, w, w);
7032001f49Smrg
7132001f49Smrg   vgDestroyImage(img1);
7232001f49Smrg   vgDestroyImage(img2);
7332001f49Smrg}
7432001f49Smrg
7532001f49Smrg
7632001f49Smrgint main(int argc, char **argv)
7732001f49Smrg{
7832001f49Smrg   set_window_size(300, 300);
7932001f49Smrg   return run(argc, argv, init, reshape,
8032001f49Smrg              draw, 0);
8132001f49Smrg}
82