title: DirectX : Nothing is drawn on screen
body: <p>I'm trying to develop a program using DirectX (10) to display on screen.</p>
  
  <p>Thing is, it displays nothing but the color I use to clear the backbuffer.</p>
  
  <p>(I apologize for the quite big chunks of code that follow).</p>
  
  <p>Here is my rendering function : </p>
  
  <pre><code>void DXEngine::renderOneFrame()
  {
      //First, we clear the back buffer
      m_device-&gt;ClearRenderTargetView(m_renderTargetView,D3DXCOLOR(0.0f, 0.125f, 0.3f, 1.0f));
  
      //Then, we clear the depth buffer
      m_device-&gt;ClearDepthStencilView(m_depthStencilView,D3D10_CLEAR_DEPTH,1.0f, 0);
  
      //Update variables
      m_worldVariable-&gt;SetMatrix((float*)&amp;m_world);
      m_viewVariable-&gt;SetMatrix((float*)&amp;m_view);
      m_projectionVariable-&gt;SetMatrix((float*)&amp;m_projection);
  
      //Render the cube 
      D3D10_TECHNIQUE_DESC techDesc;
      m_technique-&gt;GetDesc(&amp;techDesc);
  
      for(UINT pass = 0; pass &lt; techDesc.Passes ; pass++){
  
          m_technique-&gt;GetPassByIndex(pass)-&gt;Apply(0);
          m_device-&gt;DrawIndexed(36,0,0);
      }
  
      m_swapChain-&gt;Present(0,0);
  }
  </code></pre>
  
  <p>It is exactly the same as the 5th tutorial on DirectX10 in the DirectX SDK (June 2010) under the "Samples" folder, except it's encapsulated in an object.</p>
  
  <p>My scene is initialized as follow : </p>
  
  <pre><code>HRESULT DXEngine::initStaticScene()
  {
      HRESULT hr;
  
      //Vertex buffer creation and initialization
      Vertex1Pos1Col vertices [] = 
      {
          { D3DXVECTOR3( -1.0f, 1.0f, -1.0f ), D3DXVECTOR4( 0.0f, 0.0f, 1.0f, 1.0f ) },
          { D3DXVECTOR3( 1.0f, 1.0f, -1.0f ), D3DXVECTOR4( 0.0f, 1.0f, 0.0f, 1.0f ) },
          { D3DXVECTOR3( 1.0f, 1.0f, 1.0f ), D3DXVECTOR4( 0.0f, 1.0f, 1.0f, 1.0f ) },
          { D3DXVECTOR3( -1.0f, 1.0f, 1.0f ), D3DXVECTOR4( 1.0f, 0.0f, 0.0f, 1.0f ) },
          { D3DXVECTOR3( -1.0f, -1.0f, -1.0f ), D3DXVECTOR4( 1.0f, 0.0f, 1.0f, 1.0f ) },
          { D3DXVECTOR3( 1.0f, -1.0f, -1.0f ), D3DXVECTOR4( 1.0f, 1.0f, 0.0f, 1.0f ) },
          { D3DXVECTOR3( 1.0f, -1.0f, 1.0f ), D3DXVECTOR4( 1.0f, 1.0f, 1.0f, 1.0f ) },
          { D3DXVECTOR3( -1.0f, -1.0f, 1.0f ), D3DXVECTOR4( 0.0f, 0.0f, 0.0f, 1.0f ) },
      };
  
  
      D3D10_BUFFER_DESC desc;
      desc.Usage = D3D10_USAGE_DEFAULT;
      desc.ByteWidth = sizeof(Vertex1Pos1Col) * 8;
      desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
      desc.CPUAccessFlags = 0;
      desc.MiscFlags = 0;
  
      D3D10_SUBRESOURCE_DATA data;
      data.pSysMem = vertices;
      hr = m_device-&gt;CreateBuffer(&amp;desc,&amp;data,&amp;m_vertexBuffer);
  
      if(FAILED(hr)){
          MessageBox(NULL,TEXT("Vertex buffer creation failed"), TEXT("Error"),MB_OK);
          return hr;
      }
  
      UINT stride = sizeof(Vertex1Pos1Col);
      UINT offset = 0;
      m_device-&gt;IASetVertexBuffers(0,1,&amp;m_vertexBuffer,&amp;stride,&amp;offset);
  
      //Index buffer creation and initialization
      DWORD indices[] = 
      {
          3,1,0,
          2,1,3,
  
          0,5,4,
          1,5,0,
  
          3,4,7,
          0,4,3,
  
          1,6,5,
          2,6,1,
  
          2,7,6,
          3,7,2,
  
          6,4,5,
          7,4,6,
      };
  
      desc.Usage = D3D10_USAGE_DEFAULT;
      desc.ByteWidth = sizeof(DWORD) * 36;
      desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
      desc.CPUAccessFlags = 0;
      desc.MiscFlags = 0;
      data.pSysMem = vertices;
      hr = m_device-&gt;CreateBuffer(&amp;desc,&amp;data,&amp;m_indexBuffer);
  
      if(FAILED(hr)){
          MessageBox(NULL,TEXT("Index buffer creation failed"), TEXT("Error"),MB_OK);
          return hr;
      }
  
  
      m_device-&gt;IASetIndexBuffer(m_indexBuffer,DXGI_FORMAT_R32_FLOAT,0);
  
      //Set the primitive topology, i.e. how indices should be interpreted (here, as a triangle list)
      m_device-&gt;IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
  
      D3DXMatrixIdentity(&amp;m_world);
  
      D3DXVECTOR3 eye(0.0f, 1.0f, -10.0f);
      D3DXVECTOR3 at(0.0f, 1.0f, 0.0f);
      D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
  
      D3DXMatrixLookAtLH(&amp;m_view, &amp;eye, &amp;at, &amp;up);
  
      D3DXMatrixPerspectiveFovLH(&amp;m_projection, (float)D3DX_PI * 0.25f, m_width/(FLOAT)m_height, 0.1f, 100.0f);
  
      return hr;
  }
  </code></pre>
  
  <p>Once again, it's the exact same code (but encapsulated) as the tutorial I mentionned earlier.</p>
  
  <p>When I open the Tutorial Visual Studio Solution in my IDE, it works and displays nicely what is described in the scene, but when I try to run my "encapsulated" version of this code, nothing shows up but the background color...</p>
  
  <p>Note : My windows message pumps works fine, I can even handle user inputs the way I want, everything's fine. My application performs correctly my engine initialization (I check every single returned error code and there's nothing else but <code>S_OK</code> codes).</p>
  
  <p>I have no clue where to search now. I've checked my code times and times again and it's exactly the same as the tutorial, I've checked that everything I encapsulate is set and accessed correctly, etc, but I still can't display anything else than the background color... </p>
  
  <p>I was wondering if anyone here could have an idea of what could possibly cause this, or at least hints on where to look for... </p>
  
  <p>EDIT: Effect file used :</p>
  
  <pre><code>//--------------------------------------------------------------------------------------
  // File: Tutorial05.fx
  //
  // Copyright (c) Microsoft Corporation. All rights reserved.
  //--------------------------------------------------------------------------------------
  
  //--------------------------------------------------------------------------------------
  // Constant Buffer Variables
  //--------------------------------------------------------------------------------------
  matrix World;
  matrix View;
  matrix Projection;
  
  //--------------------------------------------------------------------------------------
  struct VS_INPUT
  {
      float4 Pos : POSITION;
      float4 Color : COLOR;
  };
  
  struct PS_INPUT
  {
      float4 Pos : SV_POSITION;
      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.Color = input.Color;
  
      return output;
  }
  
  
  //--------------------------------------------------------------------------------------
  // Pixel Shader
  //--------------------------------------------------------------------------------------
  float4 PS( PS_INPUT input) : SV_Target
  {
      return input.Color;
  }
  
  
  //--------------------------------------------------------------------------------------
  technique10 Render
  {
      pass P0
      {
          SetVertexShader( CompileShader( vs_4_0, VS() ) );
          SetGeometryShader( NULL );
          SetPixelShader( CompileShader( ps_4_0, PS() ) );
      }
  }
  </code></pre>