/*
Copyright (C) 2010, Heikki Salo
All rights reserved.
Distributed under the BSD license:
http://www.opensource.org/licenses/bsd-license.php
*/
#ifndef DP_DEVICESTATE_HPP
#define DP_DEVICESTATE_HPP
#include "stdafx.h"
#include "DPBase.hpp"
class DPDeviceState : DPBase {
public:
~DPDeviceState();
DPDeviceState();
DPDeviceState(ID3D11DepthStencilState*);
DPDeviceState(ID3D11BlendState*);
DPDeviceState(ID3D11RasterizerState*);
DPDeviceState(ID3D11SamplerState*);
void release();
DPDeviceState* combine(DPDeviceState&);
ID3D11DepthStencilState* getDepthStencilState() { return depthStencilState; }
ID3D11BlendState* getBlendState() { return blendState; }
ID3D11RasterizerState* getRasterizerState() { return rasterizerState; }
ID3D11SamplerState* getSamplerState() { return samplerState; }
void stealDepthStencilState(ID3D11DepthStencilState* state) {
assert(depthStencilState == 0);
depthStencilState = state;
}
void stealBlendState(ID3D11BlendState* state) {
assert(blendState == 0);
blendState = state;
}
void stealRasterizerState(ID3D11RasterizerState* state) {
assert(rasterizerState == 0);
rasterizerState = state;
}
bool hasDepthStencilState() { return depthStencilState != 0;}
bool hasBlendState() { return blendState != 0; }
bool hasRasterizerState() { return rasterizerState != 0; }
bool hasSamplerState() { return samplerState != 0; }
void setStencilRef(UINT sref) { stencilRef = sref; }
UINT getStencilRef() { return stencilRef; }
python::object getBlendFactorPy() { return python::make_tuple(blendFactor[0], blendFactor[1], blendFactor[2], blendFactor[3]); }
void setBlendFactorPy(python::object& blend) {
for (int i=0; i < 4; ++i)
blendFactor[i] = python::extract<float>(blend[i]);
}
float* getBlendFactor() { return blendFactor; }
void setBlendFactor(float blend[4]) {
for (int i=0; i < 4; ++i)
blendFactor[i] = blend[i];
}
UINT getSampleMask() { return sampleMask; }
void setSampleMask(UINT mask) { sampleMask = mask; }
private:
void zeroOut();
ID3D11DepthStencilState* depthStencilState;
UINT stencilRef;
ID3D11BlendState* blendState;
float blendFactor[4];
UINT sampleMask;
ID3D11RasterizerState* rasterizerState;
ID3D11SamplerState* samplerState;
};
#endif