d3dx9: Use float instead of long in the spec files for 32-bit floating point values.
[wine] / dlls / d3dx9_36 / tests / effect.c
1 /*
2  * Copyright 2010 Christian Costa
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "wine/test.h"
20 #include "d3dx9.h"
21
22 static const char effect_desc[] =
23 "Technique\n"
24 "{\n"
25 "}\n";
26
27 static void test_create_effect(IDirect3DDevice9* device)
28 {
29     HRESULT hr;
30     ID3DXEffect* effect;
31
32     hr = D3DXCreateEffect(NULL, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL, NULL);
33     ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
34
35     hr = D3DXCreateEffect(device, NULL, 0, NULL, NULL, 0, NULL, NULL, NULL);
36     ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
37
38     hr = D3DXCreateEffect(device, effect_desc, 0, NULL, NULL, 0, NULL, NULL, NULL);
39     ok(hr == E_FAIL, "Got result %x, expected %x (D3DXERR_INVALIDDATA)\n", hr, E_FAIL);
40
41     hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, NULL, NULL);
42     ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
43
44     hr = D3DXCreateEffect(device, effect_desc, sizeof(effect_desc), NULL, NULL, 0, NULL, &effect, NULL);
45     ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
46
47     effect->lpVtbl->Release(effect);
48 }
49
50 static void test_create_effect_pool(void)
51 {
52     HRESULT hr;
53     ID3DXEffectPool* pool;
54
55     hr = D3DXCreateEffectPool(NULL);
56     ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
57
58     hr = D3DXCreateEffectPool(&pool);
59     ok(hr == S_OK, "Got result %x, expected 0 (S_OK)\n", hr);
60
61     pool->lpVtbl->Release(pool);
62 }
63
64 START_TEST(effect)
65 {
66     HWND wnd;
67     IDirect3D9* d3d;
68     IDirect3DDevice9* device;
69     D3DPRESENT_PARAMETERS d3dpp;
70     HRESULT hr;
71
72     wnd = CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
73     d3d = Direct3DCreate9(D3D_SDK_VERSION);
74     if (!wnd) {
75         skip("Couldn't create application window\n");
76         return;
77     }
78     if (!d3d) {
79         skip("Couldn't create IDirect3D9 object\n");
80         DestroyWindow(wnd);
81         return;
82     }
83
84     ZeroMemory(&d3dpp, sizeof(d3dpp));
85     d3dpp.Windowed = TRUE;
86     d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
87     hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &device);
88     if (FAILED(hr)) {
89         skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
90         IDirect3D9_Release(d3d);
91         DestroyWindow(wnd);
92         return;
93     }
94
95     test_create_effect(device);
96     test_create_effect_pool();
97
98     IDirect3DDevice9_Release(device);
99     IDirect3D9_Release(d3d);
100     DestroyWindow(wnd);
101 }