コード例 #1
0
        /// <summary>
        /// MCDeclElementVertexBufferの複製を作る。
        /// </summary>
        /// <param name="pImmediateContext">ID3D11DeviceContextポインタ</param>
        /// <param name="buffer">複製された buffer を格納する</param>
        /// <returns>0 の場合、buffer に新たにMCDeclElementVertexBufferが作られる</returns>
        public int Clone(out MCDeclElementVertexBuffer buffer)
        {
            int     hr = 0;
            DataBox box1, box2;


            buffer = new MCDeclElementVertexBuffer();
            if (buffer == null)
            {
                return(-1);
            }


            // 頂点バッファ リソースの記述を取得する。
            BufferDescription VertexBD = m_vertexBuffer.Description;


            // 頂点バッファ作成
            hr = buffer.CreateVertexBuffer(
                m_device,
                m_preVertexSize,
                m_vetexNum
                );
            if (hr == 0)
            {
                buffer = null;
                return(hr);
            }
            LockVertexBuffer(m_device.ImmediateContext, out box1, MapMode.Read);
            {
                buffer.LockVertexBuffer(m_device.ImmediateContext, out box2, MapMode.WriteDiscard);
                {
                    unsafe
                    {
                        var src  = (byte *)box1.DataPointer;
                        var dest = (byte *)box2.DataPointer;
                        for (int i = 0; i < m_vetexNum * m_preVertexSize; i++)
                        {
                            dest[i] = src[i];
                        }
                    }
                }
                buffer.UnlockVertexBuffer(m_device.ImmediateContext);
            }
            UnlockVertexBuffer(m_device.ImmediateContext);

            buffer.m_isMemoryShare   = false;
            buffer.m_offset          = m_offset;
            buffer.m_vetexNum        = m_vetexNum;
            buffer.m_preVertexSize   = m_preVertexSize;
            buffer.m_vaVertexElement = m_vaVertexElement;

            return(hr);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public int CreateInputLayout(Device dev, EffectPass pass)
        {
            int hr;

            D3D11_INPUT_ELEMENT_DESC_EX[] aDecl = new D3D11_INPUT_ELEMENT_DESC_EX[15];
            MCDeclElementVertexBuffer     tmpSP = new MCDeclElementVertexBuffer();
            int nSt = 0, nOffset, nCpyNum = 0;

            nOffset = 0;

            // 頂点
            if (m_meshGroup.meshGeometry != null)
            {
                tmpSP   = m_meshGroup.meshGeometry.GetDeclElementVertexBuffer();
                nCpyNum = tmpSP.GetInputElementDesc(aDecl, nSt, nOffset);
                if (nCpyNum != 0)
                {
                    ++nSt;
                    nOffset += nCpyNum;
                }
            }
            // テクスチャ
            if (m_meshGroup.meshTexture != null)
            {
                tmpSP   = m_meshGroup.meshTexture.GetDeclElementVertexBuffer();
                nCpyNum = tmpSP.GetInputElementDesc(aDecl, nSt, nOffset);
                if (nCpyNum != 0)
                {
                    ++nSt;
                    nOffset += nCpyNum;
                }
            }
            // スキンメッシュ
            if (m_meshGroup.meshVBlendBone != null)
            {
                tmpSP   = m_meshGroup.meshVBlendBone.GetDeclElementVertexBuffer();
                nCpyNum = tmpSP.GetInputElementDesc(aDecl, nSt, nOffset);
                if (nCpyNum != 0)
                {
                    ++nSt;
                    nOffset += nCpyNum;
                }
            }

            // 頂点宣言オブジェクト作成
            hr = App.LayoutMgr.GetLayoutID(aDecl, nCpyNum, out m_meshGroup.layoutID);
            return(hr);
        }
コード例 #3
0
        /// <summary>
        /// m_vertexBufferSPのメモリ領域を共有した複製を作る
        /// </summary>
        /// <param name="pSP">MCDeclElementVertexBufferSP 割り当てる</param>
        /// <returns>何もなければ 0 を返す。</returns>
        public int CloneShare(out MCDeclElementVertexBuffer buffer)
        {
            buffer = new MCDeclElementVertexBuffer();

            if (buffer == null)
            {
                return(-1);
            }

            buffer.m_isMemoryShare   = true;
            buffer.m_offset          = m_offset;
            buffer.m_vetexNum        = m_vetexNum;
            buffer.m_preVertexSize   = m_preVertexSize;
            buffer.m_vaVertexElement = m_vaVertexElement;
            buffer.m_vertexBuffer    = m_vertexBuffer;

            return(0);
        }