00001 #ifndef __GXMISCD3DFUNCTIONS
00002 #define __GXMISCD3DFUNCTIONS
00003
00004
00005 #include "GXStandardDefines.h"
00006 #include "GXSquareGenerators.h"
00007
00008
00009 bool GXFillTextureWithSquare(CGXSquare<D3DXCOLOR>* pColorMap, IDirect3DTexture8* pTextureOut);
00010 bool GXFillSquareWithTexture(IDirect3DTexture8* pTextureIn, CGXSquare<D3DXCOLOR>* pColorMapOut);
00011
00012
00013
00014
00015 bool GXGetSWVPFromDevice(CGXDeviceContainer* pDevice);
00016
00017
00018 void GXGetColorAtPoint(D3DSURFACE_DESC* pDesc,
00019 D3DLOCKED_RECT* pRect,
00020 UINT uX,
00021 UINT uY,
00022 D3DXCOLOR* pOut);
00023
00024 void GXSetColorAtPoint(D3DSURFACE_DESC* pDesc,
00025 D3DLOCKED_RECT* pRect,
00026 UINT uX,
00027 UINT uY,
00028 D3DXCOLOR* pIn);
00029
00030
00031 void GXGetColorAtPoint(D3DSURFACE_DESC* pDesc,
00032 D3DLOCKED_RECT* pRect,
00033 D3DXVECTOR2* pCoords,
00034 D3DXCOLOR* pOut);
00035
00036 void GXSetColorAtPoint(D3DSURFACE_DESC* pDesc,
00037 D3DLOCKED_RECT* pRect,
00038 D3DXVECTOR2* pCoords,
00039 D3DXCOLOR* pIn);
00040
00041 bool GXWriteTextureToStream(IStream* pStream,
00042 IDirect3DTexture8* pTexture);
00043
00044 bool GXLoadTextureFromStream(IStream* pStream,
00045 CGXDeviceContainer* pDevice,
00046 IDirect3DTexture8** ppOut);
00047
00048
00049
00050 bool GXGenerateNormalMap(CGXDeviceContainer* pDevice,
00051 IDirect3DTexture8* pHeightMap,
00052 float fAmplitude,
00053 IDirect3DTexture8 **ppOut);
00054
00055
00056 DWORD GXCreateShaderFromFile(CGXDeviceContainer* pDevice, char* szShader);
00057 DWORD GXCreateShaderFromString(CGXDeviceContainer* pDevice, char* szShader);
00058 DWORD CGXLoadShader(ID3DXBuffer* pShader, ID3DXBuffer* pConstants, CGXDeviceContainer* pDevice);
00059
00060
00061
00062 bool GXSetupLinearFiltering(CGXDeviceContainer* pDevice);
00063
00064
00065
00066 struct SGXFloatRect
00067 {
00068 float fTop;
00069 float fBottom;
00070 float fLeft;
00071 float fRight;
00072 };
00073
00074
00075 bool GXAssembleTextures(CGXDeviceContainer* pDevice,
00076 SGXFloatRect* pCoordRemaps,
00077 char** ppInNames,
00078 UINT uNameCount,
00079 char* szOut,
00080 UINT uWidth,
00081 UINT uHeight);
00082
00083 bool GXPasteTextures(IDirect3DTexture8** ppTextures,
00084 UINT uTextureCount,
00085 SGXFloatRect* pCoordRemaps,
00086 IDirect3DTexture8* pOut);
00087
00088 bool GXCopyTexture(IDirect3DTexture8* pIn,
00089 SGXFloatRect* pInRect,
00090 IDirect3DTexture8* pOut,
00091 SGXFloatRect* pOutRect);
00092
00093 bool GXMakeNoiseTexture(IDirect3DTexture8* pTexture);
00094
00095
00096
00097
00098
00099 inline float GXLuminance(D3DXCOLOR* pColor)
00100 {
00101 assert(pColor!=NULL);
00102
00103 return (float) ((.3f*(pColor->r))+(.59f*(pColor->g))+(.11*(pColor->b)));
00104 }
00105
00106
00107 inline UINT GXGetTime()
00108 {
00109 return GetTickCount();
00110 }
00111
00112
00113
00114
00115 #endif