示例#1
0
        public bool InitEnviroment()
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            var evpDesc = new EngineNS.Graphics.CGfxViewPortDesc();

            evpDesc.IsDefault           = false;
            evpDesc.Width               = mWidth;
            evpDesc.Height              = mHeight;
            evpDesc.DepthStencil.Format = EngineNS.EPixelFormat.PXF_D24_UNORM_S8_UINT;
            evpDesc.DepthStencil.Width  = mWidth;
            evpDesc.DepthStencil.Height = mHeight;
            var rtDesc = new EngineNS.CRenderTargetViewDesc();

            rtDesc.CreateSRV = 1;
            rtDesc.Width     = mWidth;
            rtDesc.Height    = mHeight;
            rtDesc.Format    = EPixelFormat.PXF_R8G8B8A8_UNORM;
            evpDesc.RenderTargets.Add(rtDesc);
            EditorViewPort = new EngineNS.Graphics.CGfxViewPort();
            EditorViewPort.Init(rc, null, evpDesc);

            RPolicy = new EngineNS.Graphics.CGfxRPolicy_Default();

            InitWorld();
            return(true);
        }
示例#2
0
        public bool Init(bool noPixelShader, bool noPixelWrite, EPlatformType platforms)
        {
            RName noPsShader = RName.GetRName("Shaders/ShadingEnv/Sys/NoPixelShader.shadingenv");
            var   rc         = CEngine.Instance.RenderContext;
            var   shaderDesc = rc.CreateShaderDesc(noPsShader, "PS_Main", EShaderType.EST_PixelShader, new CShaderDefinitions(), platforms);

            if (shaderDesc == null)
            {
                return(false);
            }

            var ps = rc.CreatePixelShader(shaderDesc);

            SDK_GraphicsProfiler_SetEmptyPixelShader(CoreObject, ps.CoreObject);

            if (noPixelWrite)
            {
                CFrameBuffersDesc FBDesc = new CFrameBuffersDesc();
                FBDesc.IsSwapChainBuffer = vBOOL.FromBoolean(false);
                FBDesc.UseDSV            = vBOOL.FromBoolean(false);
                var mFrameBuffer = rc.CreateFrameBuffers(FBDesc);
                if (mFrameBuffer == null)
                {
                    return(false);
                }

                CTexture2DDesc TexDesc = new CTexture2DDesc();
                TexDesc.Init();
                TexDesc.Width     = 1;
                TexDesc.Height    = 1;
                TexDesc.Format    = EPixelFormat.PXF_R8G8B8A8_UNORM;
                TexDesc.BindFlags = (UInt32)(EBindFlags.BF_SHADER_RES | EBindFlags.BF_RENDER_TARGET);
                var Tex2D = rc.CreateTexture2D(TexDesc);

                CShaderResourceViewDesc SRVDesc = new CShaderResourceViewDesc();
                SRVDesc.mTexture2D = Tex2D.CoreObject;
                var SRV = rc.CreateShaderResourceView(SRVDesc);
                mFrameBuffer.BindSRV_RT((UInt32)0, SRV);

                CRenderTargetViewDesc RTVDesc = new CRenderTargetViewDesc();
                RTVDesc.mTexture2D = Tex2D.CoreObject;
                var RTV = rc.CreateRenderTargetView(RTVDesc);
                mFrameBuffer.BindRenderTargetView((UInt32)0, RTV);

                //depth stencil view;
                CDepthStencilViewDesc mDSVDesc = new CDepthStencilViewDesc();
                mDSVDesc.Width  = 1;
                mDSVDesc.Height = 1;
                var mDepthStencilView = rc.CreateDepthStencilView(mDSVDesc);

                mFrameBuffer.BindDepthStencilView(mDepthStencilView);

                SDK_GraphicsProfiler_SetOnePixelFrameBuffers(CoreObject, mFrameBuffer.CoreObject);
            }

            NoPixelShader = noPixelShader;
            NoPixelWrite  = noPixelWrite;

            return(true);
        }
示例#3
0
 public CRenderTargetView CreateRenderTargetView(CRenderTargetViewDesc desc)
 {
     unsafe
     {
         var obj = SDK_IRenderContext_CreateRenderTargetView(CoreObject, &desc);
         if (obj.Pointer == IntPtr.Zero)
         {
             return(null);
         }
         return(new CRenderTargetView(obj));
     }
 }