Пример #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 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;
}