|
Posted on 2007-11-15 20:22 小祥 阅读(1597) 评论(4) 编辑 收藏 引用 所属分类: CEGUI
刚刚接触CEGUI,在原D3D程序上画了一个小窗口后,发现渲染效果于以前的大相径庭,查看了源代码后发现,原来CEGUI在渲染后并没有恢复到默认的渲染状态,于是改之,再编译、运行、一切正常。。。
下面是恢复其渲染状态的代码,与初始化渲染状态函数initPerFrameStates()对应
1
void
DirectX9Renderer::UnitFrameStates()
2
{
3
//
setup vertex stream
4
5
d_device
->
SetFVF(NULL);
6
7
//
set device states
8
d_device
->
SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
9
d_device
->
SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
10
d_device
->
SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
11
d_device
->
SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
12
d_device
->
SetRenderState(D3DRS_FOGENABLE, FALSE);
13
d_device
->
SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
14
15
16
//
setup texture addressing settings/*
17
d_device
->
SetSamplerState(
0
, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
18
d_device
->
SetSamplerState(
0
, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
19
20
//
setup colour calculations
21
d_device
->
SetTextureStageState(
0
, D3DTSS_COLORARG1, D3DTA_TEXTURE);
22
d_device
->
SetTextureStageState(
0
, D3DTSS_COLORARG2, D3DTA_CURRENT);
23
d_device
->
SetTextureStageState(
0
, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
24
25
//
setup alpha calculations
26
d_device
->
SetTextureStageState(
0
, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
27
d_device
->
SetTextureStageState(
0
, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
28
d_device
->
SetTextureStageState(
0
, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
29
30
//
setup filtering
31
d_device
->
SetSamplerState(
0
, D3DSAMP_MINFILTER, D3DTEXF_POINT);
32
d_device
->
SetSamplerState(
0
, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
33
34
//
disable texture stages we do not need.
35
d_device
->
SetTextureStageState(
1
, D3DTSS_COLOROP, D3DTOP_DISABLE);
36
37
//
setup scene alpha blending
38
d_device
->
SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
39
d_device
->
SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
40
d_device
->
SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
42
}
另外CEGUI有2种渲染模式:立即渲染和缓冲渲染。所以在这2种渲染模式结束后都需要调用上面的代码以恢复渲染状态
Feedback
# re: 恢复CEGUI渲染状态[未登录] 回复 更多评论
2007-11-16 12:17 by
偶来给你顶一下~
# re: 恢复CEGUI渲染状态 回复 更多评论
2008-05-10 10:49 by
CEGUI应该有自己恢复函数吧,你找了没?
# re: 恢复CEGUI渲染状态 回复 更多评论
2009-03-26 17:58 by
CEGUI没有自己的状态清理函数的
我也遇到了渲染状态的问题,找了好久才找到
# re: 恢复CEGUI渲染状态 回复 更多评论
2013-09-18 00:19 by
老大 CEGUI木有这些函数啊
|