Graphics Reference
In-Depth Information
//Round to the nearest integer exponent
int nExp = log2_ceiling(maxComponent);
//Divide the components by the shared exponent
FLOAT fDivisor = (FLOAT)g_aPowsOfTwo[nExp + 128];
r/= fDivisor;
g/= fDivisor;
b/= fDivisor;
//Constrain the colour components
r = max(0, min(1, r));
g = max(0, min(1, g));
b = max(0, min(1, b));
//Store the shared exponent in the alpha channel
D3DCOLOUR* pDestColour = (D3DCOLOUR*)*ppDest;
*pDestColour = D3DCOLOUR_RGBA((BYTE)(r * 255), (BYTE)(g * 255), (BYTE)
(b * 255), nExp + 128);
*ppDest + = sizeof(D3DCOLOUR);
}
//—————————————————————————————————————————————————————————————————————————
inline VOID EncodeRGB16(D3DXFLOAT16* pSrc, BYTE** ppDest)
{
FLOAT r, g, b;
r = (FLOAT)*(pSrc + 0);
g = (FLOAT)*(pSrc + 1);
b = (FLOAT)*(pSrc + 2);
//Divide the components by the multiplier
r/= RGB16_MAX;
g/= RGB16_MAX;
b/= RGB16_MAX;
//Constrain the colour components
r = max(0, min(1, r));
g = max(0, min(1, g));
b = max(0, min(1, b));
//Store
USHORT* pDestColour = (USHORT*)*ppDest;
*pDestColour++ = (USHORT)(r * 65535);
*pDestColour++ = (USHORT)(g * 65535);
*pDestColour++ = (USHORT)(b * 65535);
*ppDest + = sizeof(UINT64);
}
HRESULT RetrieveTechHandles()
{
DWORD dwNumTechniques = sizeof(TECH_HANDLES)/sizeof(D3DXHANDLE);
CHAR strBuffer[MAX_PATH] = {0};
D3DXHANDLE* pHandle = (D3DXHANDLE*)&g_aTechHandles;
Search WWH ::




Custom Search