]> git.cworth.org Git - apitrace-tests/blobdiff - apps/d3d10/tri.cpp
Add a shader d3d9 tri test.
[apitrace-tests] / apps / d3d10 / tri.cpp
index 737d27d589a4d37c08d3d58a8831a1318cabcba3..18213427e5a8df6154cd7fd538e482350aaeddb0 100644 (file)
 
 #include <d3d10.h>
 
-#include "tri_vs.h"
-#include "tri_ps.h"
+#include "tri_vs_4_0.h"
+#include "tri_ps_4_0.h"
 
 
 static IDXGISwapChain* g_pSwapChain = NULL;
 static ID3D10Device * g_pDevice = NULL;
 
 
-int main(int argc, char *argv[]){
+int
+main(int argc, char *argv[])
+{
     HRESULT hr;
 
     HINSTANCE hInstance = GetModuleHandle(NULL);
@@ -88,6 +90,11 @@ int main(int argc, char *argv[]){
 
     ShowWindow(hWnd, SW_SHOW);
 
+    UINT Flags = 0;
+    if (LoadLibraryA("d3d10sdklayers")) {
+        Flags |= D3D10_CREATE_DEVICE_DEBUG;
+    }
+
     DXGI_SWAP_CHAIN_DESC SwapChainDesc;
     ZeroMemory(&SwapChainDesc, sizeof SwapChainDesc);
     SwapChainDesc.BufferDesc.Width = WindowWidth;
@@ -105,7 +112,7 @@ int main(int argc, char *argv[]){
     hr = D3D10CreateDeviceAndSwapChain(NULL,
                                        D3D10_DRIVER_TYPE_HARDWARE,
                                        NULL,
-                                       D3D10_CREATE_DEVICE_DEBUG,
+                                       Flags,
                                        D3D10_SDK_VERSION,
                                        &SwapChainDesc,
                                        &g_pSwapChain,
@@ -120,7 +127,12 @@ int main(int argc, char *argv[]){
     if (FAILED(hr)) {
         return 1;
     }
-    hr = g_pDevice->CreateRenderTargetView(pBackBuffer, NULL, &pRenderTargetView);
+    D3D10_RENDER_TARGET_VIEW_DESC RenderTargetViewDesc;
+    ZeroMemory(&RenderTargetViewDesc, sizeof RenderTargetViewDesc);
+    RenderTargetViewDesc.Format = SwapChainDesc.BufferDesc.Format;
+    RenderTargetViewDesc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
+    RenderTargetViewDesc.Texture2D.MipSlice = 0;
+    hr = g_pDevice->CreateRenderTargetView(pBackBuffer, &RenderTargetViewDesc, &pRenderTargetView);
     if (FAILED(hr)) {
         return 1;
     }
@@ -211,8 +223,12 @@ int main(int argc, char *argv[]){
     RasterizerDesc.CullMode = D3D10_CULL_NONE;
     RasterizerDesc.FillMode = D3D10_FILL_SOLID;
     RasterizerDesc.FrontCounterClockwise = true;
+    RasterizerDesc.DepthClipEnable = true;
     ID3D10RasterizerState* pRasterizerState = NULL;
-    g_pDevice->CreateRasterizerState(&RasterizerDesc, &pRasterizerState);
+    hr = g_pDevice->CreateRasterizerState(&RasterizerDesc, &pRasterizerState);
+    if (FAILED(hr)) {
+        return 1;
+    }
     g_pDevice->RSSetState(pRasterizerState);
 
     g_pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);