Jump to content

  • Log In with Google      Sign In   
  • Create Account


Megafont

Member Since 24 Oct 2008
Offline Last Active Dec 13 2012 06:43 PM

Topics I've Started

SlimDX Directx11 Text Rendering Problem

07 December 2012 - 05:31 AM

Ok, I have been following the tutorials on braynzarsoft.net, but using SlimDX. I am currently stuck on tutorial #14 which is about rendering text on the screen. But you have to go through all this bs of creating a D3D10 device, and using D2D and DirectWrite, just to get text on the screen. Anyway, I have the code in and the compiler is happy with it, except for one detail. The tutorial says that you MUST set the DriverType for the D3D11 device, to DriverType.Unknown. But anytime I set it to that, it is an automatic fail with an invalid arg error from the CreateDeviceWithSwapChain() method. So how is it that I am supposed to set it to DriverType.Unknown if it simply hates that value for that parameter?

If I leave it set to DriverType.Hardware, the program will run and draw a triangle on the screen like it is supposed to, but the text is nowhere to be seen. I have no idea what the problem is.

The tutorial I am following is here:
http://braynzarsoft....php?p=D3D11FONT


Here is the code of my class that handles the text rendering. I made it a separate class because it would clutter up the main gamewindow class since you have to do this rediculous pile of crap just to get text on the screen.
	public class TextRenderer_D2D_DW : IDisposable
	{
		#region Constants
		#endregion

		#region Member Variables
		SlimDX.Windows.RenderForm m_ParentWindow = null;
		SlimDX.Direct3D10_1.Device1 m_d3d101_Device = null;
		SlimDX.Direct3D11.Device m_d3d11_Device = null;
		KeyedMutex m_keyedMutex_d3d11 = null;
		KeyedMutex m_keyedMutex_d3d10 = null;
		SlimDX.Direct2D.RenderTarget m_d2dRenderTarget = null;		  // A RenderTarget for D2D to draw on.
		SlimDX.Direct2D.SolidColorBrush m_d2dBrush = null;			  // The Brush D2D will draw with.
		//SlimDX.Direct3D11.Texture2D m_backBuffer_d3d11 = null;
		SlimDX.Direct3D11.Texture2D m_sharedTexture_d3d11 = null;	   // The shared texture that we will have D2D/DW render onto, and then have D3D overlay this texture onto our scene.
		SlimDX.Direct3D11.Buffer m_d2dVertexBuffer = null;			  // The vertex buffer for the square to render the text texture onto.
		SlimDX.Direct3D11.Buffer m_d2dIndexBuffer = null;			   // The index buffer for the square to render the text texture onto.
		SlimDX.Direct3D11.ShaderResourceView m_textTexture = null;	  // The ShaderResourceView for the text texture.
		BlendState m_BlendState_Transparency = null;					// Our transparency blending state.
		RasterizerState m_RasterizerState_CWcullmode = null;			// for clockwise culling
		SamplerState m_TextSamplerState = null;						 // our SamplerState
		SlimDX.DirectWrite.Factory m_DWrite_Factory = null;			 // A DirectWrite Factory.
		SlimDX.DirectWrite.TextFormat m_DWrite_TextFormat = null;	   // Holds our text format settings, such as font, size, etc.
	  
		// These hold references to the passed int ConstantBuffers.
		ConstantBuffer_ChangesOnResize m_cbOnResize = null;			
		ConstantBuffer_ChangesPerFrame m_cbPerFrame = null;
		ConstantBuffer_ChangesPerObject m_cbPerObject = null;

		int m_nVertexBufferStride = 0;   // Stores the stride (number of bytes per vertex) in our vertex buffer.
		// Shaders
		VertexShader m_vShader = null;
		ShaderSignature m_vShaderSignature = null;
		PixelShader m_pShader = null;

		bool m_bIsInitialized = false;   // Indicates whether this object is initialized or not.
		bool m_bDisposed = false;		// Indicates whether this object has been disposed or not.
		#endregion

		#region Constructors
		public TextRenderer_D2D_DW(SlimDX.Windows.RenderForm form, SlimDX.Direct3D11.Device d3d11_device, ConstantBuffer_ChangesOnResize cbOnResize, ConstantBuffer_ChangesPerFrame cbPerFrame, ConstantBuffer_ChangesPerObject cbPerObject)
		{
			if (form == null)
				throw new Exception("The passed in form parameter is null!");
			this.m_ParentWindow = form;
			if (d3d11_device == null)
				throw new Exception("The passed in Direct3D 11 device is null!");
			this.m_d3d11_Device = d3d11_device;
			if (cbOnResize == null)
				throw new Exception("The first passed in constant buffer object is null!");
			this.m_cbOnResize = cbOnResize;
			if (cbPerFrame == null)
				throw new Exception("The second passed in constant buffer object is null!");
			this.m_cbPerFrame = cbPerFrame;
			if (cbPerObject == null)
				throw new Exception("The third passed in constant buffer object is null!");
			this.m_cbPerObject = cbPerObject;
			InitD2D_D3D101_DWrite();
			InitD2DScreenTexture();
			InitShaders();
			// Set up our Transparency blending state.
			// ----------------------------------------------------------------------------------------
		  
			// Create our RenderTargetBlendDescription.
			RenderTargetBlendDescription rtbd = new RenderTargetBlendDescription();
			rtbd.BlendEnable = true;
			rtbd.SourceBlend = BlendOption.SourceColor;
			rtbd.DestinationBlend = BlendOption.InverseSourceAlpha;
			rtbd.BlendOperation = BlendOperation.Add;
			rtbd.SourceBlendAlpha = BlendOption.One;
			rtbd.DestinationBlendAlpha = BlendOption.Zero;
			rtbd.BlendOperationAlpha = BlendOperation.Add;
			rtbd.RenderTargetWriteMask = ColorWriteMaskFlags.All;
		  
			// Create our BlendStateDescription.
			BlendStateDescription bsd = new BlendStateDescription();
			bsd.AlphaToCoverageEnable = false;
			bsd.RenderTargets[0] = rtbd;
			// Create our BlendState.
			m_BlendState_Transparency = BlendState.FromDescription(m_d3d11_Device, bsd);

			// Set up a RasterizerState for Clockwise culling mode.
			// ----------------------------------------------------------------------------------------
			// Create our RasterizerStateDescription
			RasterizerStateDescription rsd = new RasterizerStateDescription();
			rsd.FillMode = SlimDX.Direct3D11.FillMode.Solid;
			rsd.CullMode = CullMode.Back;
			// Create the Clockwise cull mode state.
			rsd.IsFrontCounterclockwise = false;
			m_RasterizerState_CWcullmode = RasterizerState.FromDescription(m_d3d11_Device, rsd);


			// Set up a SamplerState that we will use for Rendering our text.
			// ----------------------------------------------------------------------------------------
			// Create a SamplerDescription
			SamplerDescription sd = new SamplerDescription();
			sd.Filter = Filter.MinMagMipLinear;
			sd.AddressU = TextureAddressMode.Wrap;
			sd.AddressV = TextureAddressMode.Wrap;
			sd.AddressW = TextureAddressMode.Wrap;
			sd.ComparisonFunction = Comparison.Never;
			sd.MinimumLod = 0;
			sd.MaximumLod = float.MaxValue;
			// Create our SamplerState
			m_TextSamplerState = SamplerState.FromDescription(m_d3d11_Device, sd);

			m_bIsInitialized = true;
		}
		#endregion

		#region Non-Public Methods
		// This section is for methods that are declared as private, protected, protected internal, or internal.

		private bool InitD2D_D3D101_DWrite()
		{
			// Create our Direct3D 10.1 Device
			m_d3d101_Device = new SlimDX.Direct3D10_1.Device1(m_d3d11_Device.Factory.GetAdapter(0),
															  SlimDX.Direct3D10.DriverType.Hardware,
															  SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport | SlimDX.Direct3D10.DeviceCreationFlags.Debug,
															  SlimDX.Direct3D10_1.FeatureLevel.Level_10_1);

			// Create the Shared Texture that Direct3D 10.1 will render on
			SlimDX.Direct3D11.Texture2DDescription sharedTexDesc = new Texture2DDescription();
			sharedTexDesc.Width = m_ParentWindow.ClientSize.Width;
			sharedTexDesc.Height = m_ParentWindow.ClientSize.Height;
			sharedTexDesc.Format = Format.B8G8R8A8_UNorm;
			sharedTexDesc.MipLevels = 1;
			sharedTexDesc.ArraySize = 1;
			sharedTexDesc.SampleDescription = new SampleDescription(1, 0);
			sharedTexDesc.Usage = ResourceUsage.Default;
			sharedTexDesc.BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget;
			sharedTexDesc.OptionFlags = ResourceOptionFlags.KeyedMutex;
			m_sharedTexture_d3d11 = new Texture2D(m_d3d11_Device, sharedTexDesc);

			// Get the keyed mutex for the shared texture (for Direct3D 11)
			m_keyedMutex_d3d11 = new KeyedMutex(m_sharedTexture_d3d11);
			m_keyedMutex_d3d11.Acquire(0, 5);
			// Get the resource for the shared texture.
			SlimDX.DXGI.Resource r = new SlimDX.DXGI.Resource(m_sharedTexture_d3d11);
			// Open the surface for the shared texture in Direct3D 10.1.
			SlimDX.Direct3D10.Texture2D sharedTexture10;
			sharedTexture10 = m_d3d101_Device.OpenSharedResource<SlimDX.Direct3D10.Texture2D>(r.SharedHandle);
			m_keyedMutex_d3d10 = new KeyedMutex(sharedTexture10);
		  
			// Create the Direct2D factory
			SlimDX.Direct2D.Factory d2dFactory = new SlimDX.Direct2D.Factory(SlimDX.Direct2D.FactoryType.SingleThreaded);
			SlimDX.Direct2D.RenderTargetProperties d2d_rtp = new RenderTargetProperties();
			d2d_rtp.Type = RenderTargetType.Hardware;
			d2d_rtp.PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied);
			m_d2dRenderTarget = RenderTarget.FromDXGI(d2dFactory, sharedTexture10.AsSurface(), d2d_rtp);
			sharedTexture10.Dispose();
			d2dFactory.Dispose();
			r.Dispose();
			// Create a solid color brush to draw something with.
			m_d2dBrush = new SolidColorBrush(m_d2dRenderTarget, new Color4(1.0f, 1.0f, 0.0f, 1.0f));


			// DirectWrite
			m_DWrite_Factory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
			m_DWrite_TextFormat = m_DWrite_Factory.CreateTextFormat("Arial",
																	FontWeight.Normal,
																	FontStyle.Normal,
																	FontStretch.Normal,
																	24.0f,
																	"en-us");
			m_DWrite_TextFormat.TextAlignment = TextAlignment.Leading;
			m_DWrite_TextFormat.ParagraphAlignment = ParagraphAlignment.Near;
			// This is to prevent an annoying warning that pops up if you haven't set the primitive topology.
			m_d3d101_Device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.PointList);

			return true;
		}

		void InitD2DScreenTexture()
		{
			VertexList<Vertex3D_T> vList = new VertexList<Vertex3D_T>(m_d3d11_Device);
			vList.AddVertex(new Vertex3D_T(-1.0f, -1.0f, 1.0f, 0.0f, 1.0f));
			vList.AddVertex(new Vertex3D_T(-1.0f,  1.0f, 1.0f, 0.0f, 0.0f));
			vList.AddVertex(new Vertex3D_T( 1.0f,  1.0f, 1.0f, 1.0f, 0.0f));
			vList.AddVertex(new Vertex3D_T( 1.0f, -1.0f, 1.0f, 1.0f, 1.0f));
			// Create the vertex buffer now that we've defined all the vertex data.
			vList.CreateVertexBuffer(out m_d2dVertexBuffer);
			m_nVertexBufferStride = vList.VertexSize;

			IndexList<UInt16> iList = new IndexList<UInt16>(m_d3d11_Device);
			// Front Face
			iList.AddIndices(0, 1, 2,
							 0, 2, 3);

			// Create the index buffer now that we've defined all the index data.
			iList.CreateIndexBuffer(out m_d2dIndexBuffer);
			// Create a ShaderResourceView from the texture D2D will render to,
			// So we can use it to texture a square which overlays our scene.
			m_textTexture = new ShaderResourceView(m_d3d11_Device, m_sharedTexture_d3d11);
		}

		void InitShaders()
		{
			string shaderCode = "";

			// The file TextRenderer_D2D_DW is an embedded resource.  So we need to access it and put it in a string variable first.
			using (Stream stream = Assembly.GetExecutingAssembly()
										   .GetManifestResourceStream("Megafont_Framework.Graphics._3D.DX11.TextRenderer_D2D_DW.fx"))
			{
				using (StreamReader reader = new StreamReader(stream))
				{
					shaderCode = reader.ReadToEnd();
				}
			}

		  
			// load and compile the vertex shader
			string vsCompileError = "TextRenderer_D2D_DW - Vertex Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.Compile(shaderCode, "Text_VS", "vs_4_0", ShaderFlags.Debug, EffectFlags.None, null, null, out vsCompileError))
			{
				m_vShaderSignature = ShaderSignature.GetInputSignature(bytecode);
				m_vShader = new VertexShader(m_d3d11_Device, bytecode);
			}
		  
			// load and compile the pixel shader
			string psCompileError = "TextRenderer_D2D_DW - Pixel Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.Compile(shaderCode, "Text_PS", "ps_4_0", ShaderFlags.Debug, EffectFlags.None, null, null, out psCompileError))
			{
				m_pShader = new PixelShader(m_d3d11_Device, bytecode);
			}
		}
	  
		#endregion

		#region Public Methods
		public void RenderString(string text)
		{
			if (!m_bIsInitialized)
				return;

			BlendState blendState = null;
			RasterizerState rasterizerState = null;
			SamplerState samplerState = null;
			VertexShader vertexShader = null;
			PixelShader pixelShader = null;

			// Save the current states so we can reset them when we're done with them.
			blendState = m_d3d11_Device.ImmediateContext.OutputMerger.BlendState;
			rasterizerState = m_d3d11_Device.ImmediateContext.Rasterizer.State;
			samplerState = m_d3d11_Device.ImmediateContext.PixelShader.GetSamplers(0, 1)[0]; // We only take the first SamplerState since its the only one we will change when we render the text texture to the back buffer below.
			vertexShader = m_d3d11_Device.ImmediateContext.VertexShader.Get();
			pixelShader = m_d3d11_Device.ImmediateContext.PixelShader.Get();

			// Release the shared texture from the D3D 11 Device.
			m_keyedMutex_d3d11.Release(0);
			// Aquire the shared texture with the D3D 10.1 Device.
			m_keyedMutex_d3d10.Acquire(0, int.MaxValue);
		  
			// Begin drawing Direct2D content.
			m_d2dRenderTarget.BeginDraw();

			// Clear the D2D Background
			m_d2dRenderTarget.Clear(new Color4(1.0f, 0.0f, 0.0f, 0.0f));

			// Set the Font Color
			Color4 FontColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
			// Set the brush color D2D will use to draw with.
			m_d2dBrush.Color = FontColor;
			// Create the D2D render area
			System.Drawing.RectangleF layoutRect = new System.Drawing.RectangleF(0, 0, m_ParentWindow.ClientSize.Width, m_ParentWindow.ClientSize.Height);

			// Draw the Text onto the shared texture.
			m_d2dRenderTarget.DrawText(text,
									   m_DWrite_TextFormat,
									   layoutRect,
									   m_d2dBrush);
			// Finish drawing Direct2D content.
			m_d2dRenderTarget.EndDraw();

			// Release the shared texture from the Direct3D 10.1 Device.
			m_keyedMutex_d3d10.Release(1);
			// Aquire the shared texture with the Direct3D 11 Device.
			m_keyedMutex_d3d11.Acquire(1, int.MaxValue);
		  
			// Use the shader resource representing the Direct2D render target
			// to texture a square which is rendered in screen space so it
			// overlays on top of our entire scene. We use alpha blending so
			// that the entire background of the D2D render target is "invisible",
			// And only the stuff we draw with D2D will be visible (the text)

			// Set the blending state of the Direct3D 11 device.
			m_d3d11_Device.ImmediateContext.OutputMerger.BlendState = m_BlendState_Transparency;
		  

			// Set the vertex buffer for the text geometry (a square).
			m_d3d11_Device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new SlimDX.Direct3D11.VertexBufferBinding(m_d2dVertexBuffer, 20, 0));
			// Set the index buffer for the text geometry.
			m_d3d11_Device.ImmediateContext.InputAssembler.SetIndexBuffer(m_d2dIndexBuffer, Format.R16_UInt, 0);

			// Set the vertex shader to the one this TextRenderer uses.
			m_d3d11_Device.ImmediateContext.VertexShader.Set(m_vShader);
			// Set the pixel shader to the one this TextRenderer uses.
			m_d3d11_Device.ImmediateContext.PixelShader.Set(m_pShader);

			// Set the world matrix to the Indentity Matrix.
			Matrix tempP = m_cbOnResize.ProjectionMatrix;
			Matrix tempV = m_cbPerFrame.ViewMatrix;
			Matrix tempW = m_cbPerObject.WorldMatrix;
			m_cbOnResize.ProjectionMatrix = Matrix.Identity;
			m_cbOnResize.UpdateBuffer();
			m_cbPerFrame.ViewMatrix = Matrix.Identity;
			m_cbPerFrame.UpdateBuffer();
			m_cbPerObject.WorldMatrix = Matrix.Identity;
			m_cbPerObject.UpdateBuffer();
		  

		  
			// Set the RasterizerState to our Clockwise Cull mode one.
			m_d3d11_Device.ImmediateContext.Rasterizer.State = m_RasterizerState_CWcullmode;
			// Set the shader resource (our shared text texture).
			m_d3d11_Device.ImmediateContext.PixelShader.SetShaderResource(m_textTexture, 0);
			// Set the SamplerState.
			m_d3d11_Device.ImmediateContext.PixelShader.SetSampler(m_TextSamplerState, 0);
		  
		  
			// Draw the text texture overlay on top of our scene.
			m_d3d11_Device.ImmediateContext.DrawIndexed(6, 0, 0);
			// Reset the vertex shader.
			m_d3d11_Device.ImmediateContext.VertexShader.Set(vertexShader);
			// Reset the pixel shader.
			m_d3d11_Device.ImmediateContext.PixelShader.Set(pixelShader);
			// Reset the states of the Direct3D 11 Device now that we are done with them.
			// This way we leave the device how we found it for the parent program.
			m_d3d11_Device.ImmediateContext.OutputMerger.BlendState = blendState;
			m_d3d11_Device.ImmediateContext.Rasterizer.State = rasterizerState;
			m_d3d11_Device.ImmediateContext.PixelShader.SetSampler(samplerState, 0);

			// Reset the ConstantBuffers as well.
			m_cbPerFrame.ViewMatrix = tempV;
			m_cbOnResize.ProjectionMatrix = tempP;
			m_cbPerObject.WorldMatrix = tempW;
			m_cbOnResize.UpdateBuffer();
			m_cbPerFrame.UpdateBuffer();
			m_cbPerObject.UpdateBuffer();
		  
		}
		#endregion

		#region Operators
		#endregion

		#region IDisposable Members
		// Implement IDisposable.
		// Do not make this method virtual.
		// A derived class should not be able to override this method.
		public void Dispose()
		{
			Dispose(true);
			// Since this Dispose() method already cleaned up the resources used by this object, there's no need for the
			// Garbage Collector to call this class's Finalizer, so we tell it not to.
			GC.SuppressFinalize(this);
		}
		protected void Dispose(bool disposing)
		{
			if (!this.m_bDisposed)
			{
				/*
				* The following text is from MSDN  (http://msdn.microsoft.com/en-us/library/fs2xkftw%28VS.80%29.aspx)
				*
				*
				* Dispose(bool disposing) executes in two distinct scenarios:
				*
				* If disposing equals true, the method has been called directly or indirectly by a user's code and managed and unmanaged resources can be disposed.
				* If disposing equals false, the method has been called by the runtime from inside the finalizer and only unmanaged resources can be disposed.
				*
				* When an object is executing its finalization code, it should not reference other objects, because finalizers do not execute in any particular order.
				* If an executing finalizer references another object that has already been finalized, the executing finalizer will fail.
				*/
				if (disposing)
				{
					// Unregister events

					// get rid of managed resources
					m_ParentWindow = null;  // We don't release this since it was created by the parent program.
					m_d3d11_Device = null;  // This was also created by the parent program.
					m_d3d101_Device.Dispose();
					m_keyedMutex_d3d10.Dispose();
					m_keyedMutex_d3d11.Dispose();
				  
					m_d2dRenderTarget.Dispose();
					m_d2dBrush.Dispose();
					m_sharedTexture_d3d11.Dispose();
					m_d2dVertexBuffer.Dispose();
					m_d2dIndexBuffer.Dispose();
					m_textTexture.Dispose();
					m_BlendState_Transparency.Dispose();
					m_RasterizerState_CWcullmode.Dispose();
					m_TextSamplerState.Dispose();
					m_DWrite_Factory.Dispose();
					m_DWrite_TextFormat.Dispose();
					m_pShader.Dispose();
					m_vShader.Dispose();
					m_vShaderSignature.Dispose();
				}
				// get rid of unmanaged resources

			}
		}
		#endregion

		#region Debug Methods
#if (DEBUG)
		// put all debug methods in here...
#endif
		#endregion

		#region Properties
		/// <summary>
		/// Returns a boolean value indicating whether or not this object has been disposed.
		/// </summary>
		public bool IsDisposed
		{
			get
			{
				return m_bDisposed;
			}
		}
		/// <summary>
		/// Returns a boolean value indicating whether the GameWindow has finished initializing itself yet or not.
		/// </summary>
		virtual public bool IsInitialized
		{
			get
			{
				return m_bIsInitialized;
			}
		}
		#endregion

		#region Events
		#endregion

		#region Event Handlers
		#endregion
	}

I'm fairly sure the problem is somewhere in this class, but I have no idea what is wrong. I get no evidence that the text renderer class is doing anything at all. It has no effect on the output. And its quite difficult to debug these applications because you either get stupid vague error messages, or other nonsense. I can't use the DirectX Graphics Diagnostics tools in VS2012, because of course they don't support using D2D with DX11. This is quite a nasty big mess Microsoft has made for us...

And here is the shader code being used by the text renderer in case the problem lies there. I've mucked with this a lot too but no luck. I changed the pixel shader to output black no matter what so I could at least see if it is drawing something, but I still get nothing.
cbuffer cbPerResize : register( b0 )
{
matrix Projection;
};
cbuffer cbPerFrame : register( b1 )
{
matrix View;
};
cbuffer cbPerObject : register( b2 )
{
matrix World;
};
//--------------------------------------------------------------------------------------
Texture2D ObjTexture;
SamplerState ObjSamplerState;

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
float2 TexCoord : TEXCOORD;
};

VS_OUTPUT Text_VS(float4 inPos : POSITION, float2 inTexCoord : TEXCOORD)
{
    VS_OUTPUT output = (VS_OUTPUT)0;


matrix identity;
identity[0] = float4(1,0,0,0);
identity[1] = float4(0,1,0,0);
identity[2] = float4(0,0,1,0);
identity[3] = float4(0,0,0,1);

output.Pos = mul(inPos, identity);
/*
    output.Pos = mul( inPos, World );
    output.Pos = mul( output.Pos, View );
    output.Pos = mul( output.Pos, Projection );
*/
output.TexCoord = inTexCoord;
 
    return output;
}
float4 Text_PS(VS_OUTPUT input) : SV_TARGET
{
    //return ObjTexture.Sample( ObjSamplerState, input.TexCoord );
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}


This is just irritating because I've wasted the whole night trying to get this to work and I'm rather tired of microsoft and their bs. It is utterly rediculous that one has to go through all this crap just to get some lousy text on the screen...

Can anyone help me, I hope? And thank you so much for your time!

DirectX11 SDK Tutorial #6 SlimDX Problem

09 November 2012 - 05:59 PM

I've translated the code of DirectX11 SDK tutorial #6 to C# and SlimDX. Unlike the previous tutorials though, I am having a very bizarre problem with this one. Instead of rendering a cube like it should, it just renders large apparently stretched to infinity polygons. Even when I move the Eye and LookAt positions I can't see everything. For example, if I change Y to 100, the polygons seem to be on the same horizontal plane as the Eye and still stretch far off. This output makes no sense whatsoever and after 2 days of screwing with this darn program I still haven't been able to get it to work. Hopefully someone on here might be able to help me solve it.

Here is the code of Program.cs.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SlimDX;
using SlimDX.D3DCompiler;
using SlimDX.Direct3D11;
using Buffer = SlimDX.Direct3D11.Buffer;		// I added this line to fix ambiguity between SlimDX.Direct3D11.Buffer and System.Buffer.  This tells it to use the SlimDX Buffer class rather than the one in the System namespace when I reference the type Buffer.
using SlimDX.DXGI;
using SlimDX.Windows;
using Device = SlimDX.Direct3D11.Device;
using Resource = SlimDX.Direct3D11.Resource;

//--------------------------------------------------------------------------------------
// NOTE:
//--------------------------------------------------------------------------------------
// I modified this program and its shaders.fx file to help with debugging a bug that
// I was having a hell of a time solving. See the note at the top of the shaders.fx
// file for info on changes I made to that file.
//--------------------------------------------------------------------------------------
namespace Test_1
{
	struct SimpleVertex
	{
		Vector3 Position;
		Vector3 Normal;
		Vector4 Color;
		public SimpleVertex(Vector3 position, Vector3 normal, Vector4 color)
		{
			Position = position;
			Normal = normal;
			Color = color;
		}
	};

	struct ConstantBuffer
	{
		public Matrix mWorld;
		public Matrix mView;
		public Matrix mProjection;
		public Vector4[] vLightDir;
		public Vector4[] vLightColor;
		public Vector4 vOutputColor;

		public ConstantBuffer(Matrix world, Matrix view, Matrix projection)
		{
			mWorld = world;
			mView = view;
			mProjection = projection;
			vLightDir = new Vector4[2];
			vLightColor = new Vector4[2];
			vOutputColor = new Vector4();
		}
	};

	static class Program
	{
		static float rotationY = 0.785f;	 // Y Rotation in radians per second   (0.785 radians = 45 degrees)

		static int startTime;
		static int curTime;

		static RenderForm form;
		static Buffer constantBuffer;
		static Buffer indexBuffer;
		static Buffer vertexBuffer;
		static DataStream constants;
		static DataStream indices;
		static DataStream vertices;
		static DepthStencilView depthStencilView;
		static Device device;
		static DeviceContext context;
		static InputLayout layout;
		static PixelShader pixelShader;
		static PixelShader pixelShaderSolid;
		static PixelShader pixelShaderColor;
		static RenderTargetView renderTarget;
		static ShaderSignature inputSignature;
		static SwapChain swapChain;
		static Texture2D depthStencil;
		static VertexShader vertexShader;
		static Viewport viewport;
		static Matrix matrix_World;
		static Matrix matrix_View;
		static Matrix matrix_Projection;


		static void Main()
		{
			form = new RenderForm("OMG a Window!!");
			var description = new SwapChainDescription()
			{
				BufferCount = 2,
				Usage = Usage.RenderTargetOutput,
				OutputHandle = form.Handle,
				IsWindowed = true,
				ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
				SampleDescription = new SampleDescription(1, 0),
				Flags = SwapChainFlags.AllowModeSwitch,
				SwapEffect = SwapEffect.Discard
			};

			Device.CreateWithSwapChain(DriverType.Hardware,
									   DeviceCreationFlags.Debug,
									   description,
									   out device,
									   out swapChain);

			// create a view of our render target, which is the backbuffer of the swap chain we just created
			using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
			{
				renderTarget = new RenderTargetView(device, resource);
			};

			// Create the depth stencil texture
			Texture2DDescription depthStencilDesc = new Texture2DDescription();
			depthStencilDesc.Width = form.ClientSize.Width;
			depthStencilDesc.Height = form.ClientSize.Height;
			depthStencilDesc.MipLevels = 1;
			depthStencilDesc.ArraySize = 1;
			depthStencilDesc.Format = Format.D24_UNorm_S8_UInt;
			depthStencilDesc.SampleDescription = new SampleDescription(1, 0);
			depthStencilDesc.Usage = ResourceUsage.Default;
			depthStencilDesc.BindFlags = BindFlags.DepthStencil;
			depthStencilDesc.CpuAccessFlags = CpuAccessFlags.None;
			depthStencilDesc.OptionFlags = ResourceOptionFlags.None;
			depthStencil = new Texture2D(device, depthStencilDesc);

			// Create the Depth Stencil View
			DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription();
			depthStencilViewDesc.Format = depthStencilDesc.Format;
			depthStencilViewDesc.Dimension = DepthStencilViewDimension.Texture2D;
			depthStencilViewDesc.MipSlice = 0;
			depthStencilView = new DepthStencilView(device, depthStencil, depthStencilViewDesc);
			// setting a viewport is required if you want to actually see anything
			context = device.ImmediateContext;
			viewport = new Viewport(0.0f,
									0.0f,
									form.ClientSize.Width,
									form.ClientSize.Height,
									0.0f,
									1.0f);
			context.OutputMerger.SetTargets(depthStencilView, renderTarget);
			context.Rasterizer.SetViewports(viewport);

			// Setup our shaders
			InitShaders();

			// Setup our vertex data
			InitVertexData();

			// Setup our matrices
			InitMatrices();

			// Set the shaders
			context.VertexShader.Set(vertexShader);
			context.PixelShader.Set(pixelShader);

			// Prevent DXGI handling of Alt+Enter, which doesn't work properly with Winforms
			using (var factory = swapChain.GetParent<Factory>())
			{
				factory.SetWindowAssociation(form.Handle,
											 WindowAssociationFlags.IgnoreAltEnter);
			};

			// Handle Alt+Enter ourselves
			form.KeyDown += (o, e) =>
			{
				if (e.Alt && e.KeyCode == Keys.Enter)
				{
					swapChain.IsFullScreen = !swapChain.IsFullScreen;
				}
			};

			// Handle form size changes
			form.UserResized += (o, e) =>
			{
				renderTarget.Dispose();
				depthStencil.Dispose();
				depthStencilView.Dispose();

				swapChain.ResizeBuffers(2,
										0,
										0,
										Format.R8G8B8A8_UNorm,
										SwapChainFlags.AllowModeSwitch);

				using (var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
				{
					renderTarget = new RenderTargetView(device, resource);
				}

				depthStencilDesc.Width = form.ClientSize.Width;
				depthStencilDesc.Height = form.ClientSize.Height;
				depthStencil = new Texture2D(device, depthStencilDesc);
				depthStencilView = new DepthStencilView(device, depthStencil, depthStencilViewDesc);

				context.OutputMerger.SetTargets(depthStencilView, renderTarget);
				context.Rasterizer.SetViewports(new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height, 0.0f, 1.0f));
			};
			startTime = Environment.TickCount;
			MessagePump.Run(form, RenderFrame);


			// Clean up all resources
			// anything we missed will show up in the IDE's debug output
			vertices.Close();
			vertexBuffer.Dispose();
			layout.Dispose();
			inputSignature.Dispose();
			vertexShader.Dispose();
			pixelShader.Dispose();
			renderTarget.Dispose();
			swapChain.Dispose();
			device.Dispose();
			indexBuffer.Dispose();
			indices.Dispose();
			constantBuffer.Dispose();
			constants.Dispose();
			depthStencil.Dispose();
			depthStencilView.Dispose();
			pixelShaderSolid.Dispose();
			pixelShaderColor.Dispose();
		}

		static void InitShaders()
		{
			// load and compile the vertex shader
			string vsCompileError = "Vertex Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.CompileFromFile("shaders.fx", "VS", "vs_4_0", ShaderFlags.EnableStrictness | ShaderFlags.Debug, EffectFlags.None, null, null, out vsCompileError))
			{
				inputSignature = ShaderSignature.GetInputSignature(bytecode);
				vertexShader = new VertexShader(device, bytecode);
			}

			// load and compile the pixel shader
			string psCompileError = "Pixel Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.CompileFromFile("shaders.fx", "PS", "ps_4_0", ShaderFlags.EnableStrictness | ShaderFlags.Debug, EffectFlags.None, null, null, out psCompileError))
			{
				pixelShader = new PixelShader(device, bytecode);
			}
			// load and compile the solid pixel shader
			psCompileError = "Solid Pixel Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.CompileFromFile("shaders.fx", "PSSolid", "ps_4_0", ShaderFlags.EnableStrictness | ShaderFlags.Debug, EffectFlags.None, null, null, out psCompileError))
			{
				pixelShaderSolid = new PixelShader(device, bytecode);
			}
			// load and compile the color pixel shader
			psCompileError = "Color Pixel Shader Compile Error!!!";
			using (var bytecode = ShaderBytecode.CompileFromFile("shaders.fx", "PSColor", "ps_4_0", ShaderFlags.EnableStrictness | ShaderFlags.Debug, EffectFlags.None, null, null, out psCompileError))
			{
				pixelShaderColor = new PixelShader(device, bytecode);
			}
		}
		static void InitMatrices()
		{
			// world matrix	  
			matrix_World = Matrix.Identity;
			// view matrix
			Vector3 vEye = new Vector3(0.0f, 4.0f, -10.0f);
			Vector3 vLookAt = new Vector3(0.0f, 1.0f, 0.0f);
			Vector3 vUp = new Vector3(0.0f, 1.0f, 0.0f);
			matrix_View = Matrix.LookAtLH(vEye,
										  vLookAt,
										  vUp);

			// projection matrix
			matrix_Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4,  // Vertical Field of View
														(float)form.ClientSize.Width / (float)form.ClientSize.Height,  // Aspect Ratio
														0.01f,  // Near Z
														100.0f);  // Far Z

			// Write the matrices we just generated into the DataStream
			ConstantBuffer cb = new ConstantBuffer(Matrix.Transpose(matrix_World),
												   Matrix.Transpose(matrix_View),
												   Matrix.Transpose(matrix_Projection));
			constants = new DataStream(Marshal.SizeOf(cb), true, true);
			constants.Write<ConstantBuffer>(cb);
			constants.Position = 0;

			// Create the constant buffer
			constantBuffer = new Buffer(device,
										constants,
										(int)constants.Length,
										ResourceUsage.Default,
										BindFlags.ConstantBuffer,
										CpuAccessFlags.None,
										ResourceOptionFlags.None,
										0);
			context.UpdateSubresource(new DataBox(0, 0, constants),
									  constantBuffer,
									  0);
			context.VertexShader.SetConstantBuffer(constantBuffer, 0);
		}
		static void InitVertexData()
		{
			// Create test vertex data, making sure to rewind the stream afterward.
			vertices = new DataStream(Marshal.SizeOf(new SimpleVertex(Vector3.Zero, Vector3.Zero, Vector4.Zero)) * 24, true, true);
			SimpleVertex[] tempVertexArray =
			{
				new SimpleVertex(new Vector3(-1.0f,  1.0f, -1.0f), new Vector3( 0.0f,  1.0f,  0.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f, -1.0f), new Vector3( 0.0f,  1.0f,  0.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f,  1.0f), new Vector3( 0.0f,  1.0f,  0.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f,  1.0f,  1.0f), new Vector3( 0.0f,  1.0f,  0.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f, -1.0f), new Vector3( 0.0f, -1.0f,  0.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f, -1.0f), new Vector3( 0.0f, -1.0f,  0.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f,  1.0f), new Vector3( 0.0f, -1.0f,  0.0f), new Vector4(1.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f,  1.0f), new Vector3( 0.0f, -1.0f,  0.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f,  1.0f), new Vector3(-1.0f,  0.0f,  0.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f, -1.0f), new Vector3(-1.0f,  0.0f,  0.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f,  1.0f, -1.0f), new Vector3(-1.0f,  0.0f,  0.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f,  1.0f,  1.0f), new Vector3(-1.0f,  0.0f,  0.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f,  1.0f), new Vector3( 1.0f,  0.0f,  0.0f), new Vector4(1.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f, -1.0f), new Vector3( 1.0f,  0.0f,  0.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f, -1.0f), new Vector3( 1.0f,  0.0f,  0.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f,  1.0f), new Vector3( 1.0f,  0.0f,  0.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f, -1.0f), new Vector3( 0.0f,  0.0f, -1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f, -1.0f), new Vector3( 0.0f,  0.0f, -1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f, -1.0f), new Vector3( 0.0f,  0.0f, -1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f,  1.0f, -1.0f), new Vector3( 0.0f,  0.0f, -1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f, -1.0f,  1.0f), new Vector3( 0.0f,  0.0f,  1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f, -1.0f,  1.0f), new Vector3( 0.0f,  0.0f,  1.0f), new Vector4(1.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3( 1.0f,  1.0f,  1.0f), new Vector3( 0.0f,  0.0f,  1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f)),
				new SimpleVertex(new Vector3(-1.0f,  1.0f,  1.0f), new Vector3( 0.0f,  0.0f,  1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)),
			};

			foreach (SimpleVertex vertex in tempVertexArray)
			{
				vertices.Write(vertex);
			}
			vertices.Position = 0;
			// create the vertex layout and vertex buffer
			var elements = new[] { new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, SlimDX.Direct3D11.InputClassification.PerVertexData, 0),
								   new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0, SlimDX.Direct3D11.InputClassification.PerVertexData, 0),
								   new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 24, 0, SlimDX.Direct3D11.InputClassification.PerVertexData, 0)};
			layout = new InputLayout(device,
									 inputSignature,
									 elements);
			vertexBuffer = new Buffer(device,
									  vertices,
									  (int)vertices.Length,
									  ResourceUsage.Default,
									  BindFlags.VertexBuffer,
									  CpuAccessFlags.None,
									  ResourceOptionFlags.None,
									  0);
			// Setup the test index data, making sure to rewind the stream afterward.
			UInt16[] indicesList = { 3, 1, 0,
									 2, 1, 3,
									 6, 4, 5,
									 7, 4, 6,
									 11, 9, 8,
									 10, 9, 11,
									 14, 12, 13,
									 15, 12, 14,
									 19, 17, 16,
									 18, 17, 19,
									 22, 20, 21,
									 23, 20, 22
								   };
			// As you can see in the indices list above, we have 36 values total, each of which
			// is a UInt16 value (or 2-byte short integer)
			indices = new DataStream(36 * 2, true, true);
			foreach (UInt16 index in indicesList)
			{
				indices.Write(index);
			}
			indices.Position = 0;
			// Now create the index buffer.
			indexBuffer = new Buffer(device,
									 indices,
									 (int)indices.Length,
									 ResourceUsage.Default,
									 BindFlags.IndexBuffer,
									 CpuAccessFlags.None,
									 ResourceOptionFlags.None,
									 0);

			// Configure the Input Assembler portion of the graphics pipeline with the vertex data.
			context.InputAssembler.InputLayout = layout;
			context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
			context.InputAssembler.SetVertexBuffers(0,
													new VertexBufferBinding(vertexBuffer, 40, 0));
			context.InputAssembler.SetIndexBuffer(indexBuffer,
												  Format.R16_UInt,
												  0);
		}

		static void RenderFrame()
		{
			curTime = Environment.TickCount;
			float t = (curTime - startTime) / 1000.0f;   // Calculate elapsed time since start in seconds

			// 1st Cube: Rotate around the origin.
			matrix_World = Matrix.RotationY(t * rotationY);
			// Setup our lighting parameters
			Vector4[] vLightDirs =
			{
				new Vector4(-0.577f, 0.577f, -0.577f, 1.0f),
				new Vector4(0.0f, 0.0f, -1.0f, 1.0f)
			};
			Vector4[] vLightColors =
			{
				new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
				new Vector4(0.5f, 0.0f, 0.0f, 1.0f)
			};
			// Rotate the second light around the origin
			Matrix mRotate = Matrix.RotationY(-2.0f * t);
			Vector4 vLightDir = vLightDirs[1];
			vLightDir = Vector4.Transform(vLightDir, mRotate);
			vLightDirs[1] = vLightDir;
			// Clear the render target to a soothing blue
			context.ClearRenderTargetView(renderTarget,
										  new Color4(0.0f, 0.125f, 0.3f, 1.0f));
			// Clear the Depth buffer to 1.0 (max depth)
			context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0);

			// Update the constant buffer variables
			ConstantBuffer cb = new ConstantBuffer(Matrix.Transpose(matrix_World),
												   Matrix.Transpose(matrix_View),
												   Matrix.Transpose(matrix_Projection));
			cb.vLightDir[0] = vLightDirs[0];
			cb.vLightDir[1] = vLightDirs[1];
			cb.vLightColor[0] = vLightColors[0];
			cb.vLightColor[1] = vLightColors[1];
			cb.vOutputColor = new Vector4(0, 0, 0, 0);
			constants.Position = 0;
			constants.Write<ConstantBuffer>(cb);
			constants.Position = 0;
			// Give GPU updated matrices data.
			context.UpdateSubresource(new DataBox(0, 0, constants),
									  constantBuffer,
									  0);

			// Render the cube
			context.VertexShader.Set(vertexShader);
			context.VertexShader.SetConstantBuffer(constantBuffer, 0);
			context.PixelShader.Set(pixelShaderColor);
			context.PixelShader.SetConstantBuffer(constantBuffer, 0);
			context.DrawIndexed(36,
								0,
								0);
			/*
			// Render each light
			for (int m = 0; m < 2; m++)
			{
				Matrix mLight = Matrix.Translation(5.0f * new Vector3(vLightDirs[m].X, vLightDirs[m].Y, vLightDirs[m].Z));
				Matrix mLightScale = Matrix.Scaling(0.2f, 0.2f, 0.2f);
				mLight = mLightScale * mLight;
				// Update the world variable to reflect the current light
				cb.mWorld = Matrix.Transpose(mLight);
				cb.vOutputColor = vLightColors[m];
				constants.Position = 0;
				constants.Write<ConstantBuffer>(cb);
				constants.Position = 0;
				context.UpdateSubresource(new DataBox(0, 0, constants),
										 constantBuffer,
										 0);
				context.PixelShader.Set(pixelShaderSolid);

				context.DrawIndexed(36,
									0,
									0);
			}
			*/
			// Present the frame we just rendered.
			swapChain.Present(0,
							  PresentFlags.None);
		}
	}
}

And here is the code of the shaders.fx file which contains the shaders:
//--------------------------------------------------------------------------------------
// File: Tutorial06.fx
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// NOTE:
//--------------------------------------------------------------------------------------
// I modified this file by adding color to the VS_INPUT and PS_INPUT structs.
// I also added the Pixel Shader from the DirectX11 SDK tutorial 5 program and named
// it as PSColor.  I also added one line in the Vertex Shader to return the vertex
// color in the output so the pixel shader has access to the color.
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
cbuffer ConstantBuffer : register( b0 )
{
matrix World;
matrix View;
matrix Projection;
float4 vLightDir[2];
float4 vLightColor[2];
float4 vOutputColor;
}

//--------------------------------------------------------------------------------------
struct VS_INPUT
{
	float4 Pos : POSITION;
	float3 Norm : NORMAL;
	float4 Color: COLOR;
};
struct PS_INPUT
{
	float4 Pos : SV_POSITION;
	float3 Norm : TEXCOORD0;
	float4 Color: COLOR;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS( VS_INPUT input )
{
	PS_INPUT output = (PS_INPUT)0;
	output.Pos = mul( input.Pos, World );
	output.Pos = mul( output.Pos, View );
	output.Pos = mul( output.Pos, Projection );
	output.Norm = mul( input.Norm, World );
  
// I added this line.
output.Color = input.Color;
	return output;
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input) : SV_Target
{
	float4 finalColor = 0;
  
	//do NdotL lighting for 2 lights
	for(int i=0; i<2; i++)
	{
		finalColor += saturate( dot( (float3)vLightDir[i],input.Norm) * vLightColor[i] );
	}
	finalColor.a = 1;
	return finalColor;
}

//--------------------------------------------------------------------------------------
// PSSolid - render a solid color
//--------------------------------------------------------------------------------------
float4 PSSolid( PS_INPUT input) : SV_Target
{
	return vOutputColor;
}

//--------------------------------------------------------------------------------------
// PSColor - render using vertex colors
//--------------------------------------------------------------------------------------
float4 PSColor( PS_INPUT input) : SV_Target
{
	return input.Color;
}


As you can see, I added the Pixel Shader from tutorial 5 (renamed to PSColor) to the bottom of the shaders.fx file and added a color attribute to the shader input data. I then changed the render code to use this shader instead of the PSSolid pixel shader. And lastly I added the color data from tutorial 5 into the vertex list of this program. I can see where one face ends and the next begins now, but what I'm seeing I can't make any sense out of. The code to render the lights is commented out to see what difference that made. I need to get it to draw a cube for now like it is supposed to. Then I'll go back and uncomment that code to enable the lights again.

Any help would be greatly appreciated. I'm totally stumped here. Posted Image Thanks

PARTNERS