HRESULT SetRenderState( D3DRENDERSTATETYPE State, DWORD Value )

设置一个设备的渲染状态参数。

HRESULT SetRenderState( 

    D3DRENDERSTATETYPE State,

    DWORD Value

);

参数:

        State

            [in] Device state variable that is being modified. This parameter can be any member of the

            D3DRENDERSTATETYPE enumerated type.

        Value

            [in] New value for the device render state to be set. The meaning of this parameter is dependent on the value specified             

            for State. For example, if State were D3DRS_SHADEMODE, the second parameter would be one member of the

             D3DSHADEMODE enumerated type.

Return Value

        If the method succeeds, the return value is D3D_OK.

        D3DERR_INVALIDCALL is returned if one of the arguments is invalid.

下面是几个比较常用的:

//This is because we want to hide the back of our polygons

g_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);

   

//Turn off lighting because we are specifying that our vertices have colour

g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

//激活深度缓冲

m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); 

//Turn on lighting    打开灯光效果

m_pD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);

//Set ambient light level  设置环境光

m_pD3DDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(32, 32, 32));

//激活D3DRS_NORMALIZENORMALS渲染状态

m_pD3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

//Enable alpha blending so we can use transparent textures  使用透明纹理

m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

//Set how the texture should be blended (use alpha)        使用阿尔法

m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);

m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

D3DRENDERSTATETYPE 结构:

typedef enum _D3DRENDERSTATETYPE {

    D3DRS_ZENABLE = 7,

    D3DRS_FILLMODE = 8,

    D3DRS_SHADEMODE = 9,

    D3DRS_ZWRITEENABLE = 14,

    D3DRS_ALPHATESTENABLE = 15,

    D3DRS_LASTPIXEL = 16,

    D3DRS_SRCBLEND = 19,

    D3DRS_DESTBLEND = 20,

    D3DRS_CULLMODE = 22,

    D3DRS_ZFUNC = 23,

    D3DRS_ALPHAREF = 24,

    D3DRS_ALPHAFUNC = 25,

    D3DRS_DITHERENABLE = 26,

    D3DRS_ALPHABLENDENABLE = 27,

    D3DRS_FOGENABLE = 28,

    D3DRS_SPECULARENABLE = 29,

    D3DRS_FOGCOLOR = 34,

    D3DRS_FOGTABLEMODE = 35,

    D3DRS_FOGSTART = 36,

    D3DRS_FOGEND = 37,

    D3DRS_FOGDENSITY = 38,

    D3DRS_RANGEFOGENABLE = 48,

    D3DRS_STENCILENABLE = 52,

    D3DRS_STENCILFAIL = 53,

    D3DRS_STENCILZFAIL = 54,

    D3DRS_STENCILPASS = 55,

    D3DRS_STENCILFUNC = 56,

    D3DRS_STENCILREF = 57,

    D3DRS_STENCILMASK = 58,

    D3DRS_STENCILWRITEMASK = 59,

    D3DRS_TEXTUREFACTOR = 60,

    D3DRS_WRAP0 = 128,

    D3DRS_WRAP1 = 129,

    D3DRS_WRAP2 = 130,

    D3DRS_WRAP3 = 131,

    D3DRS_WRAP4 = 132,

    D3DRS_WRAP5 = 133,

    D3DRS_WRAP6 = 134,

    D3DRS_WRAP7 = 135,

    D3DRS_CLIPPING = 136,

    D3DRS_LIGHTING = 137,

    D3DRS_AMBIENT = 139,

    D3DRS_FOGVERTEXMODE = 140,

    D3DRS_COLORVERTEX = 141,

    D3DRS_LOCALVIEWER = 142,

    D3DRS_NORMALIZENORMALS = 143,

    D3DRS_DIFFUSEMATERIALSOURCE = 145,

    D3DRS_SPECULARMATERIALSOURCE = 146,

    D3DRS_AMBIENTMATERIALSOURCE = 147,

    D3DRS_EMISSIVEMATERIALSOURCE = 148,

    D3DRS_VERTEXBLEND = 151,

    D3DRS_CLIPPLANEENABLE = 152,

    D3DRS_POINTSIZE = 154,

    D3DRS_POINTSIZE_MIN = 155,

    D3DRS_POINTSPRITEENABLE = 156,

    D3DRS_POINTSCALEENABLE = 157,

    D3DRS_POINTSCALE_A = 158,

    D3DRS_POINTSCALE_B = 159,

    D3DRS_POINTSCALE_C = 160,

    D3DRS_MULTISAMPLEANTIALIAS = 161,

    D3DRS_MULTISAMPLEMASK = 162,

    D3DRS_PATCHEDGESTYLE = 163,

    D3DRS_DEBUGMONITORTOKEN = 165,

    D3DRS_POINTSIZE_MAX = 166,

    D3DRS_INDEXEDVERTEXBLENDENABLE = 167,

    D3DRS_COLORWRITEENABLE = 168,

    D3DRS_TWEENFACTOR = 170,

    D3DRS_BLENDOP = 171,

    D3DRS_POSITIONDEGREE = 172,

    D3DRS_NORMALDEGREE = 173,

    D3DRS_SCISSORTESTENABLE = 174,

    D3DRS_SLOPESCALEDEPTHBIAS = 175,

    D3DRS_ANTIALIASEDLINEENABLE = 176,

    D3DRS_MINTESSELLATIONLEVEL = 178,

    D3DRS_MAXTESSELLATIONLEVEL = 179,

    D3DRS_ADAPTIVETESS_X = 180,

    D3DRS_ADAPTIVETESS_Y = 181,

    D3DRS_ADAPTIVETESS_Z = 182,

    D3DRS_ADAPTIVETESS_W = 183,

    D3DRS_ENABLEADAPTIVETESSELATION = 184,

    D3DRS_TWOSIDEDSTENCILMODE = 185,

    D3DRS_CCW_STENCILFAIL = 186,

    D3DRS_CCW_STENCILZFAIL = 187,

    D3DRS_CCW_STENCILPASS = 188,

    D3DRS_CCW_STENCILFUNC = 189,

    D3DRS_COLORWRITEENABLE1 = 190,

    D3DRS_COLORWRITEENABLE2 = 191,

    D3DRS_COLORWRITEENABLE3 = 192,

    D3DRS_BLENDFACTOR = 193,

    D3DRS_SRGBWRITEENABLE = 194,

    D3DRS_DEPTHBIAS = 195,

    D3DRS_WRAP8 = 198,

    D3DRS_WRAP9 = 199,

    D3DRS_WRAP10 = 200,

    D3DRS_WRAP11 = 201,

    D3DRS_WRAP12 = 202,

    D3DRS_WRAP13 = 203,

    D3DRS_WRAP14 = 204,

    D3DRS_WRAP15 = 205,

    D3DRS_SEPARATEALPHABLENDENABLE = 206,

    D3DRS_SRCBLENDALPHA = 207,

    D3DRS_DESTBLENDALPHA = 208,

    D3DRS_BLENDOPALPHA = 209,

    D3DRS_FORCE_DWORD = 0x7fffffff

} D3DRENDERSTATETYPE;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值