Ejemplo n.º 1
0
        protected override void _Render(DXCamera camera)
        {
            EffectTechnique technique = _shader.DXEffect.GetTechniqueByIndex(0);
            EffectPass      usePass   = technique.GetPassByIndex(0);

            for (int i = 0; i < 5; i++)
            {
                if (_vertexBuffer2[i] != null && Program.DXSceneOptions.LevelVisibility[i])
                {
                    DXContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(_vertexBuffer2[i], Marshal.SizeOf(typeof(DXSKV)), 0));
                    DXContext.InputAssembler.SetIndexBuffer(_indexBuffer2[i], Format.R32_UInt, 0);
                    DXContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.LineList;
                    DXContext.InputAssembler.InputLayout       = _inputLayout;

                    _shader.SetParameter("worldMatrix", Matrix.Identity);
                    _shader.SetParameter("viewMatrix", camera.ViewMatrix);
                    _shader.SetParameter("projectionMatrix", camera.ProjMatrix);
                    _shader.SetParameter("vp", camera.ViewMatrix * camera.ProjMatrix);

                    usePass.Apply(DXContext);

                    DXContext.DrawIndexed(IndexCount2[i], 0, 0);
                }
            }



            technique.Dispose();
            usePass.Dispose();
        }
Ejemplo n.º 2
0
        private void InitShaders()
        {
            _shader = Program.DXShaderManager.MakeShader("TreeSkeleton");

            // Create the InputElement
            _inputElements = new InputElement[]
            {
                new InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0),
                new InputElement("COLOR", 0, SharpDX.DXGI.Format.R32G32B32_Float, 12, 0)
            };

            // Create the InputLayout
            EffectTechnique technique = _shader.DXEffect.GetTechniqueByIndex(0);
            EffectPass      usePass   = technique.GetPassByIndex(0);

            _inputLayout = new InputLayout(DXDevice, usePass.Description.Signature, _inputElements);
            technique.Dispose();
            usePass.Dispose();
        }
Ejemplo n.º 3
0
        private void InitShaders()
        {
            _shader = Program.DXShaderManager.MakeShader("SolidWireframe");

            // Create the InputElement
            _inputElements = new InputElement[]
            {
                new InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 16, 0),
                new InputElement("NORMAL", 0, SharpDX.DXGI.Format.R32G32B32_Float, 24, 0),
                new InputElement("TANGENT", 0, SharpDX.DXGI.Format.R32G32B32_Float, 36, 0)
            };

            // Create the InputLayout
            EffectTechnique technique = _shader.DXEffect.GetTechniqueByIndex(0);
            EffectPass      usePass   = technique.GetPassByIndex(0);

            _inputLayout = new InputLayout(DXDevice, usePass.Description.Signature, _inputElements);
            technique.Dispose();
            usePass.Dispose();
        }
        /// <summary>
        /// Cleans up the memory allocated by the manager.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                disposed = true;
                if (effect != null)
                {
                    effect.Dispose();
                }
                effect = null;

                if (techniqueRenderTexture != null)
                {
                    techniqueRenderTexture.Dispose();
                }
                techniqueRenderTexture = null;

                if (techniqueRenderVertexColor != null)
                {
                    techniqueRenderVertexColor.Dispose();
                }
                techniqueRenderVertexColor = null;

                if (techniqueRenderMaterialColor != null)
                {
                    techniqueRenderMaterialColor.Dispose();
                }
                techniqueRenderMaterialColor = null;

                if (brightnessVariable != null)
                {
                    brightnessVariable.Dispose();
                }
                brightnessVariable = null;

                if (materialColorVariable != null)
                {
                    materialColorVariable.Dispose();
                }
                materialColorVariable = null;

                if (worldVariable != null)
                {
                    worldVariable.Dispose();
                }
                worldVariable = null;

                if (viewVariable != null)
                {
                    viewVariable.Dispose();
                }
                viewVariable = null;

                if (projectionVariable != null)
                {
                    projectionVariable.Dispose();
                }
                projectionVariable = null;

                if (diffuseVariable != null)
                {
                    diffuseVariable.Dispose();
                }
                diffuseVariable = null;
            }
        }