游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2599|回复: 0

CEGUI 0.7.5 + DirectX 渲染状态的问题

[复制链接]

1

主题

1

帖子

5

积分

新手上路

Rank: 1

积分
5
发表于 2013-8-23 20:52:57 | 显示全部楼层 |阅读模式
  众所周知,CEGUI在渲染DirectX时,会自己改掉一些渲染状态,可恶的是又不提供恢复函数,这是我的代码,有没有熟悉的人能帮我分析一下问题出在哪里,如何恢复,感激不尽!

DWORD origFVF = 0;

        DWORD orig_D3D_Render[20] = {0};
        DWORD orig_D3DSAMP_State[20] = {0};


        D3DMATRIX Matrix;

        origIDirect3DDevice9->GetFVF(&origFVF);
        origIDirect3DDevice9->GetRenderState(D3DRS_LIGHTING, &orig_D3D_Render[0]);
        origIDirect3DDevice9->GetRenderState(D3DRS_FOGENABLE, &orig_D3D_Render[1]);
        origIDirect3DDevice9->GetRenderState(D3DRS_ZENABLE, &orig_D3D_Render[2]);
        origIDirect3DDevice9->GetRenderState(D3DRS_ALPHATESTENABLE, &orig_D3D_Render[3]);
        origIDirect3DDevice9->GetRenderState(D3DRS_CULLMODE, &orig_D3D_Render[4]);
        origIDirect3DDevice9->GetRenderState(D3DRS_FILLMODE, &orig_D3D_Render[5]);
        origIDirect3DDevice9->GetRenderState(D3DRS_SCISSORTESTENABLE, &orig_D3D_Render[6]);
        origIDirect3DDevice9->GetRenderState(D3DRS_ZWRITEENABLE, &orig_D3D_Render[7]);

        origIDirect3DDevice9->GetSamplerState(0, D3DSAMP_ADDRESSU, &orig_D3DSAMP_State[0]);
        origIDirect3DDevice9->GetSamplerState(0, D3DSAMP_ADDRESSV, &orig_D3DSAMP_State[1]);

        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_COLORARG1, &orig_D3DSAMP_State[2]);
        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_COLORARG2, &orig_D3DSAMP_State[3]);
        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_COLOROP, &orig_D3DSAMP_State[4]);

        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_ALPHAARG1, &orig_D3DSAMP_State[5]);
        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_ALPHAARG2, &orig_D3DSAMP_State[6]);
        origIDirect3DDevice9->GetTextureStageState(0, D3DTSS_ALPHAOP, &orig_D3DSAMP_State[7]);

        origIDirect3DDevice9->GetSamplerState(0, D3DSAMP_MINFILTER, &orig_D3DSAMP_State[8]);
        origIDirect3DDevice9->GetSamplerState(0, D3DSAMP_MAGFILTER,&orig_D3DSAMP_State[9]);

        origIDirect3DDevice9->GetTextureStageState(1, D3DTSS_COLOROP, &orig_D3DSAMP_State[10]);
        origIDirect3DDevice9->GetRenderState(D3DRS_ALPHABLENDENABLE, &orig_D3DSAMP_State[11]);

        origIDirect3DDevice9->GetTransform(D3DTS_VIEW, &Matrix);

        CEGUI::System::getSingleton().renderGUI();

        origIDirect3DDevice9->SetFVF(origFVF);
        origIDirect3DDevice9->SetRenderState(D3DRS_LIGHTING, orig_D3D_Render[0]);
        origIDirect3DDevice9->SetRenderState(D3DRS_FOGENABLE, orig_D3D_Render[1]);
        origIDirect3DDevice9->SetRenderState(D3DRS_ZENABLE, orig_D3D_Render[2]);
        origIDirect3DDevice9->SetRenderState(D3DRS_ALPHATESTENABLE, orig_D3D_Render[3]);
        origIDirect3DDevice9->SetRenderState(D3DRS_CULLMODE, orig_D3D_Render[4]);
        origIDirect3DDevice9->SetRenderState(D3DRS_FILLMODE, orig_D3D_Render[5]);
        origIDirect3DDevice9->SetRenderState(D3DRS_SCISSORTESTENABLE, orig_D3D_Render[6]);
        origIDirect3DDevice9->SetRenderState(D3DRS_ZWRITEENABLE, orig_D3D_Render[7]);

        origIDirect3DDevice9->SetSamplerState(0, D3DSAMP_ADDRESSU, orig_D3DSAMP_State[0]);
        origIDirect3DDevice9->SetSamplerState(0, D3DSAMP_ADDRESSV, orig_D3DSAMP_State[1]);
        
        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_COLORARG1, orig_D3DSAMP_State[2]);
        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_COLORARG2, orig_D3DSAMP_State[3]);
        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_COLOROP, orig_D3DSAMP_State[4]);

        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_ALPHAARG1, orig_D3DSAMP_State[5]);
        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_ALPHAARG2, orig_D3DSAMP_State[6]);
        origIDirect3DDevice9->SetTextureStageState(0, D3DTSS_ALPHAOP, orig_D3DSAMP_State[7]);

        origIDirect3DDevice9->SetSamplerState(0, D3DSAMP_MINFILTER, orig_D3DSAMP_State[8]);
        origIDirect3DDevice9->SetSamplerState(0, D3DSAMP_MAGFILTER, orig_D3DSAMP_State[9]);

        origIDirect3DDevice9->SetTextureStageState(1, D3DTSS_COLOROP, orig_D3DSAMP_State[10]);
        origIDirect3DDevice9->SetRenderState(D3DRS_ALPHABLENDENABLE, orig_D3DSAMP_State[11]);

        origIDirect3DDevice9->SetTransform(D3DTS_VIEW, &Matrix);


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-2-26 14:10

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表