コード例 #1
1
/****************************************************************************
** InitView() is called by PVRShell each time a rendering variable is changed
** in the Shell menu (Z-Buffer On/Off, resolution change, buffering mode...)
** In this function one should initialise all variables that are dependant on
** general rendering variables (screen mode, 3D device, etc...)
****************************************************************************/
bool OVGFont::InitView()
{
	CPVRTPVGObject* pPVGObj;
	VGImage vgImage;
	VGImage vgChild;
	float fW,fH;
	PVRTVECTOR2 fGlyphOrigin, fEscapement;

	// Store the screen width and height
	m_ui32ScreenWidth  = PVRShellGet(prefWidth);
	m_ui32ScreenHeight = PVRShellGet(prefHeight);

	// Set the clear colour
	VGfloat afClearColour[] = { 0.6f, 0.8f, 1.0f, 1.0f };
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	// Initialise PrintVG for the logo and the title
	m_PrintVG.Initialize(m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Load the font path data from the pvg file
	pPVGObj = CPVRTPVGObject::FromFile(c_szPVGFile);

	if(pPVGObj == NULL)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to load Font.pvg.");
		return false;
	}

	if(pPVGObj->m_i32NumPaths != g_i32ImageCharNo)
	{
		PVRShellSet(prefExitMessage, "Error: Font.pvg doesn't contain the expected amount of characters.");

		delete pPVGObj;
		return false;
	}

	// Load the image based font data
	if(PVRTImageLoadFromPVR(c_szPVRFile, &vgImage) != PVR_SUCCESS)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to open mask.pvr.");
		return false;
	}

	/*
		Create two fonts. m_vgPathFont will purely contain glyphs represented by paths
		and m_vgImageFont by images. It is also reasonable to have a font that contains
		a mixture but we are keeping them seperate so they can be compared.
	*/

	m_vgImageFont = vgCreateFont(g_i32ImageCharNo);
	m_vgPathFont  = vgCreateFont(pPVGObj->m_i32NumPaths);

	// Add the glyphs to the fonts.
	for(int i = 0; i < g_i32ImageCharNo; ++i)
	{
		// Load glyph from path data

		/*
			Each path in the PVG file represents a glyph. First we need to acquire the origin
			of the glyph so we use vgPathBounds to achieve this as the origin described in
			g_CharDesc is for the image.
		*/
		vgPathBounds(pPVGObj->m_pPaths[i].m_path, &fGlyphOrigin.x, &fGlyphOrigin.y, &fW, &fH);

		// We offset the origin so glyphs like a 'y' are lower
		fGlyphOrigin.x += g_CharDesc[i].fOriginOffset.x;
		fGlyphOrigin.y += g_CharDesc[i].fOriginOffset.y;

		/*
			Add the glyph and assign it a unique ID. The characters we're loading have ASCII codes ranging from
			33 to 128 hence we're giving the glyphs IDs starting at 33. The glyph origin defines the coordinates
			in path space at which to start drawing the glyph and the escapement character is the offset to start
			drawing the next following character.
		*/
		vgSetGlyphToPath(m_vgPathFont, 33 + i, pPVGObj->m_pPaths[i].m_path, VG_TRUE, (VGfloat*) &fGlyphOrigin.x, (VGfloat*) &g_CharDesc[i].fEscapement.x);

		// Load glyph from image data

		/*
			Using a child image we 'cut' the glyph out of the main image (see the child image training course for
			an explanation).
		*/
		vgChild = vgChildImage(vgImage,  g_CharDesc[i].i32Origin[0], g_CharDesc[i].i32Origin[1], g_CharDesc[i].i32Width, g_CharDesc[i].i32Height);

		/*
			We then add the child image to the font. We use the origin offset value directly for the value as the glyph's
			origin is 0,0 within the child image.
		*/
		vgSetGlyphToImage(m_vgImageFont, 33 + i, vgChild, (VGfloat*) &g_CharDesc[i].fOriginOffset.x, (VGfloat*) &g_CharDesc[i].fEscapement.x);

		// Destroy the child image as we no longer need it.
		vgDestroyImage(vgChild);
	}

	// Destroy the image as it is no longer required
	vgDestroyImage(vgImage);

	// Destroy the PVG data as it too is no longer required
	delete pPVGObj;
	pPVGObj = 0;

	// Space

	/*
		Glyphs such as spaces that do not have a visual representation can be added to
		the fonts by passing VG_INVALID_HANDLE instead of a path or image handle.
	*/

	// Set the glyph origin and escapement for the space...
	fGlyphOrigin.x = 0.0f;
	fGlyphOrigin.y = 0.0f;
	// ... We're giving the space a width of 10.0f
	fEscapement.x = 10.0f;
	fEscapement.y = 0.0f;

	vgSetGlyphToImage(m_vgImageFont, 32, VG_INVALID_HANDLE, (VGfloat*) &fGlyphOrigin.x, (VGfloat*) &fEscapement.x);
	vgSetGlyphToPath(m_vgPathFont, 32, VG_INVALID_HANDLE, VG_TRUE, (VGfloat*) &fGlyphOrigin.x, (VGfloat*) &fEscapement.x);

	// Create font paint
	m_vgFontPaint = vgCreatePaint();

	vgSetParameteri(m_vgFontPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_vgFontPaint, PVRTRGBA(255,0,0,255));

	return true;
}
コード例 #2
0
ファイル: PVRTPrint3D.cpp プロジェクト: Sheph/gles-tests
/*!***************************************************************************
 @Function			DisplayDefaultTitle
 @Input				sTitle				Title to display
 @Input				sDescription		Description to display
 @Input				uDisplayLogo		1 = Display the logo
 @Return			PVR_SUCCESS or PVR_FAIL
 @Description		Creates a default title with predefined position and colours.
					It displays as well company logos when requested:
					0 = No logo
					1 = PowerVR logo
					2 = Img Tech logo
*****************************************************************************/
EPVRTError CPVRTPrint3D::DisplayDefaultTitle(const char * const pszTitle, const char * const pszDescription, const unsigned int uDisplayLogo)
{
	EPVRTError eRet = PVR_SUCCESS;

#if !defined (DISABLE_PRINT3D)

	// Display Title
	if(pszTitle)
	{
		if(Print3D(0.0f, 0.0f, 1.0f,  PVRTRGBA(255, 255, 0, 255), pszTitle) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}

	// Display Description
	if(pszDescription)
	{
        float fY = (float)(int((m_uiNextLineH / (480.0f/100.0f)) / m_fScreenScale[1]));
		if(Print3D(0.0f, fY, 0.8f,  PVRTRGBA(255, 255, 255, 255), pszDescription) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}

	m_uLogoToDisplay = uDisplayLogo;

#endif

	return eRet;
}
コード例 #3
0
ファイル: PVRTPrint3D.cpp プロジェクト: Arideas/isgl3d
/*!***************************************************************************
 @Function			DisplayDefaultTitle
 @Input				sTitle				Title to display
 @Input				sDescription		Description to display
 @Input				uDisplayLogo		1 = Display the logo
 @Return			PVR_SUCCESS or PVR_FAIL
 @Description		Creates a default title with predefined position and colours.
					It displays as well company logos when requested:
					0 = No logo
					1 = PowerVR logo
					2 = Img Tech logo
*****************************************************************************/
EPVRTError CPVRTPrint3D::DisplayDefaultTitle(const char * const pszTitle, const char * const pszDescription, const unsigned int uDisplayLogo)
{
	EPVRTError eRet = PVR_SUCCESS;

#if !defined (DISABLE_PRINT3D)

	// Display Title
	if(pszTitle)
	{
		if(Print3D(0.0f, 1.0f, 1.2f,  PVRTRGBA(255, 255, 0, 255), pszTitle) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}

	// Display Description
	if(pszDescription)
	{
		if(Print3D(0.0f, 8.0f, 0.9f,  PVRTRGBA(255, 255, 255, 255), pszDescription) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}

	m_uLogoToDisplay = uDisplayLogo;

#endif

	return eRet;
}
コード例 #4
0
/*******************************************************************************
 * Function Name  : InitView
 * Inputs		  : uWidth, uHeight
 * Returns        : true if no error occured
 * Description    : Code in InitView() will be called by the Shell upon a change
 *					in the rendering context.
 *					Used to initialise variables that are dependent on the rendering
 *					context (e.g. textures, vertex buffers, etc.)
 *******************************************************************************/
bool CTransforms::InitView()
{
	// Create paths
	CreatePaths();

	// Create paint
	m_vgPaint = vgCreatePaint();
	vgSetParameteri(m_vgPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_vgPaint, PVRTRGBA(255, 255, 170, 255));

	vgSeti(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
	vgSetf(VG_STROKE_LINE_WIDTH, 2.5f / PVRShellGet(prefHeight));

	/*
	The clear colour will be used whenever calling vgClear(). The colour is given
	as non-premultiplied sRGBA.
	*/
	VGfloat afClearColour[] = { 0.6f, 0.8f, 1.0f, 1.0f };
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	// Initialise custom text drawing
	m_PrintVG.Initialize(PVRShellGet(prefWidth), PVRShellGet(prefHeight));

	m_ui32StartTime = PVRShellGetTime();

	return true;
}
コード例 #5
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2Fog::RenderScene()
{
	// Clear the color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Keyboard input (cursor to change fog function)
	if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
	{
		m_eFogMode = EFogMode((m_eFogMode + eNumFogModes - 1) % eNumFogModes);
	}
	if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		m_eFogMode = EFogMode((m_eFogMode + 1) % eNumFogModes);
	}

	// Use the loaded shader program
	glUseProgram(m_ShaderProgram.uiId);

	// Bind texture
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, m_uiTexture);

	// Set uniforms
	glUniform1i(m_ShaderProgram.uiFogFuncLoc, m_eFogMode);

	// Rotate and translate the model matrix
	PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
	m_fAngleY += PVRT_PI / 90;
	mModel.preTranslate(0, 0, 500 * cos(m_fPositionZ) - 450);	
	m_fPositionZ += (2*PVRT_PI)*0.0008f;

	// Feed Projection and Model View matrices to the shaders
	PVRTMat4 mModelView = m_mView * mModel;
	PVRTMat4 mMVP = m_mProjection * mModelView;

	glUniformMatrix4fv(m_ShaderProgram.uiModelViewLoc, 1, GL_FALSE, mModelView.ptr());
	glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());

	// Pass the light direction transformed with the inverse of the ModelView matrix
	// This saves the transformation of the normals per vertex. A simple dot3 between this direction
	// and the un-transformed normal will allow proper smooth shading.
	PVRTVec3 vMsLightDir = (PVRTMat3(mModel).inverse() * PVRTVec3(1, 1, 1)).normalized();
	glUniform3fv(m_ShaderProgram.uiLightDirLoc, 1, vMsLightDir.ptr());

	/*
		Now that the model-view matrix is set and the materials ready,
		call another function to actually draw the mesh.
	*/
	DrawMesh(0);

	// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
	m_Print3D.DisplayDefaultTitle("Fog", "", ePVRTPrint3DLogoIMG);
	m_Print3D.Print3D(0.3f, 7.5f, 0.75f, PVRTRGBA(255,255,255,255), "Fog Mode: %s", g_FogFunctionList[m_eFogMode]);
	m_Print3D.Flush();

	return true;
}
コード例 #6
0
/****************************************************************************
** InitView() is called by PVRShell each time a rendering variable is changed
** in the Shell menu (Z-Buffer On/Off, resolution change, buffering mode...)
** In this function one should initialise all variables that are dependant on
** general rendering variables (screen mode, 3D device, etc...)
****************************************************************************/
bool CIntroducingPVRShell::InitView()
{
	/*
	Initially, the OpenVG coordinate system is based on the output resolution.
	To get a device independent coordinate system, we need to apply a
	transformation. Scaling by the output resolution means that coordinates
	between (0, 0) and (1, 1) will be visible on screen.

	It should be noted, however, that different aspect ratios usually require
	special attention regarding the layout of elements on screen.
	*/
	vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
	vgLoadIdentity();
	vgScale((float)PVRShellGet(prefWidth), (float)PVRShellGet(prefHeight));

	/*
	Drawing shapes with OpenVG requires a path which represents a series of
	line and curve segments describing the outline of the shape. The shape
	does not need to be closed, but for now we will start with a simple
	triangle.
	First we create a path object, then we append segment and point data.
	*/
	m_vgPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F,
							1.0f, 0.0f, 4, 3, (unsigned int)VG_PATH_CAPABILITY_ALL);

	VGubyte aui8PathSegments[4] = {
		VG_MOVE_TO_ABS,
		VG_LINE_TO_ABS,
		VG_LINE_TO_ABS,
		VG_CLOSE_PATH,
	};
	VGfloat afPoints[6] = {
			0.3f, 0.3f,
			0.7f, 0.3f,
			0.5f, 0.7f,
	};
	vgAppendPathData(m_vgPath, 4, aui8PathSegments, afPoints);

	/*
	To fill a shape, we need a paint that describes how to fill it: a gradient,
	pattern, or single colour. Here we choose a simple opaque red.
	*/
	m_vgFillPaint = vgCreatePaint();
	vgSetParameteri(m_vgFillPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_vgFillPaint, PVRTRGBA(255,255,170,255));

	/*
	The clear colour will be used whenever calling vgClear(). The colour is given
	as non-premultiplied sRGBA.
	*/
	VGfloat afClearColour[] = { 0.6f, 0.8f, 1.0f, 1.0f };
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	return true;
}
コード例 #7
0
/*!***************************************************************************
 @fn       			DisplayDefaultTitle
 @param[in]			sTitle				Title to display
 @param[in]			sDescription		Description to display
 @param[in]			uDisplayLogo		1 = Display the logo
 @return			PVR_SUCCESS or PVR_FAIL
 @brief      		Creates a default title with predefined position and colours.
					It displays as well company logos when requested:
					0 = No logo
					1 = PowerVR logo
					2 = Img Tech logo
*****************************************************************************/
EPVRTError CPVRTPrint3D::DisplayDefaultTitle(const char * const pszTitle, const char * const pszDescription, const unsigned int uDisplayLogo)
{
	EPVRTError eRet = PVR_SUCCESS;

#if !defined (DISABLE_PRINT3D)

	// Display Title
	if(pszTitle)
	{
		if(Print3D(0.0f, -1.0f, 1.0f,  PVRTRGBA(255, 255, 255, 255), pszTitle) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}
	
	float fYVal;
	if(m_bRotate)
		fYVal = m_fScreenScale[0] * 480.0f;
	else
		fYVal = m_fScreenScale[1] * 480.0f;

	// Display Description
	if(pszDescription)
	{
        float fY;
		float a = 320.0f/fYVal;
		fY = m_uiNextLineH / (480.0f/100.0f) * a;
		
		if(Print3D(0.0f, fY, 0.8f,  PVRTRGBA(255, 255, 255, 255), pszDescription) != PVR_SUCCESS)
			eRet = PVR_FAIL;
	}

	m_uLogoToDisplay = uDisplayLogo;

#endif

	return eRet;
}
コード例 #8
0
ファイル: PVRTPrint3D.cpp プロジェクト: Arideas/isgl3d
/*!***************************************************************************
 @Function			CreateDefaultWindow
 @Input				fPosX					Position X for the new window
 @Input				fPosY					Position Y for the new window
 @Input				nXSize_LettersPerLine
 @Input				sTitle					Title of the window
 @Input				sBody					Body text of the window
 @Return			Window handle
 @Description		Creates a default window.
					If Title is NULL the main body will have just one line
					(for InfoWin).
*****************************************************************************/
unsigned int CPVRTPrint3D::CreateDefaultWindow(float fPosX, float fPosY, int nXSize_LettersPerLine, const char * const sTitle, const char * const sBody)
{
#if !defined (DISABLE_PRINT3D)

	unsigned int dwActualWin;
	unsigned int dwFlags = ePVRTPrint3D_ADJUST_SIZE_ALWAYS;
	unsigned int dwBodyTextColor, dwBodyBackgroundColor;

	// If no text is specified, return an error
	if(!sBody && !sTitle) return 0xFFFFFFFF;

	// If no title is specified, body text colours are different
	if(!sTitle)
	{
		dwBodyTextColor			= PVRTRGBA(0xFF, 0xFF, 0x30, 0xFF);
		dwBodyBackgroundColor	= PVRTRGBA(0x20, 0x20, 0xB0, 0xE0);
	}
	else
	{
		dwBodyTextColor			= PVRTRGBA(0xFF, 0xFF, 0xFF, 0xFF);
		dwBodyBackgroundColor	= PVRTRGBA(0x20, 0x30, 0xFF, 0xE0);
	}

	// Set window flags depending on title and body text were specified
	if(!sBody)		dwFlags |= ePVRTPrint3D_DEACTIVATE_WIN;
	if(!sTitle)		dwFlags |= ePVRTPrint3D_DEACTIVATE_TITLE;

	// Create window
	dwActualWin = InitWindow(nXSize_LettersPerLine, (sTitle==NULL) ? 1:50);

	// Set window properties
	SetWindow(dwActualWin, dwBodyBackgroundColor, dwBodyTextColor, 0.5f, fPosX, fPosY, 20.0f, 20.0f);

	// Set title
	if (sTitle)
		SetTitle(dwActualWin, PVRTRGBA(0x20, 0x20, 0xB0, 0xE0), 0.6f, PVRTRGBA(0xFF, 0xFF, 0x30, 0xFF), sTitle, PVRTRGBA(0xFF, 0xFF, 0x30, 0xFF), (char*)"");

	// Set window text
	if (sBody)
		SetText(dwActualWin, sBody);

	// Set window flags
	SetWindowFlags(dwActualWin, dwFlags);

	m_pWin[dwActualWin].bNeedUpdated = true;

	// Return window handle
	return dwActualWin;

#else
	return 0;
#endif
}
コード例 #9
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2AnisotropicLighting::RenderScene()
{
	// Clear the color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Keyboard input (cursor to change render mode)
	if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
	{
		m_eRenderMode = ERenderMode((m_eRenderMode + eNumRenderModes - 1) % eNumRenderModes);
	}
	if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		m_eRenderMode = ERenderMode((m_eRenderMode + 1) % eNumRenderModes);
	}

	// Rotate the model matrix
	PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
	m_fAngleY += 0.02f;

	// Calculate model view projection matrix
	PVRTMat4 mMVP = m_mViewProj * mModel;

	if (m_eRenderMode == eTexLookup)
	{
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, m_uiTexture);

		glUseProgram(m_FastShader.uiId);

		glUniformMatrix4fv(m_FastShader.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());

		/*
			The inverse of a rotation matrix is the transposed matrix
			Because of v * M = transpose(M) * v, this means:
			v * R == inverse(R) * v
			So we don't have to actually invert or transpose the matrix
			to transform back from world space to model space
		*/
		PVRTVec3 vMsEyePos = PVRTVec3(PVRTVec4(0, 0, 150, 1) * mModel);
		glUniform3fv(m_FastShader.uiMsEyePosLoc, 1, vMsEyePos.ptr());

		PVRTVec3 vMsLightDir = PVRTVec3(PVRTVec4(1, 1, 1, 1) * mModel).normalized();
		glUniform3fv(m_FastShader.uiMsLightDirLoc, 1, vMsLightDir.ptr());
	}
	else
	{
		glUseProgram(m_SlowShader.uiId);

		glUniformMatrix4fv(m_SlowShader.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());

		PVRTVec3 vMsEyeDir = PVRTVec3(PVRTVec4(0, 0, 150, 1) * mModel).normalized();
		glUniform3fv(m_SlowShader.uiMsEyeDirLoc, 1, vMsEyeDir.ptr());

		PVRTVec3 vMsLightDir = PVRTVec3(PVRTVec4(1, 1, 1, 1) * mModel).normalized();
		glUniform3fv(m_SlowShader.uiMsLightDirLoc, 1, vMsLightDir.ptr());
	}

	/*
		Now that the uniforms are set, call another function to actually draw the mesh.
	*/
	DrawMesh(0);

	// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
	m_Print3D.DisplayDefaultTitle("AnisotropicLighting", "", ePVRTPrint3DLogoIMG);
	m_Print3D.Print3D(0.3f, 7.5f, 0.75f, PVRTRGBA(255,255,255,255), c_aszRenderModes[m_eRenderMode]);
	m_Print3D.Flush();

	return true;
}
コード例 #10
0
/*******************************************************************************
 * Function Name  : InitView
 * Returns        : true if no error occured
 * Description    : Code in InitView() will be called by the Shell upon a change
 *					in the rendering context.
 *					Used to initialise variables that are dependent on the rendering
 *					context (e.g. textures, vertex buffers, etc.)
 *******************************************************************************/
bool CChildImage::InitView()
{
	//Create an image
	m_vgImage = vgCreateImage(VG_sRGBA_8888, IMG_SIZE, IMG_SIZE, VG_IMAGE_QUALITY_NONANTIALIASED);

	/*
	Populate the image from memory. A 32bit integer array (8bits per component)
	is created and populated.
	*/

	VGuint* pui32ImgData = new VGuint[IMG_SIZE*IMG_SIZE];

	for(int i = 0; i < IMG_SIZE; ++i)
	{
		for(int j = 0; j < IMG_SIZE; ++j)
		{
			// Fills the data with a fancy pattern
			if ( ((i*j)/8) % 2 )
				pui32ImgData[j*IMG_SIZE+i] = PVRTRGBA(255,255,0,255);
			else
				pui32ImgData[j*IMG_SIZE+i] = PVRTRGBA(255, 255 - (j * 2), 255 - i, 255 - (i * 2));
		}
	}

	/*
	The data in the array is then copied to the portion of the image starting at (0,0) through to (IMG_SIZE, IMG_SIZE), in
	this case that is the whole image. The coordinate system of the image places (0,0) at the bottom left-hand corner and
	(IMG_SIZE, IMG_SIZE) at the top right-hand corner.
	*/
	vgImageSubData(m_vgImage, pui32ImgData, sizeof(VGuint) * IMG_SIZE, VG_sRGBA_8888, 0, 0, IMG_SIZE, IMG_SIZE);

	// Delete the image data as it is now in OpenVG memory
	delete[] pui32ImgData;
	pui32ImgData = 0;

	//Create child images

	/*
	The first child is a child of m_vgImage and is made up of the region of m_vgImage from (0,0) to (IMG_SIZE / 2, IMG_SIZE / 2).
	Note: The area specified must be in the bounds of the parent.
	*/
	m_avgChildImages[0] = vgChildImage(m_vgImage,  0, 0, (VGint) (IMG_SIZE * 0.5), (VGint) (IMG_SIZE * 0.5));

	//The second child is a clone of the first child.

	//Get the dimensions of the first child..
	int i32ChildWidth = vgGetParameteri(m_avgChildImages[0], VG_IMAGE_WIDTH);
	int i32ChildHeight= vgGetParameteri(m_avgChildImages[0], VG_IMAGE_HEIGHT);

	//..and use them to define the region for creating the second child.
	m_avgChildImages[1] = vgChildImage(m_avgChildImages[0],  0, 0, i32ChildWidth,  i32ChildHeight);

	/*
	Clear a small portion of the bottom left-hand corner of m_avgChildImages[0] to red.
	This change will be seen in all relatives of m_avgChildImages[0], reason being they
	all share the same physical memory.

	Note:

	When clearing you specify the coordinate you want to start from and then how many pixels
	across and up you want to clear.
	*/
	VGfloat afClearColour[] = {1.0f, 0.0f, 0.0f, 1.0f};
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);
	vgClearImage(m_avgChildImages[0], 0, 0, 10, 10);

	//Set the clear colour for clearing the sceen
	afClearColour[0] = 0.6f;
	afClearColour[1] = 0.8f;
	afClearColour[2] = 1.0f;
	afClearColour[3] = 1.0f;

	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	m_PrintVG.Initialize(PVRShellGet(prefWidth), PVRShellGet(prefHeight));
	return true;
}
コード例 #11
0
/*******************************************************************************
 * Function Name  : InitView
 * Returns        : true if no error occured
 * Description    : Code in InitView() will be called by the Shell upon a change
 *					in the rendering context.
 *					Used to initialise variables that are dependent on the rendering
 *					context (e.g. textures, vertex buffers, etc.)
 *******************************************************************************/
bool OVGMaskLayer::InitView()
{
	// Get screen dimensions
	m_ui32ScreenWidth = PVRShellGet(prefWidth);
	m_ui32ScreenHeight= PVRShellGet(prefHeight);

	// Create the paths so we have something to look at.
	CreatePath();

	// Set the render quality so the stroke borders have some form of anti-aliasing
	vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER);

	// Create the paints that the paths will use
	m_avgColourPaint[0] = vgCreatePaint();
	vgSetParameteri(m_avgColourPaint[0], VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_avgColourPaint[0], PVRTRGBA(255,255,15,255));

	m_avgColourPaint[1] = vgCreatePaint();
	vgSetParameteri(m_avgColourPaint[1], VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_avgColourPaint[1], PVRTRGBA(255,50,0, 255));

	m_avgColourPaint[2] = vgCreatePaint();
	vgSetParameteri(m_avgColourPaint[2], VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
	vgSetColor(m_avgColourPaint[2], PVRTRGBA(50,250,15, 255));

	/*
		Load the images we're going to use to modify the mask layer.

		For more details on masking please refer to our OVGMasking training course
	*/

	// Create the VGImages.
	VGImage vgMaskImg, vgMaskImg2;

	// Using the PVR Tools we're going to load the mask data from a pvr file
	if(PVRTImageLoadFromPVR(c_szMask1File, &vgMaskImg) != PVR_SUCCESS)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to open mask1.pvr.");
		return false;
	}

	if(PVRTImageLoadFromPVR(c_szMask2File, &vgMaskImg2) != PVR_SUCCESS)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to open mask2.pvr.");
		return false;
	}

	/*
		Create a mask layer

		A VGMaskLayer is an object that allows you to store and manipulate the drawing surface's mask layer
	*/

	m_vgMaskLayer[0] = vgCreateMaskLayer(m_ui32ScreenWidth, m_ui32ScreenHeight);

	if(m_vgMaskLayer[0] == 0)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to create mask layer.");
		return false;
	}

	// Tile the first image in the drawing surface's masking layer
	TileImageInMask(vgMaskImg, VG_SET_MASK);

	/*
		Copy the contents of the drawing surface mask layer into our mask layer object

		vgCopyMask has the following parameters

		VGMaskLayer maskLayer, VGint dx, VGint dy, VGint sx, VGint sy, VGint width, VGint height)

		where

		masklayer is the masklayer to copy to
		dx, dy are the coordinates to start the copy at in the masklayer
		sx, sy are the coordinates to start the copy from in the source mask layer
		width and the height are the width and height of the region you wish to copy.

		In our case we're copying the full mask layer.
	*/

	vgCopyMask(m_vgMaskLayer[0], 0, 0, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Create the second mask layer
	m_vgMaskLayer[1] = vgCreateMaskLayer(m_ui32ScreenWidth, m_ui32ScreenHeight);

	if(m_vgMaskLayer[1] == 0)
	{
		PVRShellSet(prefExitMessage, "Error: Failed to create mask layer.");
		return false;
	}

	// Replace the contents of the mask by tiling the second image
	TileImageInMask(vgMaskImg2, VG_SET_MASK);

	// Copy the contents of the mask into the second mask layer
	vgCopyMask(m_vgMaskLayer[1], 0, 0, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Destroy the images as they are no longer needed
	vgDestroyImage(vgMaskImg);
	vgDestroyImage(vgMaskImg2);

	// Set the mask to ones
	vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, 0, 0, m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Init PrintVG
	m_PrintVG.Initialize(m_ui32ScreenWidth, m_ui32ScreenHeight);

	// Setup the transformation to scale the paths to fit the screen
	vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
	vgLoadIdentity();

	vgScale((float) m_ui32ScreenWidth, (float) m_ui32ScreenHeight);

	// Reduce the stroke size to compensate for our scaling
	vgSetf(VG_STROKE_LINE_WIDTH, 1.0f / m_ui32ScreenHeight);

	//Create and set the clear colour
	VGfloat afClearColour[] = { 0.6f, 0.8f, 1.0f, 1.0f };
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	return true;
}
コード例 #12
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;
}
コード例 #13
0
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2Refraction::RenderScene()
{
	// Keyboard input (cursor to change Reflection Flag)
	if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT) || PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		m_bSpecular = !m_bSpecular;
	}

	// Clear the color and depth buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	m_Background.Draw(m_uiTexture);

	// Enable backface culling and depth test
	glCullFace(GL_BACK);
	glFrontFace(GL_CCW);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);

	// Use shader program
	glUseProgram(m_ShaderProgram.uiId);

	// Bind textures
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, m_uiTexture);

	// Calculate the model matrix
	PVRTMat4 mRotX, mRotY, mModel;
	mRotX = PVRTMat4::RotationX(m_fAngleX);
	mRotY = PVRTMat4::RotationY(m_fAngleY);
	mModel = mRotX * mRotY;

	m_fAngleX += PVRT_PI / 111;
	m_fAngleY += PVRT_PI / 150;

	// Set model view projection matrix
	PVRTMat4 mModelView, mMVP;
	mModelView = m_mView * mModel;
	mMVP = m_mProjection * mModelView;

	glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());

	// Set light direction in model space
	PVRTVec4 vLightDirModel;
	vLightDirModel =  mModelView.inverse() * PVRTVec4(0.57735f, 0.57735f, 0.57735f, 0);

	glUniform3fv(m_ShaderProgram.auiLoc[eLightDirModel], 1, &vLightDirModel.x);

	// Set eye position in model space
	PVRTVec4 vEyePosModel;
	vEyePosModel = mModelView.inverse() * PVRTVec4(0, 0, 0, 1);

	glUniform3fv(m_ShaderProgram.auiLoc[eEyePosModel], 1, &vEyePosModel.x);

	// Set specular flag
	glUniform1i(m_ShaderProgram.auiLoc[eSpecular], m_bSpecular);

	// Set rotation flag
	glUniform1i(m_ShaderProgram.auiLoc[eRotate], m_bRotate);

	/*
		Now that the uniforms are set, call another function to actually draw the mesh.
	*/
	DrawMesh(0);

	// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
	m_Print3D.DisplayDefaultTitle("Refraction", "", ePVRTPrint3DLogoIMG);
	m_Print3D.Print3D(0.3f, 7.5f, 0.75f, PVRTRGBA(255,255,255,255), "Specular reflection: %s", (m_bSpecular) ? "on" : "off" );
	m_Print3D.Flush();
	return true;
}
コード例 #14
0
ファイル: OGLESFur.cpp プロジェクト: deepbansal15/Native_SDK
/*!****************************************************************************
 @Function		RenderScene
 @Return		bool		true if no error occured
 @Description	Main rendering loop function of the program. The shell will
				call this function every frame.
				eglSwapBuffers() will be performed by PVRShell automatically.
				PVRShell will also manage important OS events.
				Will also manage relevent OS events. The user has access to
				these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLESFur::RenderScene()
{
	// Reset the states that print3D changes
	glDisable(GL_CULL_FACE);
	glEnable(GL_FOG);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);

	//	User input
	bool bNewPage = false;

	if(PVRShellIsKeyPressed(PVRShellKeyNameSELECT))
		m_bPause = !m_bPause;

	if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
	{
		if(--m_i32WndPage < 0)
			m_i32WndPage = 5;

		bNewPage = true;
	}

	if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
	{
		if(++m_i32WndPage > 5)
			m_i32WndPage = 0;

		bNewPage = true;
	}

	if(bNewPage)
	{
		switch(m_i32WndPage)
		{
			case 0:
				m_bViewMode = false;
				m_i32FurShellNo = 7;
				break;
			case 1:
				m_bViewMode = true;
				m_i32FurShellNo = 0;
				break;
			case 2:
				m_bViewMode = true;
				m_i32FurShellNo = 1;
				break;
			case 3:
				m_bViewMode = true;
				m_i32FurShellNo = 2;
				break;
			case 4:
				m_bViewMode = true;
				m_i32FurShellNo = 7;
				break;
			case 5:
				m_bViewMode = false;
				m_i32FurShellNo = 7;
				break;
		}

		// Since the number of fur shells has changed, update them
		UpdateFurShells();
	}

	// Clear
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Animation
	DoAnimation();

	// View matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf(m_mView.f);

	// Enable the vertex and normal arrays
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	// Begin Scene
	if(!m_bViewMode)
		DrawEnvironment();

	// Draw the Duck
	DrawDuck();

	// Display Paused if the app is paused
	if(m_bPause)
		m_Print3D.Print3D(78.0f, 2.0f, 1.0f, PVRTRGBA(255,255,255,255), "Paused");

	// Disable the normals before our drawing of the print3D content
	glDisableClientState(GL_NORMAL_ARRAY);
	
	char szDesc[256];
	snprintf(szDesc, 256, "Displaying %d shells", m_i32FurShellNo);

	// Display the IMG logo
	m_Print3D.DisplayDefaultTitle("Fur", szDesc, ePVRTPrint3DSDKLogo);
	m_Print3D.Flush();
	return true;
}
コード例 #15
0
/*******************************************************************************
 * Function Name  : InitView
 * Returns        : true if no error occured
 * Description    : Code in InitView() will be called by the Shell upon a change
 *					in the rendering context.
 *					Used to initialise variables that are dependent on the rendering
 *					context (e.g. textures, vertex buffers, etc.)
 *******************************************************************************/
bool CImage::InitView()
{
	//Create a pair of images
	m_avgImage[0] = vgCreateImage(VG_sRGBA_8888, IMG_SIZE, IMG_SIZE, VG_IMAGE_QUALITY_NONANTIALIASED);
	m_avgImage[1] = vgCreateImage(VG_sRGBA_8888, IMG_SIZE, IMG_SIZE, VG_IMAGE_QUALITY_NONANTIALIASED);

	/*
	The first image will be populated from memory. A 32bit integer array (8bits per component)
	is created and populated.
	*/

	VGuint* pui32ImgData = new VGuint[IMG_SIZE * IMG_SIZE];

	for (int i = 0; i < IMG_SIZE; ++i)
	{
		for (int j = 0; j < IMG_SIZE; ++j)
		{
			// Fills the data with a fancy pattern
			if ( ((i*j)/8) % 2 )
				pui32ImgData[j*IMG_SIZE+i] = PVRTRGBA(255,255,0,255);
			else
				pui32ImgData[j*IMG_SIZE+i] = PVRTRGBA(255, 255 - (j * 2), 255 - i, 255 - (i * 2));
		}
	}

	/*
	The data in the array is then copied to the portion of the image starting at (0,0) through to (IMG_SIZE, IMG_SIZE), in
	this case that is the whole image. The coordinate system of the image places (0,0) at the bottom left-hand corner and
	(IMG_SIZE, IMG_SIZE) at the top right-hand corner.
	*/
	vgImageSubData(m_avgImage[0],pui32ImgData, sizeof(VGuint) * IMG_SIZE,VG_sRGBA_8888, 0, 0, IMG_SIZE, IMG_SIZE);

	// Delete the image data as it is now in OpenVG memory
	delete[] pui32ImgData;
	pui32ImgData = 0;

	/*
	The second image will initially be cleared to a single colour and then a part of the first image
	will be copied to it.
	*/

	//The colour to clear the image to is taken from the currently set VG_CLEAR_COLOR.
	VGfloat afClearColour[] = { 1.0f, 0.8f, 0.6f, 1.0f };
	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	//Clear the part of the image in the range (0,0) to (IMG_SIZE, IMG_SIZE), in this case that is the whole image.
	vgClearImage(m_avgImage[1], 0, 0, IMG_SIZE, IMG_SIZE);

	/*
	Copy the bottom left-hand corner ((0,0) to (IMG_SIZE / 2, IMG_SIZE / 2)) of the first image
	into the the second image starting at (IMG_SIZE / 4, IMG_SIZE / 4).
	*/
	int i32ImgSizeQuarter = (int) (IMG_SIZE * 0.25);

	vgCopyImage(m_avgImage[1], i32ImgSizeQuarter, i32ImgSizeQuarter,
				m_avgImage[0], 0,0,
				(VGint) (IMG_SIZE * 0.5), (VGint) (IMG_SIZE * 0.5),
				(VGboolean) false);

	//Set the clear colour for clearing the sceen
	afClearColour[0] = 0.6f;
	afClearColour[1] = 0.8f;
	afClearColour[2] = 1.0f;
	afClearColour[3] = 1.0f;

	vgSetfv(VG_CLEAR_COLOR, 4, afClearColour);

	m_PrintVG.Initialize(PVRShellGet(prefWidth), PVRShellGet(prefHeight));
	return true;
}
コード例 #16
0
ファイル: PVRTPrint3D.cpp プロジェクト: Arideas/isgl3d
/*!***************************************************************************
 @Function			InitWindow
 @Input				dwBufferSizeX		Buffer width
 @Input				dwBufferSizeY		Buffer height
 @Return			Window handle
 @Description		Allocate a buffer for a newly-created window and return its
					handle.
*****************************************************************************/
unsigned int CPVRTPrint3D::InitWindow(unsigned int dwBufferSizeX, unsigned int dwBufferSizeY)
{
#if !defined (DISABLE_PRINT3D)

	unsigned int		dwCurrentWin;

	/* Find the first available window */
	for (dwCurrentWin=1; dwCurrentWin<PVRTPRINT3D_MAX_WINDOWS; dwCurrentWin++)
	{
		/* If this window available? */
		if (!(m_pWin[dwCurrentWin].dwFlags & Print3D_WIN_EXIST))
		{
			/* Window available, exit loop */
			break;
		}
	}

	/* No more windows available? */
	if (dwCurrentWin == PVRTPRINT3D_MAX_WINDOWS)
	{
		_RPT0(_CRT_WARN,"\nPVRTPrint3DCreateWindow WARNING: PVRTPRINT3D_MAX_WINDOWS overflow.\n");
		return 0;
	}

	/* Set flags */
	m_pWin[dwCurrentWin].dwFlags = Print3D_WIN_TITLE  | Print3D_WIN_EXIST | Print3D_WIN_ACTIVE;

	/* Text Buffer */
	m_pWin[dwCurrentWin].dwBufferSizeX = dwBufferSizeX + 1;
	m_pWin[dwCurrentWin].dwBufferSizeY = dwBufferSizeY;
	m_pWin[dwCurrentWin].pTextBuffer  = (char *)calloc((dwBufferSizeX+2)*(dwBufferSizeY+2), sizeof(char));
	m_pWin[dwCurrentWin].bTitleTextL  = (char *)calloc(MAX_LETTERS, sizeof(char));
	m_pWin[dwCurrentWin].bTitleTextR  = (char *)calloc(MAX_LETTERS, sizeof(char));

	/* Memory allocation failed */
	if (!m_pWin[dwCurrentWin].pTextBuffer || !m_pWin[dwCurrentWin].bTitleTextL || !m_pWin[dwCurrentWin].bTitleTextR)
	{
		_RPT0(_CRT_WARN,"\nPVRTPrint3DCreateWindow : No memory enough for Text Buffer.\n");
		return 0;
	}

	/* Title */
	m_pWin[dwCurrentWin].fTitleFontSize	= 1.0f;
	m_pWin[dwCurrentWin].dwTitleFontColorL = PVRTRGBA(0xFF, 0xFF, 0x00, 0xFF);
	m_pWin[dwCurrentWin].dwTitleFontColorR = PVRTRGBA(0xFF, 0xFF, 0x00, 0xFF);
	m_pWin[dwCurrentWin].dwTitleBaseColor  = PVRTRGBA(0x30, 0x30, 0xFF, 0xFF); /* Dark Blue */

	/* Window */
	m_pWin[dwCurrentWin].fWinFontSize		= 0.5f;
	m_pWin[dwCurrentWin].dwWinFontColor	= PVRTRGBA(0xFF, 0xFF, 0xFF, 0xFF);
	m_pWin[dwCurrentWin].dwWinBaseColor	= PVRTRGBA(0x80, 0x80, 0xFF, 0xFF); /* Light Blue */
	m_pWin[dwCurrentWin].fWinPos[0]		= 0.0f;
	m_pWin[dwCurrentWin].fWinPos[1]		= 0.0f;
	m_pWin[dwCurrentWin].fWinSize[0]		= 20.0f;
	m_pWin[dwCurrentWin].fWinSize[1]		= 20.0f;
	m_pWin[dwCurrentWin].fZPos		        = 0.0f;
	m_pWin[dwCurrentWin].dwSort		    = 0;

	m_pWin[dwCurrentWin].bNeedUpdated = true;

	dwCurrentWin++;

	/* Returning the handle */
	return (dwCurrentWin-1);

#else
	return 0;
#endif
}