zoukankan      html  css  js  c++  java
  • CEGUI渲染冲突问题 冷夜

    在Directx中使用CEGUI时渲染状态会产生一些冲突,导致DX画出来的图形不能正常显示,原因是CEGUI的Direct3D9Renderer::beginRendering() 更改了渲染状态和一些变换,所以解决方法是在DX画图形之前恢复你的渲染状态和变换:

    void graphicApp::beginRenderMode()
    {
        pDevice->SetFVF(NULL);
    
        pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
        pDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
        pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
        pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
        pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
        //pDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
        pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
        pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
        pDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
        pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
        pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
        pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
    
        pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
        pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
        pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
        pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
    
        pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
        pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
        pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
        pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
        pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
        pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
        pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    
    
        D3DXMATRIX startMat(1,0,0,0,
            0,1,0,0,
            0,0,1,0,
            0,0,0,1);//初始矩阵
    
        pDevice->SetTransform(D3DTS_WORLD, &startMat);
    
        D3DXVECTOR3 position(0.0f,0.0f,-3.0f);
        D3DXVECTOR3 targect(0.0f,0.0f,0.0f);
        D3DXVECTOR3 up(0.0f,1.0f,0.0f);
        D3DXMATRIX V;
    
        D3DXMatrixLookAtLH(&V,&position,&targect,&up);
        pDevice->SetTransform(D3DTS_VIEW,&V);
    
        D3DXMATRIX proj;
        D3DXMatrixPerspectiveFovLH(&proj,D3DX_PI * 0.5f,width/height,1.0f,1000.0f);
        pDevice->SetTransform(D3DTS_PROJECTION,&proj);
    
    
    }

  • 相关阅读:
    配置Python3 Pip3环境变量
    超级搜索术-读书笔记
    技术笔记-图片管理器
    Python不错的资料、网站
    输入法9键 VS 26键,哪个更适合?
    超级搜索术-思维导图
    Linux知识-Docker
    Python知识体系-基础知识03-函数/类/模块
    js基础(BOM对象)
    js基础(事件)
  • 原文地址:https://www.cnblogs.com/gamesky/p/2875402.html
Copyright © 2011-2022 走看看