Пример #1
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 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;
}
Пример #2
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 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;
}
Пример #3
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;
}
Пример #4
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 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;
}
Пример #5
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;
}
Пример #6
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 CStrokeStyles::RenderScene()
{
	/*
		If the left or right arrow keys are pressed then change the
		CapStyle or JoinStyle or DashStyle depending on which one is
		selected.
	*/
	if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
	{
		switch(m_i32Selected)
		{
			case 0: m_i32CapStyle  = (m_i32CapStyle +  2) % 3; break;
			case 1: m_i32JoinStyle = (m_i32JoinStyle + 2) % 3; break;
			case 2: m_i32DashStyle = (m_i32DashStyle + 2) % 3; break;
		}
	}
	if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		switch(m_i32Selected)
		{
			case 0: m_i32CapStyle  = (m_i32CapStyle +  1) % 3; break;
			case 1: m_i32JoinStyle = (m_i32JoinStyle + 1) % 3; break;
			case 2: m_i32DashStyle = (m_i32DashStyle + 1) % 3; break;
		}
	}

	/*
		If the up or down arrow is pressed then change which item is
		selected.
	*/
	if(PVRShellIsKeyPressed(PVRShellKeyNameUP))
		m_i32Selected = (m_i32Selected + 2) % 3;

	if(PVRShellIsKeyPressed(PVRShellKeyNameDOWN))
		m_i32Selected = (m_i32Selected + 1) % 3;

	vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
	vgLoadIdentity();
	vgScale((float)PVRShellGet(prefWidth), (float)PVRShellGet(prefHeight));

	// Clear the screen with clear colour.
	vgClear(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight));

	// Draw the path with the stroke styles that we want
	vgSeti(VG_STROKE_CAP_STYLE  , VG_CAP_BUTT   + m_i32CapStyle);
	vgSeti(VG_STROKE_JOIN_STYLE , VG_JOIN_MITER + m_i32JoinStyle);
	vgSetf(VG_STROKE_MITER_LIMIT, m_fMiterLimit * PVRShellGet(prefHeight));

	if(m_i32DashStyle > 0)
	{
		vgSetf(VG_STROKE_DASH_PHASE, m_fDashPhase);

		static float s_afDashes[] = { 0.1f, 0.15f, 0.23f, 0.11f };
		vgSetfv(VG_STROKE_DASH_PATTERN, 4, s_afDashes);

		if(m_i32DashStyle == 2)
			m_fDashPhase += 0.01f;
	}
	else
	{
		vgSetfv(VG_STROKE_DASH_PATTERN, 0, NULL);
	}

	vgSetf(VG_STROKE_LINE_WIDTH, 20.0f / PVRShellGet(prefHeight));

	vgDrawPath(m_vgPath, VG_STROKE_PATH);

	/*	Draw the text.

		If one of the pieces of text is currently selected then it will be
		drawn in yellow.
	*/

	static char* apszCapStrings[]  = { "Butt", "Round", "Square" };
	static char* apszJoinStrings[] = { "Miter", "Round", "Bevel" };
	static char* apszDashStrings[] = { "None", "Pattern", "Moving" };

	m_PrintVG.DisplayDefaultTitle("StrokeStyles", "", ePVRTPrint3DLogoIMG);

	float fHeight = PVRShellGet(prefHeight) - 40.0f;

	/*
		Draw the Cap text.
	*/
	m_PrintVG.DrawString(2.0f , fHeight, 0.6f, "Cap:", (int) PVRTRGBA(204,204,204,255));
	m_PrintVG.DrawShadowString(65.0f, fHeight, 0.6f, apszCapStrings[m_i32CapStyle],
			m_i32Selected == 0 ? (int) PVRTRGBA(255,255,0,255) : (int) PVRTRGBA(255,255,255,255));

	/*
		Draw the Join text.
	*/
	fHeight -= 20.0f;
	m_PrintVG.DrawString(2.0f, fHeight, 0.6f, "Join:", (int) PVRTRGBA(204,204,204,255));
	m_PrintVG.DrawShadowString(65.0f, fHeight, 0.6f, apszJoinStrings[m_i32JoinStyle],
			m_i32Selected == 1 ? (int) PVRTRGBA(255,255,0,255) : (int) PVRTRGBA(255,255,255,255));

	/*
		Draw the Dash text.
	*/
	fHeight -= 20.0f;
	m_PrintVG.DrawString(2.0f,fHeight, 0.6f, "Dash:", (int) PVRTRGBA(204,204,204,255));
	m_PrintVG.DrawShadowString(65.0f, fHeight, 0.6f, apszDashStrings[m_i32DashStyle],
			m_i32Selected == 2 ? (int) PVRTRGBA(255,255,0,255) : (int) PVRTRGBA(255,255,255,255));

	return true;
}
Пример #7
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 OVGFont::RenderScene()
{
	// Clear the screen
	vgClear(0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Set the current fill paint...
	vgSetPaint(m_vgFontPaint, VG_FILL_PATH);

	/*
		Set the matrix mode to GLYPH_USER_TO_SURFACE as we want to
		translate and scale the glyphs.
	*/
	vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE);

	/*
		Set the string. The vgDrawGlyphs function used and
		explained in DrawLine excepts an array of unsiged
		ints for an array of glyph IDs which is why we are
		not defining a char array.

		An alternative to vgDrawGlyphs is vgDrawGlyph that
		can be used to display 1 glyph at a time.
	*/

	static VGuint str[] = {'T','e','x','t','y', '!',' '};

	/*
		The DrawLine function repeats the string until the
		line has covered the width of the screen.
	*/

	// Draw the string with the path based font at 4 different scales
	DrawLine(m_vgPathFont, 7, &str[0], m_ui32ScreenHeight * 0.75f, 2.0f);
	DrawLine(m_vgPathFont, 7, &str[0], m_ui32ScreenHeight * 0.65f, 1.0f);
	DrawLine(m_vgPathFont, 7, &str[0], m_ui32ScreenHeight * 0.60f, 0.5f);
	DrawLine(m_vgPathFont, 7, &str[0], m_ui32ScreenHeight * 0.55f, 0.25f);

	/*
		Set the blend mode for the image based glyphs
	*/
	vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);

	/*
		Set the image mode to DRAW_IMAGE_MULTIPLY so the image based glyphs
		are multiplied by the paint colour and alpha values.
	*/
	vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);

	// Draw the string with the image based font at 4 different scales.
	DrawLine(m_vgImageFont, 7, &str[0], m_ui32ScreenHeight * 0.35f, 2.0f);
	DrawLine(m_vgImageFont, 7, &str[0], m_ui32ScreenHeight * 0.25f, 1.0f);
	DrawLine(m_vgImageFont, 7, &str[0], m_ui32ScreenHeight * 0.20f, 0.5f);
	DrawLine(m_vgImageFont, 7, &str[0], m_ui32ScreenHeight * 0.15f, 0.25f);

	// Disable blending
	vgSeti(VG_BLEND_MODE, VG_BLEND_SRC);

	// Display the title and logo.
	m_PrintVG.DisplayDefaultTitle("Font", "", ePVRTPrint3DSDKLogo);

	return true;
}