• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!****************************************************************************
2 
3  @file         PVRTMisc.h
4  @copyright    Copyright (c) Imagination Technologies Limited.
5  @brief        Miscellaneous functions used in 3D rendering.
6 
7 ******************************************************************************/
8 #ifndef _PVRTMISC_H_
9 #define _PVRTMISC_H_
10 
11 #include "PVRTMatrix.h"
12 #include "PVRTFixedPoint.h"
13 
14 /****************************************************************************
15 ** Functions
16 ****************************************************************************/
17 
18 /*!***************************************************************************
19  @brief      	Calculates coords of the intersection of a line and an
20 				infinite plane
21  @param[out]	pvIntersection	The point of intersection
22  @param[in]		pfPlane			Length 4 [A,B,C,D], values for plane equation
23  @param[in]		pv0				A point on the line
24  @param[in]		pv1				Another point on the line
25 *****************************************************************************/
26 void PVRTMiscCalculateIntersectionLinePlane(
27 	PVRTVECTOR3			* const pvIntersection,
28 	const VERTTYPE		pfPlane[4],
29 	const PVRTVECTOR3	* const pv0,
30 	const PVRTVECTOR3	* const pv1);
31 
32 /*!***************************************************************************
33  @brief      	Calculates world-space coords of a screen-filling
34 				representation of an infinite plane The resulting vertices run
35 				counter-clockwise around the screen, and can be simply drawn using
36 				non-indexed TRIANGLEFAN
37  @param[out]	pfVtx			Position of the first of 3 floats to receive
38 								the position of vertex 0; up to 5 vertex positions
39 								will be written (5 is the maximum number of vertices
40 								required to draw an infinite polygon clipped to screen
41 								and far clip plane).
42  @param[in]		nStride			Size of each vertex structure containing pfVtx
43  @param[in]		pvPlane			Length 4 [A,B,C,D], values for plane equation
44  @param[in]		pmViewProjInv	The inverse of the View Projection matrix
45  @param[in]		pFrom			Position of the camera
46  @param[in]		fFar			Far clipping distance
47  @return		Number of vertices in the polygon fan (Can be 0, 3, 4 or 5)
48 *****************************************************************************/
49 int PVRTMiscCalculateInfinitePlane(
50 	VERTTYPE			* const pfVtx,
51 	const int			nStride,
52 	const PVRTVECTOR4	* const pvPlane,
53 	const PVRTMATRIX 	* const pmViewProjInv,
54 	const PVRTVECTOR3	* const pFrom,
55 	const VERTTYPE		fFar);
56 
57 /*!***************************************************************************
58  @brief      	Creates the vertices and texture coordinates for a skybox
59  @param[in]		scale			Scale the skybox
60  @param[in]		adjustUV		Adjust or not UVs for PVRT compression
61  @param[in]		textureSize		Texture size in pixels
62  @param[out]	Vertices		Array of vertices
63  @param[out]	UVs				Array of UVs
64 *****************************************************************************/
65 void PVRTCreateSkybox(float scale, bool adjustUV, int textureSize, VERTTYPE** Vertices, VERTTYPE** UVs);
66 
67 /*!***************************************************************************
68  @brief      	Destroy the memory allocated for a skybox
69  @param[in]		Vertices	    Vertices array to destroy
70  @param[in]		UVs			    UVs array to destroy
71 *****************************************************************************/
72 void PVRTDestroySkybox(VERTTYPE* Vertices, VERTTYPE* UVs);
73 
74 /*!***************************************************************************
75  @brief      	When iTimesHigher is one, this function will return the closest
76 				power-of-two value above the base value.
77 				For every increment beyond one for the iTimesHigher value,
78 				the next highest power-of-two value will be calculated.
79  @param[in]		uiOriginalValue	    Base value
80  @param[in]		iTimesHigher		Multiplier
81 *****************************************************************************/
82 unsigned int PVRTGetPOTHigher(unsigned int uiOriginalValue, int iTimesHigher);
83 
84 /*!***************************************************************************
85  @brief      	When iTimesLower is one, this function will return the closest
86 				power-of-two value below the base value.
87 				For every increment beyond one for the iTimesLower value,
88 				the next lowest power-of-two value will be calculated. The lowest
89 				value that can be reached is 1.
90  @param[in]		uiOriginalValue	    Base value
91  @param[in]		iTimesLower		    Multiplier
92 *****************************************************************************/
93 unsigned int PVRTGetPOTLower(unsigned int uiOriginalValue, int iTimesLower);
94 
95 #endif /* _PVRTMISC_H_ */
96 
97 
98 /*****************************************************************************
99  End of file (PVRTMisc.h)
100 *****************************************************************************/
101 
102