Restore the cegui rendering status
I just got in touch with cegui. After drawing a small window in the original d3d program, I found that the rendering effect was quite different from the previous one. After checking the source code, I found that, the original cegui does not return to the default rendering state after rendering, so it is changed, then compiled, run, and everything is normal...
The following code restores the rendering status, which corresponds to the initialization rendering status function 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 color 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_colodrop, d3dtop_selectarg1 );
24
25 // setup Alpha calculations
26 d_device-> settexturestagestate (0, d3dtss_alph1_g1, d3dta_texture );
27 d_device-> settexturestagestate (0, d3dtss_alph1_g2, 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_colodrop, 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}
In addition, cegui has two rendering modes: instant rendering and buffer rendering. Therefore, after the two rendering modes, you must call the above Code to restore the rendering state.
Copyright Disclaimer: This article is an original article and can be reproduced. However, you must use a hyperlink to indicate the original source and author information of the article. Please respect your labor achievements. Thank you!
Xiao Xiang's blog http://xfxsworld.cnblogs.com