132001f49Smrg#include <stdio.h> 232001f49Smrg#include <VG/openvg.h> 332001f49Smrg#include <EGL/egl.h> 432001f49Smrg 532001f49Smrg#include "lion-render.h" 632001f49Smrg#include "eglut.h" 732001f49Smrg 832001f49Smrgstatic VGint width, height; 932001f49Smrgstruct lion *lion = 0; 1032001f49SmrgVGfloat angle = 0; 1132001f49Smrg 1232001f49Smrgstatic void 1332001f49Smrgdraw(void) 1432001f49Smrg{ 1532001f49Smrg static double t0 = -1.0; 1632001f49Smrg static int num_frames; 1732001f49Smrg double now; 1832001f49Smrg 1932001f49Smrg vgClear(0, 0, width, height); 2032001f49Smrg 2132001f49Smrg vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); 2232001f49Smrg vgLoadIdentity(); 2332001f49Smrg vgTranslate(width/2, height/2); 2432001f49Smrg vgRotate(angle); 2532001f49Smrg vgTranslate(-width/2, -height/2); 2632001f49Smrg 2732001f49Smrg lion_render(lion); 2832001f49Smrg vgFlush(); 2932001f49Smrg num_frames++; 3032001f49Smrg 3132001f49Smrg if (t0 < 0.0) { 3232001f49Smrg t0 = eglutGet(EGLUT_ELAPSED_TIME) / 1000.0; 3332001f49Smrg num_frames = 0; 3432001f49Smrg } 3532001f49Smrg 3632001f49Smrg now = eglutGet(EGLUT_ELAPSED_TIME) / 1000.0; 3732001f49Smrg if (now - t0 > 5.0) { 3832001f49Smrg /* just a rough estimate */ 3932001f49Smrg printf("%d frames in %3.1f seconds = %6.3f FPS\n", 4032001f49Smrg num_frames, now - t0, num_frames / (now - t0)); 4132001f49Smrg 4232001f49Smrg t0 = now; 4332001f49Smrg num_frames = 0; 4432001f49Smrg } 4532001f49Smrg 4632001f49Smrg ++angle; 4732001f49Smrg eglutPostRedisplay(); 4832001f49Smrg} 4932001f49Smrg 5032001f49Smrg 5132001f49Smrg/* new window size or exposure */ 5232001f49Smrgstatic void 5332001f49Smrgreshape(int w, int h) 5432001f49Smrg{ 5532001f49Smrg width = w; 5632001f49Smrg height = h; 5732001f49Smrg} 5832001f49Smrg 5932001f49Smrg 6032001f49Smrgstatic void 6132001f49Smrginit(void) 6232001f49Smrg{ 6332001f49Smrg float clear_color[4] = {1.0, 1.0, 1.0, 1.0}; 6432001f49Smrg vgSetfv(VG_CLEAR_COLOR, 4, clear_color); 6532001f49Smrg 6632001f49Smrg lion = lion_create(); 6732001f49Smrg} 6832001f49Smrg 6932001f49Smrg 7032001f49Smrgint 7132001f49Smrgmain(int argc, char *argv[]) 7232001f49Smrg{ 7332001f49Smrg eglutInitWindowSize(350, 450); 7432001f49Smrg eglutInitAPIMask(EGLUT_OPENVG_BIT); 7532001f49Smrg eglutInit(argc, argv); 7632001f49Smrg 7732001f49Smrg eglutCreateWindow("Lion Example"); 7832001f49Smrg 7932001f49Smrg eglutReshapeFunc(reshape); 8032001f49Smrg eglutDisplayFunc(draw); 8132001f49Smrg 8232001f49Smrg init(); 8332001f49Smrg 8432001f49Smrg eglutMainLoop(); 8532001f49Smrg 8632001f49Smrg return 0; 8732001f49Smrg} 88