Example #1
0
		public Universe(Connection connection, ElementHost host)
		{
			InitializeComponent();

			m_connection = connection;
			m_host = host;

			m_container = new D3DImageSlimDX();
			m_container.IsFrontBufferAvailableChanged += new DependencyPropertyChangedEventHandler(OnIsFrontBufferAvailableChanged);
			RenderImage.Source = m_container;

			m_scene = new Scene(m_host, m_connection);
			var texture = m_scene.SharedTexture;
			m_container.SetBackBufferSlimDX(texture);
			BeginRenderingScene();
		}
Example #2
0
		public ThreadView(Connection conn, Scene scene)
		{
			m_connection = conn;
			m_device = scene.Device;
			m_context = m_device.ImmediateContext;

			var bytecode = ShaderBytecode.CompileFromFile(RenderSupport.ContentPath + "\\Universe.fx", "fx_5_0", ShaderFlags.None, EffectFlags.None);
			m_effect = new Effect(m_device, bytecode);
			var pass = m_effect.GetTechniqueByIndex(0).GetPassByIndex(0);
			m_layout = new InputLayout(m_device, pass.Description.Signature, QuadVertex.Elements);

			m_vertices = new SlimDX.Direct3D11.Buffer(m_device, new BufferDescription()
			{
				CpuAccessFlags = CpuAccessFlags.Write,
				BindFlags = BindFlags.VertexBuffer,
				SizeInBytes = 6 * MaxQuads * QuadVertex.SizeBytes,
				Usage = ResourceUsage.Dynamic
			});

			m_texture = Texture2D.FromFile(m_device, RenderSupport.ContentPath + "\\stars.png");
			m_textureView = new ShaderResourceView(m_device, m_texture);
		}
Example #3
0
		public void DrawIconic(Scene parentScene)
		{
			throw new NotImplementedException();
		}
Example #4
0
		public void Draw(Scene parentScene)
		{
			m_context.InputAssembler.InputLayout = m_layout;
			m_context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
			m_context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(m_vertices, QuadVertex.SizeBytes, 0));
			m_context.InputAssembler.SetIndexBuffer(parentScene.QuadIndices, SlimDX.DXGI.Format.R16_UInt, 0);

			var mvp = m_effect.GetVariableByName("ModelViewProj");
			//Matrix modelViewProj = Matrix.Scaling(0.5f, 1.0f, 1.0f);
			Matrix modelViewProj = Matrix.PerspectiveFovLH((float) Math.PI / 3.0f, (float) parentScene.Width / parentScene.Height, 0.1f, 10.0f);
			mvp.AsMatrix().SetMatrix(modelViewProj);
			m_effect.GetVariableByName("Texture").AsResource().SetResource(m_textureView);

			var technique = m_effect.GetTechniqueByIndex(0);
			var pass = technique.GetPassByIndex(0);

			for(int i = 0; i < technique.Description.PassCount; ++i)
			{
				pass.Apply(m_context);
				m_context.DrawIndexed(6 * m_threads.Count, 0, 0);
			}
		}