Esempio n. 1
0
        private static void SetupUniformMatrices()
        {
            Matrix4 projectionMatrix =
                new Matrix4(
                    1.0f, 0.0f, 0.0f, 0.0f,
                    0.0f, -1.0f, 0.0f, 0.0f,
                    0.0f, 0.0f, 0.5f, 0.0f,
                    0.0f, 0.0f, 0.5f, 1.0f)
                * Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, Context.SurfaceWidth / (float)Context.SurfaceHeight, 0.1f, 100.0f);


            VulkanBase.Camera.Position = new Vector3(0.0f, 10f, 0.0f);
            VulkanBase.Camera.Rotation = new Vector3(0, (float)Math.PI / 2f, 0);

            Matrix4 viewMatrix = VulkanBase.Camera.CalculateViewMatrix();


            uint bufferSize = graphicsPipeline.ShaderUniformSets[0].GetSize();

            Matrix4[] matrices = new Matrix4[]
            {
                projectionMatrix,
                viewMatrix
            };

            uniformBuffer = Context.BufferManager.CreateBuffer(BufferUsageFlags.UniformBuffer, bufferSize, matrices);


            uniformDescriptorSet = graphicsPipeline.CreateDescriptorSet(0, 0, uniformBuffer);
        }
Esempio n. 2
0
        public TextDisplayer()
        {
            _textPipeline = new GenericGraphicsPipeline(
                new List <ShaderObject>()
            {
                new EmbeddedShaderObject("VulkanBase.Text.Shader.text.frag"),
                new EmbeddedShaderObject("VulkanBase.Text.Shader.text.vert")
            }
                );

            _font               = new Font(Properties.Resources.Courier, Properties.Resources.CourierCharacterWidth);
            _imageWithMemory    = TextureLoader.CreateImageWithMemory(_font.Texture);
            _imageDescriptorSet = _textPipeline.CreateDescriptorSet(0, 0, _imageWithMemory.ImageView);
        }