#ifndef _hlslShader_h_
#define _hlslShader_h_
#include <maya/MPxCommand.h>
#include <maya/MPxHardwareShader.h>
#include <maya/MTypeId.h>
#include <maya/MStringArray.h>
#include <maya/MVaryingParameter.h>
#include <maya/MUniformParameter.h>
#include <maya/MUniformParameterList.h>
#include <maya/MRenderProfile.h>
#include <maya/MHwrCallback.h>
#include <maya/MModelMessage.h>
#include <d3d9.h>
#include <d3dx9.h>
class hlslShader;
{
public:
typedef enum
{
kInvalid,
kReset,
kValid
} hlslDeviceState;
inline hlslDeviceManager( hlslShader& shader) : fShader( shader), fState( kValid) {
addCallback(
this); }
inline hlslDeviceState deviceState() { return fState; }
void resetShader();
private:
void operator=( const hlslDeviceManager&) {};
protected:
hlslDeviceState fState;
hlslShader& fShader;
};
{
public:
friend class hlslDeviceManager;
hlslShader();
virtual ~hlslShader();
static void* creator();
static void initializeNodeAttrs();
floatRegion region,
int &imageWidth,
int &imageHeight );
const MString& imageName, floatRegion region,
int &imageWidth,
int &imageHeight );
public:
void release();
protected:
bool passHasTranparency( D3DXHANDLE passHandle );
hlslDeviceManager fDeviceManager;
void releaseVertexDeclaration();
LPD3DXEFFECT fD3DEffect;
D3DXHANDLE fD3DTechnique;
D3DXEFFECT_DESC fD3DEffectDesc;
D3DXTECHNIQUE_DESC fD3DTechniqueDesc;
IDirect3DVertexDeclaration9** fD3DVertexDeclaration;
bool fTechniqueHasBlending;
void setupUniform( D3DXHANDLE d3dParameter,
const MString& prefix);
bool GetAnnotation( D3DXHANDLE parameter, const char* name, LPCSTR& value);
bool GetBOOLAnnotation( D3DXHANDLE parameter, const char* name, BOOL& value);
bool GetAnnotation( D3DXHANDLE parameter, const char* name, float& value);
bool GetAnnotation( D3DXHANDLE parameter, const char* name, int& value);
void updateUIVisibilityFromAnnotation( D3DXHANDLE d3dParameter,
MUniformParameter& uniform);
void updateRangeFromAnnotation( D3DXHANDLE d3dParameter,
MUniformParameter& uniform);
inline hlslShader& me() { return *this; }
int fErrorCount;
void reportInternalError( const char* function, size_t errcode );
static void postDuplicateCB(void* data);
MCallbackId fPostDuplicateCallbackId;
};
{
public:
hlslShaderCmd();
virtual ~hlslShaderCmd();
static void* creator();
};
#endif