void render(int w, int h) { { float clearColor[4] = {1,1,1,1}; float scale = w / (tigerMaxX - tigerMinX); eglSwapBuffers(egldisplay, eglsurface); //force EGL to recognize resize vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vgClear(0, 0, w, h); vgLoadIdentity(); vgTranslate(w * 0.5f, h * 0.5f); vgRotate(rotateN); vgTranslate(-w * 0.5f, -h * 0.5f); vgScale(scale, scale); vgTranslate(-tigerMinX, -tigerMinY + 0.5f * (h / scale - (tigerMaxY - tigerMinY))); PS_render(tiger); assert(vgGetError() == VG_NO_ERROR); renderWidth = w; renderHeight = h; } }
void display(float interval) { VGfloat cc[] = {0,0,0,1}; vgSetfv(VG_CLEAR_COLOR, 4, cc); vgClear(0,0,testWidth(),testHeight()); vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER); vgLoadIdentity(); vgTranslate(tx, ty); vgScale(sx, sy); vgRotate(a); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); vgLoadIdentity(); vgSetPaint(patternFill, VG_FILL_PATH); /*vgDrawPath(p, VG_FILL_PATH);*/ vgDrawImage(backImage); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(tx, ty); vgScale(sx, sy); vgRotate(a); vgSetPaint(blackFill, VG_FILL_PATH | VG_STROKE_PATH); vgDrawPath(org, VG_FILL_PATH); }
static bool rpi_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { rpi_t *rpi = (rpi_t*)data; if (width != rpi->mRenderWidth || height != rpi->mRenderHeight) { rpi->mRenderWidth = width; rpi->mRenderHeight = height; rpi_calculate_quad(rpi); vguComputeWarpQuadToQuad( rpi->x1, rpi->y1, rpi->x2, rpi->y1, rpi->x2, rpi->y2, rpi->x1, rpi->y2, // needs to be flipped, Khronos loves their bottom-left origin 0, height, width, height, width, 0, 0, 0, rpi->mTransformMatrix); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(rpi->mTransformMatrix); } vgSeti(VG_SCISSORING, VG_FALSE); vgClear(0, 0, rpi->mScreenWidth, rpi->mScreenHeight); vgSeti(VG_SCISSORING, VG_TRUE); vgImageSubData(rpi->mImage, frame, pitch, rpi->mTexType, 0, 0, width, height); vgDrawImage(rpi->mImage); #ifdef HAVE_FREETYPE if (msg && rpi->mFontsOn) rpi_draw_message(rpi, msg); #else (void)msg; #endif eglSwapBuffers(rpi->mDisplay, rpi->mSurface); return true; }
void display(float interval) { VGfloat cc[] = {0,0,0,1}; vgSetfv(VG_CLEAR_COLOR, 4, cc); vgClear(0,0,testWidth(),testHeight()); vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER); vgLoadIdentity(); vgTranslate(tx, ty); vgRotate(ang); vgScale(sx, sy); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgSetPaint(radialFill, VG_FILL_PATH); vgDrawPath(p, VG_FILL_PATH); vgTranslate(tx, ty); vgRotate(ang); vgScale(sx, sy); vgSetPaint(blackFill, VG_FILL_PATH | VG_STROKE_PATH); vgDrawPath(radius, VG_STROKE_PATH); vgDrawPath(center, VG_STROKE_PATH); vgDrawPath(focus, VG_FILL_PATH); }
//Display functions void display(float interval) { int i; const VGfloat *style; VGfloat clearColor[] = {1,1,1,1}; if (animate) { ang += interval * 360 * 0.1f; if (ang > 360) ang -= 360; } vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vgClear(0,0,testWidth(),testHeight()); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(testWidth()/2 + tx,testHeight()/2 + ty); vgScale(sx, sy); vgRotate(ang); for (i=0; i<pathCount; ++i) { style = styleArrays[i]; vgSetParameterfv(tigerStroke, VG_PAINT_COLOR, 4, &style[0]); vgSetParameterfv(tigerFill, VG_PAINT_COLOR, 4, &style[4]); vgSetf(VG_STROKE_LINE_WIDTH, style[8]); vgDrawPath(tigerPaths[i], (VGint)style[9]); // Bingo!!, Draw it!! } vgFlush(); }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool CImage::RenderScene() { //Clear the screen with the current clear colour. vgClear(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); //Change the matrix mode to VG_MATRIX_IMAGE_USER_TO_SURFACE so we can transform the images vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); //Set the current matrix to the identity vgLoadIdentity(); //Translate the image to the desired position vgTranslate(PVRShellGet(prefWidth) * 0.5f - (IMG_SIZE * 0.5f), PVRShellGet(prefHeight)* 0.5f + 5); //Draw the first image vgDrawImage(m_avgImage[0]); //Reset the current matrix... vgLoadIdentity(); //...Perform a translation to position the second image... vgTranslate(PVRShellGet(prefWidth) * 0.5f - (IMG_SIZE * 0.5f), PVRShellGet(prefHeight)* 0.5f - IMG_SIZE - 5); //...and draw vgDrawImage(m_avgImage[1]); m_PrintVG.DisplayDefaultTitle("Image", "", ePVRTPrint3DLogoIMG); return true; }
static void draw(void) { vgClear(0, 0, window_width(), window_height()); vgDrawPath(path, VG_FILL_PATH); vgFlush(); }
static void draw(void) { vgClear(0, 0, window_width(), window_height()); vgLoadIdentity(); vgTranslate(50, 21); vgDrawPath(path, VG_FILL_PATH); vgFlush(); }
// Start begins the picture, clearing a rectangular region with a specified color void Start(int width, int height) { VGfloat color[4] = { 1, 1, 1, 1 }; vgSetfv(VG_CLEAR_COLOR, 4, color); vgClear(0, 0, width, height); color[0] = 0, color[1] = 0, color[2] = 0; setfill(color); setstroke(color); StrokeWidth(0); vgLoadIdentity(); }
static bool vg_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg) { unsigned width, height; vg_t *vg = (vg_t*)data; static struct retro_perf_counter vg_fr = {0}; static struct retro_perf_counter vg_image = {0}; rarch_perf_init(&vg_fr, "vg_fr"); retro_perf_start(&vg_fr); video_driver_get_size(&width, &height); if (frame_width != vg->mRenderWidth || frame_height != vg->mRenderHeight || vg->should_resize) { vg->mRenderWidth = frame_width; vg->mRenderHeight = frame_height; vg_calculate_quad(vg); matrix_3x3_quad_to_quad( vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2, /* needs to be flipped, Khronos loves their bottom-left origin */ 0, frame_height, frame_width, frame_height, frame_width, 0, 0, 0, &vg->mTransformMatrix); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(vg->mTransformMatrix.data); vg->should_resize = false; } vgSeti(VG_SCISSORING, VG_FALSE); vgClear(0, 0, width, height); vgSeti(VG_SCISSORING, VG_TRUE); rarch_perf_init(&vg_image, "vg_image"); retro_perf_start(&vg_image); vg_copy_frame(vg, frame, frame_width, frame_height, pitch); retro_perf_stop(&vg_image); vgDrawImage(vg->mImage); #if 0 if (msg && vg->mFontsOn) vg_draw_message(vg, msg); #endif gfx_ctx_update_window_title(vg); retro_perf_stop(&vg_fr); gfx_ctx_swap_buffers(vg); return true; }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool COVGIntroducingSVG::RenderScene() { // Clear surface vgClear(0, 0, m_i32WindowWidth, m_i32WindowHeight); // Draw the SVGobject m_SVGObject.Draw(); // Display the title and logo. m_PrintVG.DisplayDefaultTitle("IntroducingSVG", "", ePVRTPrint3DSDKLogo); return true; }
// C function:: void vgClear(VGint x, VGint y, VGint width, VGint height); JNIEXPORT jint JNICALL Java_com_example_startvg_VG11_vgClear( JNIEnv* env, jobject obj, jint x, jint y, jint width, jint height){ vgClear( (VGint) x, (VGint) y, (VGint) width, (VGint) height ); }
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); } }
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); }
static void draw(void) { const VGint w = 48; VGImage img1, img2; VGint x, y; vgSetfv(VG_CLEAR_COLOR, 4, white); vgClear(0, 0, window_width(), window_height()); img1 = vgCreateImage(VG_sRGBA_8888, w, w, VG_IMAGE_QUALITY_NONANTIALIASED); img2 = vgCreateImage(VG_sRGBA_8888, w, w, VG_IMAGE_QUALITY_NONANTIALIASED); x = 5; y = (window_height() - w) / 2; /* test vgSetPixels */ vgSetfv(VG_CLEAR_COLOR, 4, red); vgClearImage(img1, 0, 0, w, w / 2); vgSetfv(VG_CLEAR_COLOR, 4, black); vgClearImage(img1, 0, w / 2, w, w / 2); vgSetPixels(x, y, img1, 0, 0, w, w); x += w + 5; /* test vgDrawImage */ vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(x, y); vgDrawImage(img1); /* test vgGetPixels */ vgGetPixels(img1, 0, 0, x, y, w, w); x += w + 5; vgSetPixels(x, y, img1, 0, 0, w, w); x += w + 5; /* test vgCopyImage */ vgCopyImage(img2, 0, 0, img1, 0, 0, w, w, VG_FALSE); vgSetPixels(x, y, img2, 0, 0, w, w); /* vgCopyPixels */ vgCopyPixels(x + w + 5, y, x, y, w, w); vgDestroyImage(img1); vgDestroyImage(img2); }
static void update_display(setting_render_internal_t* renderer) { // Render it out vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); vgSetfv(VG_CLEAR_COLOR, 4, renderer->definition.background_colour); vgClear(renderer->definition.x, renderer->definition.y, renderer->definition.width, renderer->definition.height); vgSetiv(VG_SCISSOR_RECTS, 4, &renderer->definition.x); vgSeti(VG_SCISSORING, VG_TRUE); vgTranslate(renderer->definition.x, renderer->definition.y); vgSeti(VG_RENDERING_QUALITY, renderer->definition.text_quality); vgSetPaint(renderer->state.text_paint, VG_FILL_PATH); gfx_render_text(renderer->definition.text_x_offset, renderer->definition.text_y_offset, renderer->definition.text, &gfx_font_sans, renderer->definition.text_size); VGfloat text_width = gfx_text_width(renderer->definition.text, &gfx_font_sans, renderer->definition.text_size); const size_t buffer_size = 512; char setting_text_buffer[buffer_size]; setting_t* setting = renderer->definition.setting; switch(setting->type) { case SETTING_TYPE_INT: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_int(setting)); break; } case SETTING_TYPE_FLOAT: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_float(setting)); break; } case SETTING_TYPE_ENUM: { snprintf(setting_text_buffer, buffer_size - 1, renderer->definition.format, setting_get_value_enum(setting)); break; } default: snprintf(setting_text_buffer, buffer_size - 1, "ILLEGAL SETTING TYPE: %d", (int)setting->type); break; } setting_text_buffer[buffer_size - 1] = 0; gfx_render_text(text_width + 2 + renderer->definition.text_x_offset, renderer->definition.text_y_offset, setting_text_buffer, &gfx_font_sans, renderer->definition.text_size); vgSeti(VG_SCISSORING, VG_FALSE); }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool OVGMaskLayer::RenderScene() { //Clear the screen with the current clear colour vgClear(0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight); // Set the paint and draw the path vgSetPaint(m_avgColourPaint[1], VG_FILL_PATH); vgDrawPath(m_avgPath[0], VG_STROKE_PATH | VG_FILL_PATH); //Enable masking vgSeti(VG_MASKING, VG_TRUE); // Set paint vgSetPaint(m_avgColourPaint[2], VG_FILL_PATH); /* Modify the drawing surface's mask layer by loading it with the values from our first mask layer. See OVGMasking for more details on vgMask. */ vgMask(m_vgMaskLayer[0], VG_SET_MASK, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight); // Draw our path vgDrawPath(m_avgPath[1], VG_STROKE_PATH | VG_FILL_PATH); // Load the second mask layer into the mask vgMask(m_vgMaskLayer[1], VG_SET_MASK, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight); // Draw our path vgDrawPath(m_avgPath[2], VG_STROKE_PATH | VG_FILL_PATH); // Change paint for the triangle vgSetPaint(m_avgColourPaint[0], VG_FILL_PATH); // Merge our first mask layer into the mask (that currently contains the data from our second layer) vgMask(m_vgMaskLayer[0], VG_INTERSECT_MASK, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight); // Draw our path vgDrawPath(m_avgPath[3], VG_STROKE_PATH | VG_FILL_PATH); // Disable masking vgSeti(VG_MASKING, VG_FALSE); // Draw title and logo m_PrintVG.DisplayDefaultTitle("MaskLayer", "", ePVRTPrint3DSDKLogo); return true; }
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(); }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool CIntroducingPVRShell::RenderScene() { /* Clear the screen with clear colour. Clear is pixel based, so we need the dimensions of the screen. */ vgClear(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); // Set the current fill paint... vgSetPaint(m_vgFillPaint, VG_FILL_PATH); // ... and draw a filled triangle vgDrawPath(m_vgPath, VG_FILL_PATH); return true; }
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(); }
void display(float interval) { VGfloat cc[] = {0,0,0,1}; angle += interval * 0.4 * PI; if (angle > 2*PI) angle -= 2*PI; amount = (sin(angle) + 1) * 0.5f; createMorph(); vgSetfv(VG_CLEAR_COLOR, 4, cc); vgClear(0,0,testWidth(),testHeight()); vgLoadIdentity(); vgTranslate(testWidth()/2, testHeight()/2); vgScale(1.5, 1.5); vgDrawPath(iMorph, VG_FILL_PATH); }
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); }
void CTSmallWindowOpenVG::RenderL() { CTWindow::RenderL(); // Make sure that this egl status is active eglMakeCurrent(iDisplay, iSurface, iSurface, iContextVG); VGfloat clearColor[4] = {0.1f, 0.2f, 0.4f, 1.f}; VGfloat scaleFactor = Size().iWidth/200.f; if (Size().iHeight/200.f < scaleFactor) { scaleFactor = Size().iHeight/200.f; } iCurrentRotation = iTime; if (iCurrentRotation >= 360.f) { iCurrentRotation -= 360.f; } vgSetfv(VG_CLEAR_COLOR, 4, clearColor); vgClear(0, 0, Size().iWidth, Size().iHeight); vgLoadIdentity(); vgTranslate((float)Size().iHeight / 2, (float)Size().iHeight / 2); vgScale(scaleFactor, scaleFactor); vgRotate(iCurrentRotation); vgTranslate(-50.f, -50.f); vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER); vgSeti(VG_FILL_RULE, VG_EVEN_ODD); vgSetPaint(iFillPaint, VG_FILL_PATH); vgSetf(VG_STROKE_LINE_WIDTH, 10.f); vgSeti(VG_STROKE_CAP_STYLE, VG_CAP_ROUND); vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND); vgSetf(VG_STROKE_MITER_LIMIT, 0.f); vgSetPaint(iStrokePaint, VG_STROKE_PATH); vgDrawPath(iPath, VG_FILL_PATH | VG_STROKE_PATH); iTime++; eglSwapBuffers(iDisplay, iSurface); }
static bool vg_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { RARCH_PERFORMANCE_INIT(vg_fr); RARCH_PERFORMANCE_START(vg_fr); vg_t *vg = (vg_t*)data; if (width != vg->mRenderWidth || height != vg->mRenderHeight || vg->should_resize) { vg->mRenderWidth = width; vg->mRenderHeight = height; vg_calculate_quad(vg); matrix_3x3_quad_to_quad( vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2, // needs to be flipped, Khronos loves their bottom-left origin 0, height, width, height, width, 0, 0, 0, &vg->mTransformMatrix); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(vg->mTransformMatrix.data); vg->should_resize = false; } vgSeti(VG_SCISSORING, VG_FALSE); vgClear(0, 0, vg->mScreenWidth, vg->mScreenHeight); vgSeti(VG_SCISSORING, VG_TRUE); RARCH_PERFORMANCE_INIT(vg_image); RARCH_PERFORMANCE_START(vg_image); vg_copy_frame(vg, frame, width, height, pitch); RARCH_PERFORMANCE_STOP(vg_image); vgDrawImage(vg->mImage); #if 0 if (msg && vg->mFontsOn) vg_draw_message(vg, msg); #endif vg->driver->update_window_title(vg); RARCH_PERFORMANCE_STOP(vg_fr); vg->driver->swap_buffers(vg); return true; }
static void draw(EGLmanager *eglman) { VGfloat black[] = {0.f, 0.f, 0.f, 1.f}; // Render 3D scene by GL eglBindAPI(EGL_OPENGL_ES_API); eglMakeCurrent(eglman->dpy, eglman->pbuf_surface, eglman->pbuf_surface, eglman->es_ctx); // Modify GL texture source glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2); glClearColor(0.0, 1.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, TEXTURE_WIDTH/2, 0, 0, 0, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2); glClearColor(0.0, 0.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, TEXTURE_HEIGHT/2, 0, 0, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2, 0, 0, TEXTURE_WIDTH/2, TEXTURE_HEIGHT/2); // Make current to VG content eglBindAPI(EGL_OPENVG_API); eglMakeCurrent(eglman->dpy, eglman->win_surface, eglman->win_surface, eglman->vg_ctx); // Draw VGImage target vgSetfv(VG_CLEAR_COLOR, 4, black); vgClear(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); vgSeti(VG_BLEND_MODE, VG_BLEND_SRC); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); vgTranslate(WINDOW_WIDTH/2.0f, WINDOW_HEIGHT/2.0f); vgScale((VGfloat)WINDOW_WIDTH/(VGfloat)TEXTURE_WIDTH * 0.8f, (VGfloat)WINDOW_HEIGHT/(VGfloat)TEXTURE_HEIGHT * 0.8f); vgTranslate(-TEXTURE_WIDTH/2.0f, -TEXTURE_HEIGHT/2.0f); vgDrawImage(eglman->vg_image); // Swap buffer eglSwapBuffers(eglman->dpy, eglman->win_surface); return; }
void display(float interval) { int x,y,p; VGfloat white[] = {1,1,1,1}; vgSetfv(VG_CLEAR_COLOR, 4, white); vgClear(0, 0, testWidth(), testHeight()); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); for (y=0, p=0; y<3; ++y) { for (x=0; x<3; ++x, ++p) { if (p > NUM_PRIMITIVES) break; vgLoadIdentity(); vgTranslate(100 + x*150, 100 + y*150); vgDrawPath(primitives[p], VG_STROKE_PATH); } } }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool CChildImage::RenderScene() { //Clear the screen with the current clear color. vgClear(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); //Change the matrix mode to VG_MATRIX_IMAGE_USER_TO_SURFACE so we can transform the images vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); //Set the current matrix to the identiy vgLoadIdentity(); //Translate the image to the desired position vgTranslate(PVRShellGet(prefWidth) * 0.5f - (IMG_SIZE * 0.5f), PVRShellGet(prefHeight)* 0.5f + 5.0f); //Draw the main image vgDrawImage(m_vgImage); //Reset the current matrix... vgLoadIdentity(); //...Perform a translation to position the first child image... int i32Height = vgGetParameteri(m_avgChildImages[0], VG_IMAGE_HEIGHT); vgTranslate(PVRShellGet(prefWidth) * 0.5f - (vgGetParameteri(m_avgChildImages[1], VG_IMAGE_WIDTH) * 0.5f), PVRShellGet(prefHeight)* 0.5f - i32Height - 5.0f); //...and draw vgDrawImage(m_avgChildImages[0]); //Reset the current matrix... vgLoadIdentity(); //...Perform a translation to position the second child image... i32Height = vgGetParameteri(m_avgChildImages[0], VG_IMAGE_HEIGHT) + vgGetParameteri(m_avgChildImages[1], VG_IMAGE_HEIGHT); vgTranslate(PVRShellGet(prefWidth) * 0.5f - (vgGetParameteri(m_avgChildImages[1], VG_IMAGE_WIDTH) * 0.5f), PVRShellGet(prefHeight)* 0.5f - i32Height - 10.0f); //...and draw vgDrawImage(m_avgChildImages[1]); m_PrintVG.DisplayDefaultTitle("ChildImage", "", ePVRTPrint3DLogoIMG); return true; }
/******************************************************************************* * Function Name : RenderScene * Returns : true if no error occured * Description : Main rendering loop function of the program. The shell will * call this function every frame. *******************************************************************************/ bool CTransforms::RenderScene() { m_ui32AbsTime = PVRShellGetTime(); // Clear the screen with clear color. vgClear(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); // Set fill paint vgSetPaint(m_vgPaint, VG_FILL_PATH); unsigned int ui32TimeSinceStart = PVRShellGetTime() - m_ui32StartTime; // toggle segment type every 3 seconds int ui32ActiveTransform = (ui32TimeSinceStart % (3000 * 7)) / 3000; switch(ui32ActiveTransform) { case 0: DoTranslate(); break; case 1: DoScaleCentered(); break; case 2: DoScaleOrigin(); break; case 3: DoRotateCentered(); break; case 4: DoRotateOrigin(); break; case 5: DoShearCentered(); break; case 6: DoShearOrigin(); break; } // Draw user interface static char* apszTransforms[] = { "Translation", "Scaling (centered on object)", "Scaling (from origin)", "Rotate (centered on object)", "Rotate (around origin)", "Shear (centered on object)", "Shear (from origin)", }; m_PrintVG.DisplayDefaultTitle("Transforms", apszTransforms[ui32ActiveTransform], ePVRTPrint3DLogoIMG); return true; }
ImageBufferData::ImageBufferData(const IntSize& size, int colorSpace, bool& success) : m_surface(0) { ASSERT(size.width() > 0); ASSERT(size.height() > 0); success = false; switch ((ImageColorSpace) colorSpace) { case DeviceRGB: m_format = VG_sARGB_8888; break; case GrayScale: m_format = VG_sL_8; break; case LinearRGB: m_format = VG_lARGB_8888; break; } #if PLATFORM(EGL) EGLint errorCode; m_surface = new SurfaceOpenVG(size, EGLDisplayOpenVG::current()->display(), 0, &errorCode); #else ASSERT_NOT_REACHED(); return; #endif if (!m_surface->isValid()) { delete m_surface; m_surface = 0; return; } m_surface->makeCurrent(); // Clear the ImageBuffer from whatever color was set before to transparent. const VGfloat transparent[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; vgSeti(VG_SCISSORING, VG_FALSE); vgSetfv(VG_CLEAR_COLOR, 4, transparent); vgClear(0, 0, size.width(), size.height()); success = true; }
int main(int argc, char **argv) { float rotate, color[4] = {0.0, 0.33, 0.33, 1.0}; VGPath path; VGPaint paintStroke; VGubyte pathSegments[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_CLOSE_PATH}; float pathData[] = {200.0, 300.0, 100.0, 100.0}; float incData[] = { 1.0, 2.0, -2.5, -0.5}; EGLDisplayState *eglState = eglOpenDisplay(0 /* min win dimension */, 8 /* min color component size */, 8 /* min alpha size */, 0 /* min Z depth */, EGL_OPENVG_BIT /* render type */); path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0, 0.0, 0, 0, VG_PATH_CAPABILITY_APPEND_TO | VG_PATH_CAPABILITY_MODIFY); vgAppendPathData(path, 3, pathSegments, pathData); paintStroke = vgCreatePaint(); vgSetColor(paintStroke, 0x00FF00FF); vgSetParameteri(paintStroke, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); vgSetPaint(paintStroke, VG_STROKE_PATH | VG_FILL_PATH); vgSetf(VG_STROKE_LINE_WIDTH, 5.0); vgLoadIdentity(); for (rotate = 0.0; rotate < 1000.0; rotate++) { color[0] = rotate / 1000.0; vgSetfv(VG_CLEAR_COLOR, 4, color); vgClear(0, 0, eglState->win.width, eglState->win.height); bounce(2, pathData, incData, eglState->win.width, eglState->win.height); vgModifyPathCoords(path, 0, 3, pathData); vgDrawPath(path, VG_STROKE_PATH); eglUpdateDisplay(eglState); } eglCloseDisplay(eglState); }