   SlimDX (D3D 10) , render  texture
  Hi. Im new to SlimDX.What I'm atempting to do is to draw a 2D quad (2 triangles) with a texture.The quad is rendered in the midle of the screen, instead of the whole texture I just get the "general" color of the texture. The texture is a brick wall.The quad looks like this:  /*Positions are given in ndc space    lower left corner would be  : {-1f,-1f,0f}    top right corner would be   : {1f,1f,0f}   */Vector3[] pos = new Vector3[]   { //left triangle, 90 deg corner down the left corner new Vector3(-1.0f, -1.0f, 0.0f), new Vector3(-1.0f,  1.0f, 0.0f), new Vector3(1.0f,  -1.0f, 0.0f), //right triangle, 90 deg corner up the right corner new Vector3(-1.0f, 1.0f, 0.0f), new Vector3(1.0f,  1.0f, 0.0f), new Vector3(1.0f,  -1.0f, 0.0f)    };  Vector2[] uv = new Vector2[]   { new Vector2(0.0f, 1.0f), new Vector2(0.0f, 0.0f), new Vector2(1.0f, 1.0f),  new Vector2(0.0f, 0.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 0.0f),   };The quad is rendered correctly and I belive the UV cordinates to be correct. So I hope that there is some flag I just forgot to set.when I load the texture i just use: m_texture = Texture2D.FromFile(device, fileName);When sending the texture to the shader I checked the VS debugger and it's a valid texture, with the format: Format = R8G8B8A8_UNormI'l also post my very simple shader:/*Author: Rickard HermanssonDescription:Positions will be sent in "NDC(Normalized Device Coordinates) Space"lower left corner would be  : {-1f,-1f,0f}top right corner would be   : {1f,1f,0f}*///Color of everything renderer with this shadercbuffer cbPerFrame{float4 g_color;float4x4 g_textureMatrix;};//this texture will be mixed with the color aboveTexture2D g_colorMap;SamplerState g_triLinearSample{Filter = MIN_MAG_MIP_LINEAR;AddressU = Wrap;AddressV = Wrap;};struct VS_IN{float3 pos : POSITION;float2 uv : TEXCOORD;};struct VS_OUT{float4 pos : SV_POSITION;float2 uv : TEXCOORD;}; VS_OUT VS(VS_IN vIn){VS_OUT vOut;vOut.pos = float4(vIn.pos, 1.0f);vOut.uv  = vIn.uv;return vOut;}float4 PS_Color(VS_OUT pIn) : SV_Target{return g_color;}float4 PS_Texture(VS_OUT pIn) : SV_Target{return g_color *g_colorMap.Sample(g_triLinearSample, pIn.uv);} technique10 TechColor{    pass P0    {   SetVertexShader( CompileShader( vs_4_0, VS() ) );   SetGeometryShader( NULL );   SetPixelShader( CompileShader( ps_4_0, PS_Color() ) );    }}technique10 TechTexture{    pass P0    {   SetVertexShader( CompileShader( vs_4_0, VS() ) );   SetGeometryShader( NULL );   SetPixelShader( CompileShader( ps_4_0, PS_Texture() ) );    }}The Vertex and VertexLayout looks like this: [StructLayout(LayoutKind.Sequential)]    public struct SimpleVertex : IVertex    {   private Vector3 m_position;   private Vector2 m_uv;   public Vector3 Position   {  get { return m_position; }  set { m_position = value; }   }   public Vector2 UV   {  get { return m_uv; }  set { m_uv = value; }   }   public float Size   {  get {return Marshal.SizeOf(typeof(SimpleVertex)); }   }}//Input Elementsnew InputElement("POSITION",0,Format.R32G32B32A32_Float,0,0,InputClassification.PerVertexData,0),new InputElement("TEXCOORD",0,Format.R32G32_Float,0,12,InputClassification.PerVertexData,0),Is there some flag that I need to set to enable texture rendering?   
  Hi, i can see one problem//Input Elementsnew InputElement("POSITION",0,Format.R32G32B32A32_Float,0,0,InputClassification.PerVertexData,0),new InputElement("TEXCOORD",0,Format.R32G32_Float,0,12,InputClassification.PerVertexData,0),you use POSITION R32G32B32A32 = 4 float * 4bytes(perfloat)Then the "int offset in TEXCOORD should be : 16 not 12("TEXCOORD",0,Format.R32G32_Float,0,16,InputClassification.PerVertexData,0),OH !! im a beginner with the InputClassification 12 is int slot .. i  know input element with this parameter Other thing im not sure but you declare Vector4 POSITION and you use VECTOR3   ;  i dont know inputelement with this parameter i mean   ;  You are right, It should be:new InputElement("POSITION",0,Format.R32G32B32_Float,0,0,InputClassification.PerVertexData,0),new InputElement("TEXCOORD",0,Format.R32G32_Float,0,12,InputClassification.PerVertexData,0),Sadly nothing happend when I made the change.   ;  No, there are no flags you need to set in order to enable texturing. However:1. Are you binding the texture to the shader?2. Show your rendering code.   ;  I supose this is a crticial moment:  DataStream stream = new DataStream(vertices.Length * Marshal.SizeOf(typeof(SimpleVertex)), true, true);  foreach (SimpleVertex vertex in vertices)  { stream.Write(vertex.Position); stream.Write(vertex.UV);  }  // rewind the stream so that the buffer constructor reads the right data  stream.Position = 0;  BufferDescription bufferDesc = new BufferDescription();  bufferDesc.BindFlags = BindFlags.VertexBuffer;  // Buffer is used as a vertex buffer  bufferDesc.CpuAccessFlags = CpuAccessFlags.None;  bufferDesc.OptionFlags = ResourceOptionFlags.None;  bufferDesc.SizeInBytes = (int)stream.Length;  bufferDesc.Usage = ResourceUsage.Default;  m_vertexBuffer = new Buffer(device, stream, bufferDesc);  stream.Close();  and the rendering: Quad2D quad = (Quad2D)rendeble;  Quad2DShader shader = (Quad2DShader)quad.Shader;  Device device = shader.Device;    device.InputAssembler.SetInputLayout(shader.InputLayout);  device.InputAssembler.SetPrimitiveTopology(PrimitiveTopology.TriangleList);  device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(quad.Meshes[0].VB, Marshal.SizeOf(typeof(SimpleVertex)), 0));  String techName = "TechColor";  if (quad.Texture != null)  { techName = "TechTexture"; shader.SetTexture(quad.TextureResourceView);  }  EffectTechnique technique = shader.Effect.GetTechniqueByName(techName);  EffectPass pass = technique.GetPassByIndex(0);  shader.SetColor(quad.Color);  shader.SetTextureMatrix(quad.TextureMatrix);  for (int i = 0; i < technique.Description.PassCount; ++i)  { pass.Apply(); device.Draw(quad.Meshes[0].VertexCount, 0);  }Quad2DShader:m_textureVaraible = m_effect.GetVariableByName("g_colorMap").AsResource();ans I set it using: public void SetTexture(ShaderResourceView texture) { m_textureVaraible.SetResource(texture); }//This is valid in the debuggerMeshes is just a class that holds the VertexBuffer and a index buffer thats not used right now   ;  You should take a look at the SlimDX samples, one of them does texturing.   ;Vector2[] uv = new Vector2[] {    new Vector2(0.0f, 1.0f),    new Vector2(0.0f, 0.0f),    new Vector2(1.0f, 1.0f),new Vector2(0.0f, 0.0f),   // <----    new Vector2(1.0f, 0.0f),    new Vector2(0.0f, 0.0f),   // <----};The uv's for your second triangle are definitively degenerate, since you got (0,0) twice.The first one seems ok, though, so I don't know why no texturing occurs. I recommend PIX to actually see whats going on.Hope that helps   