//this function takes the index position of a cover, the linear interpolation too the next position and the index of the 
//texture it is displaying. The matrices and texture load are applied and then draw mesh is called to draw an individual cover.
void OGLES2Coverflow::DrawInPosition(int index, float queueLerp, int coverIndex)
{
	PVRTVec3 pos, posNext;
	float angle = 0.f;
	float backgroundPosition = -8.f;
	float backgroundAngle = (PVRT_PI/2.5);
	float distInQueue = 3.f;

	queueLerp += (float)index;
	coverIndex += index;

	if(coverIndex >= g_i32CoverNo)
	{
		coverIndex = coverIndex - g_i32CoverNo;
	}
	if(coverIndex < 0)
	{
		coverIndex = g_i32CoverNo;
	}

	pos = 0.f;

	pos.x = (queueLerp - eFront) * distInQueue;

	if(queueLerp > eFront - 1 && queueLerp < eFront + 1)
	{
		float lerpAbs = (float) fabs(queueLerp - eFront);
		pos.z = backgroundPosition * lerpAbs;
		angle = backgroundAngle * (queueLerp - eFront);
		pos.x += 2.0f * (queueLerp - eFront);
	}
	else
	{
		queueLerp - eFront < 0 ? angle = -backgroundAngle : angle = backgroundAngle;
		pos.z = backgroundPosition;
		if(queueLerp - eFront > 0)
			pos.x += 2.0;
		else
			pos.x -= 2.0;
	}

	PVRTMat4 mTrans, mRotation;
	PVRTMatrixTranslation(mTrans, pos.x, pos.y, pos.z);

	PVRTMatrixRotationY(mRotation, angle);
	
	PVRTMat4 mModelView, mMVP;
	mModelView = m_mView * mTrans * mRotation;
	mMVP = m_mProjection * mModelView;

	glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.f);
		
	glBindTexture(GL_TEXTURE_2D, g_Covers[coverIndex].ui32TexID);

	DrawMesh();
}
Example #2
0
//this funciton takes the index position of a cover, the linear interpolation too the next position and the index of the
//texture it is displaying. The matrices and texture load are applied and then draw mesh is called to draw an individual cover.
void OGLESCoverflow::DrawInPosition(int index, float queueLerp, int coverIndex)
{
	PVRTVec3 pos, posNext;
	float angle = 0.0f;
	float backgroundPosition = -8.0f;
	float backgroundAngle = (PVRT_PIf/2.5f);
	float distInQueue = 3.0f;

	queueLerp += (float)index;
	coverIndex += index;

	if(coverIndex >= g_i32CoverNo)
	{
		coverIndex = coverIndex - g_i32CoverNo;
	}
	if(coverIndex < 0)
	{
		coverIndex = g_i32CoverNo;
	}

	pos = 0.0f;

	pos.x = (queueLerp - eFront) * distInQueue;

	if(queueLerp > eFront - 1 && queueLerp < eFront + 1)
	{
		float lerpAbs = (float) fabs(queueLerp - eFront);
		pos.z = backgroundPosition * lerpAbs;
		angle = backgroundAngle * (queueLerp - eFront);
		pos.x += 2.0f * (queueLerp - eFront);
	}
	else
	{
		queueLerp - eFront < 0 ? angle = -backgroundAngle : angle = backgroundAngle;
		pos.z = backgroundPosition;
		if(queueLerp - eFront > 0)
			pos.x += 2.0f;
		else
			pos.x -= 2.0f;
	}

	PVRTMat4 mTrans, mRotation;
	PVRTMatrixTranslation(mTrans, pos.x, pos.y, pos.z);

	PVRTMatrixRotationY(mRotation, angle);

	glLoadMatrixf((mTrans * m_mView * mRotation).f);

	glClientActiveTexture(GL_TEXTURE0);
	glActiveTexture(GL_TEXTURE0);

	glBindTexture(GL_TEXTURE_2D, g_Covers[coverIndex].ui32TexID);

	DrawMesh();
}
/*!***************************************************************************
 @Function			APIDrawLogo
 @Description		
*****************************************************************************/
void CPVRTPrint3D::APIDrawLogo(const EPVRTPrint3DLogo uLogoToDisplay, const int ePos)
{
	GLuint	tex = 0;
	float fScale = 1.0f;
	if(m_ui32ScreenDim[1] >= 720)
		fScale = 2.0f;
	
	SPVRTPrint3DAPI::SInstanceData& Data = (m_pAPI->m_pInstanceData ? *m_pAPI->m_pInstanceData : SPVRTPrint3DAPI::s_InstanceData);

	switch(uLogoToDisplay)
	{
		case ePVRTPrint3DLogoIMG: 
			tex = Data.uTextureIMGLogo;
			break;
		case ePVRTPrint3DLogoPowerVR: 
			tex = Data.uTexturePowerVRLogo;
			break;
		default:
			return; // Logo not recognised
	}

	const float fLogoXSizeHalf = (128.0f / m_ui32ScreenDim[0]);
	const float fLogoYSizeHalf = (64.0f / m_ui32ScreenDim[1]);

	const float fLogoXShift = 0.035f / fScale;
	const float fLogoYShift = 0.035f / fScale;

	const float fLogoSizeXHalfShifted = fLogoXSizeHalf + fLogoXShift;
	const float fLogoSizeYHalfShifted = fLogoYSizeHalf + fLogoYShift;

	static float Vertices[] =
		{
			-fLogoXSizeHalf, fLogoYSizeHalf , 0.5f,
			-fLogoXSizeHalf, -fLogoYSizeHalf, 0.5f,
			fLogoXSizeHalf , fLogoYSizeHalf , 0.5f,
	 		fLogoXSizeHalf , -fLogoYSizeHalf, 0.5f
		};

	static float UVs[] = {
			0.0f, 0.0f,
			0.0f, 1.0f,
			1.0f, 0.0f,
	 		1.0f, 1.0f
		};

	float *pVertices = ( (float*)&Vertices );
	float *pUV       = ( (float*)&UVs );

	// Matrices
	PVRTMATRIX matModelView;
	PVRTMATRIX matTransform;
	PVRTMatrixIdentity(matModelView);

	PVRTMatrixScaling(matTransform, f2vt(fScale), f2vt(fScale), f2vt(1.0f));
	PVRTMatrixMultiply(matModelView, matModelView, matTransform);

	int nXPos = (ePos & eLeft) ? -1 : 1;
	int nYPos = (ePos & eTop) ? 1 : -1;
	PVRTMatrixTranslation(matTransform, nXPos - (fLogoSizeXHalfShifted * fScale * nXPos), nYPos - (fLogoSizeYHalfShifted * fScale * nYPos), 0.0f);
	PVRTMatrixMultiply(matModelView, matModelView, matTransform);

	if(m_bRotate)
	{
		PVRTMatrixRotationZ(matTransform, -90.0f*PVRT_PI/180.0f);
		PVRTMatrixMultiply(matModelView, matModelView, matTransform);
	}

	_ASSERT(Data.uProgramLogo != UNDEFINED_HANDLE);
	glUseProgram(Data.uProgramLogo);

	// Bind the model-view-projection to the shader
	glUniformMatrix4fv(Data.mvpLocationLogo, 1, GL_FALSE, matModelView.f);

	// Render states
	glActiveTexture(GL_TEXTURE0);

	_ASSERT(tex != UNDEFINED_HANDLE);
	glBindTexture(GL_TEXTURE_2D, tex);

	// Vertices
	glEnableVertexAttribArray(VERTEX_ARRAY);
	glEnableVertexAttribArray(UV_ARRAY);

	glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, (const void*)pVertices);
	glVertexAttribPointer(UV_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, (const void*)pUV);

	glDrawArrays(GL_TRIANGLE_STRIP,0,4);

	glDisableVertexAttribArray(VERTEX_ARRAY);
	glDisableVertexAttribArray(UV_ARRAY);
}