Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
static void vg_draw_message(vg_t *vg, const char *msg)
{
   settings_t *settings = config_get_ptr();

   if (!vg->mLastMsg || strcmp(vg->mLastMsg, msg))
      vg_render_message(vg, msg);

   vgSeti(VG_SCISSORING, VG_FALSE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);

   VGfloat origins[] = {
      vg->mScreenWidth  * settings->video.msg_pos_x - 2.0f,
      vg->mScreenHeight * settings->video.msg_pos_y - 2.0f,
   };

   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(vg->mPaintBg, VG_FILL_PATH);
   vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
   origins[0] += 2.0f;
   origins[1] += 2.0f;
   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(vg->mPaintFg, VG_FILL_PATH);
   vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);

   vgSeti(VG_SCISSORING, VG_TRUE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
}
Ejemplo n.º 4
0
void CNVGCSIcon::ConstructL(const TDesC8& aBuf)
    {
    iNVGIconData = CNVGIconData::NewL(aBuf.Length());
    iOpenVGHandles = COpenVGHandleStore::NewL();
    
    if (iPath == VG_INVALID_HANDLE)
        {
        iPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
                        VG_PATH_DATATYPE_S_32, 1.0f/65536.0f, 0.0f, 0, 0,
                        VG_PATH_CAPABILITY_APPEND_TO);
        iOpenVGHandles->AddPathDHL(iPath);
        }
    
    if (iFillPaint == VG_INVALID_HANDLE)
        {
        iFillPaint = vgCreatePaint();
        iOpenVGHandles->AddPaintDHL(iFillPaint);
        }
    vgSetPaint(iFillPaint, VG_FILL_PATH);
    
    if (iStrokePaint == VG_INVALID_HANDLE)
        {
        iStrokePaint = vgCreatePaint();
        iOpenVGHandles->AddPaintDHL(iStrokePaint);
        }
    vgSetPaint(iStrokePaint, VG_STROKE_PATH);
    }
Ejemplo n.º 5
0
void loadTiger()
{
  int i;
  VGPath temp;
  
  temp = testCreatePath();  
  tigerPaths = (VGPath*)malloc(pathCount * sizeof(VGPath));
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgTranslate(-100,100);
  vgScale(1,-1);
  
  for (i=0; i<pathCount; ++i) {
    
    vgClearPath(temp, VG_PATH_CAPABILITY_ALL);
    vgAppendPathData(temp, commandCounts[i],
                     commandArrays[i], dataArrays[i]);
    
    tigerPaths[i] = testCreatePath();
    vgTransformPath(tigerPaths[i], temp);
  }
  
  tigerStroke = vgCreatePaint();
  tigerFill = vgCreatePaint();
  vgSetPaint(tigerStroke, VG_STROKE_PATH);
  vgSetPaint(tigerFill, VG_FILL_PATH);
  vgLoadIdentity();
  vgDestroyPath(temp);
}
Ejemplo n.º 6
0
static void rpi_draw_message(rpi_t *rpi, const char *msg)
{
   if (!rpi->mLastMsg || strcmp(rpi->mLastMsg, msg))
      rpi_render_message(rpi, msg);

   vgSeti(VG_SCISSORING, VG_FALSE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);

   VGfloat origins[] = {
      rpi->mScreenWidth * g_settings.video.msg_pos_x - 2.0f,
      rpi->mScreenHeight * g_settings.video.msg_pos_y - 2.0f,
   };

   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(rpi->mPaintBg, VG_FILL_PATH);
   vgDrawGlyphs(rpi->mFont, rpi->mMsgLength, rpi->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
   origins[0] += 2.0f;
   origins[1] += 2.0f;
   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(rpi->mPaintFg, VG_FILL_PATH);
   vgDrawGlyphs(rpi->mFont, rpi->mMsgLength, rpi->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);

   vgSeti(VG_SCISSORING, VG_TRUE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
}
Ejemplo n.º 7
0
CNVGCSIcon::~CNVGCSIcon()
    {
    vgSetPaint(VG_INVALID_HANDLE, VG_FILL_PATH);
    vgSetPaint(VG_INVALID_HANDLE, VG_STROKE_PATH);

    delete iNVGIconData;
    delete iOpenVGHandles;
    }
Ejemplo n.º 8
0
/*******************************************************************************
 * 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;
}
Ejemplo n.º 9
0
// setfill sets the fill color
void setfill(VGfloat color[4]) {
	VGPaint fillPaint = vgCreatePaint();
	vgSetParameteri(fillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetParameterfv(fillPaint, VG_PAINT_COLOR, 4, color);
	vgSetPaint(fillPaint, VG_FILL_PATH);
	vgDestroyPaint(fillPaint);
}
Ejemplo n.º 10
0
void SubtitleRenderer::
draw_text(VGFont font, VGFont italic_font,
          const std::vector<SubtitleRenderer::InternalChar>& text,
          int x, int y,
          unsigned int lightness) {
  VGPaint paint = vgCreatePaint();
  assert(paint);

  vgSetColor(paint, (lightness<<8) | (lightness<<16) | (lightness<<24) | 0xFF);
  assert(!vgGetError());

  vgSetPaint(paint, VG_FILL_PATH);
  assert(!vgGetError());

  vgDestroyPaint(paint);
  assert(!vgGetError());

  vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
  assert(!vgGetError());

  VGfloat pos[] = {static_cast<VGfloat>(x), static_cast<VGfloat>(y)};

  vgSetfv(VG_GLYPH_ORIGIN, 2, pos);
  assert(!vgGetError());

  for (auto c = text.begin(); c != text.end(); ++c) {
    vgDrawGlyph(c->italic ? italic_font : font,
                c->codepoint,
                VG_FILL_PATH,
                VG_FALSE);
    assert(!vgGetError());
  }
}
Ejemplo n.º 11
0
  void render() {
    vgSetPaint(paint_, VG_FILL_PATH);
    assert(!vgGetError());

    vgDrawPath(path_, VG_FILL_PATH);
    assert(!vgGetError());
  }
Ejemplo n.º 12
0
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);
}
Ejemplo n.º 13
0
// setstroke sets the stroke color
void setstroke(VGfloat color[4]) {
	VGPaint strokePaint = vgCreatePaint();
	vgSetParameteri(strokePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, color);
	vgSetPaint(strokePaint, VG_STROKE_PATH);
	vgDestroyPaint(strokePaint);
}
Ejemplo n.º 14
0
// setstops sets color stops for gradients
void setstop(VGPaint paint, VGfloat * stops, int n) {
	VGboolean multmode = VG_FALSE;
	VGColorRampSpreadMode spreadmode = VG_COLOR_RAMP_SPREAD_REPEAT;
	vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spreadmode);
	vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, multmode);
	vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, 5 * n, stops);
	vgSetPaint(paint, VG_FILL_PATH);
}
Ejemplo n.º 15
0
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);
	}
Ejemplo n.º 16
0
static void setVGSolidColor(VGPaintMode paintMode, const Color& color)
{
    VGPaint paint = vgCreatePaint();
    vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
    vgSetColor(paint, colorToVGColor(color));
    vgSetPaint(paint, paintMode);
    vgDestroyPaint(paint);
    ASSERT_VG_NO_ERROR();
}
Ejemplo n.º 17
0
	// C function:: void vgSetPaint(VGPaint paint, VGbitfield paintModes);
	JNIEXPORT jint JNICALL
	Java_com_example_startvg_VG11_vgSetPaint(
		JNIEnv * env, jobject obj, 
	  long paint, int paintModes){
	  
			vgSetPaint(
			(VGPaint) paint, 
			(VGbitfield) paintModes
			);
	}
Ejemplo n.º 18
0
void OpenVG_SVGHandler::draw_recursive( group_t& group ) {

    // push the group matrix onto the stack
    pushTransform( group.transform );
    vgLoadMatrix( topTransform().m );

    for ( list<path_object_t>::iterator it = group.path_objects.begin(); it != group.path_objects.end(); it++ ) {
        path_object_t& po = *it;
        uint32_t draw_params = 0;
        if ( po.fill ) {
            vgSetPaint( po.fill, VG_FILL_PATH );
            draw_params |= VG_FILL_PATH;
        }

        if ( po.stroke ) {
            vgSetPaint( po.stroke, VG_STROKE_PATH );
            vgSetf( VG_STROKE_LINE_WIDTH, po.stroke_width );
            draw_params |= VG_STROKE_PATH;
        }

        if( draw_params == 0 ) {	// if no stroke or fill use the default black fill
            vgSetPaint( _blackBackFill, VG_FILL_PATH );
            draw_params |= VG_FILL_PATH;
        }

        // set the fill rule
        vgSeti( VG_FILL_RULE, po.fill_rule );
        // trasnform
        pushTransform( po.transform );
        vgLoadMatrix( topTransform().m );
        vgDrawPath( po.path, draw_params );
        popTransform();
        vgLoadMatrix( topTransform().m );
    }

    for ( list<group_t>::iterator it = group.children.begin(); it != group.children.end(); it++ ) {
        draw_recursive( *it );
    }

    popTransform();
    vgLoadMatrix( topTransform().m );
}
Ejemplo n.º 19
0
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);
}
Ejemplo n.º 20
0
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);
}
Ejemplo n.º 21
0
void PS_render(PS* ps)
{
	int i;
	assert(ps);
	vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);

	for(i=0;i<ps->m_numPaths;i++)
	{
		vgSeti(VG_FILL_RULE, ps->m_paths[i].m_fillRule);
		vgSetPaint(ps->m_paths[i].m_fillPaint, VG_FILL_PATH);

		if(ps->m_paths[i].m_paintMode & VG_STROKE_PATH)
		{
			vgSetf(VG_STROKE_LINE_WIDTH, ps->m_paths[i].m_strokeWidth);
			vgSeti(VG_STROKE_CAP_STYLE, ps->m_paths[i].m_capStyle);
			vgSeti(VG_STROKE_JOIN_STYLE, ps->m_paths[i].m_joinStyle);
			vgSetf(VG_STROKE_MITER_LIMIT, ps->m_paths[i].m_miterLimit);
			vgSetPaint(ps->m_paths[i].m_strokePaint, VG_STROKE_PATH);
		}

		vgDrawPath(ps->m_paths[i].m_path, ps->m_paths[i].m_paintMode);
	}
	assert(vgGetError() == VG_NO_ERROR);
}
Ejemplo n.º 22
0
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();
}
Ejemplo n.º 23
0
/*******************************************************************************
 * 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;
}
Ejemplo n.º 24
0
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);
}
Ejemplo n.º 25
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);
}
Ejemplo n.º 26
0
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);
}
Ejemplo n.º 27
0
/*******************************************************************************
 * 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;
}
Ejemplo n.º 28
0
Archivo: svg2.c Proyecto: dschmenk/SEGL
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);
}
Ejemplo n.º 29
0
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);
}
Ejemplo n.º 30
0
LRESULT OnPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

	VGPaint strokePaint = vgCreatePaint();
	vgSetPaint(strokePaint, VG_STROKE_PATH);

	VGfloat color[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
	vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, &color[0]);

	VGPath line = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
	vguLine(line, 20, 20, 130, 130);

	VGPath square = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, VG_PATH_CAPABILITY_ALL);
	vguRect(square, 10.0f, 10.0f, 130.0f, 50.0f);

	vgSetf(VG_STROKE_LINE_WIDTH, 7.0f);
	vgDrawPath(line, VG_STROKE_PATH);
	vgDrawPath(square, VG_STROKE_PATH);



	::ValidateRect(hWnd, NULL);
	return 0;
}