push cc8bc80451cc24f4d7cf75168b569f0ebfe19547
[wine/hacks.git] / dlls / d3dx8 / core.c
blobda821fc9d35ce0f9ead2b649a0f04f56da7b52c7
1 /*
3 * Copyright 2002 Raphael Junqueira
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
29 #include "d3dx8_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
33 /* ID3DXBuffer IUnknown parts follow: */
34 static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
35 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
37 if (IsEqualGUID(riid, &IID_IUnknown)
38 || IsEqualGUID(riid, &IID_ID3DXBuffer)) {
39 IUnknown_AddRef(iface);
40 *ppobj = This;
41 return D3D_OK;
44 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
45 return E_NOINTERFACE;
48 static ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
49 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
50 ULONG ref = InterlockedIncrement(&This->ref);
52 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
54 return ref;
57 static ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
58 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
59 ULONG ref = InterlockedDecrement(&This->ref);
61 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
63 if (ref == 0) {
64 HeapFree(GetProcessHeap(), 0, This->buffer);
65 HeapFree(GetProcessHeap(), 0, This);
67 return ref;
70 /* ID3DXBuffer Interface follow: */
71 static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
72 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
73 return This->buffer;
76 static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
77 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
78 return This->bufferSize;
81 const ID3DXBufferVtbl D3DXBuffer_Vtbl =
83 ID3DXBufferImpl_QueryInterface,
84 ID3DXBufferImpl_AddRef,
85 ID3DXBufferImpl_Release,
86 ID3DXBufferImpl_GetBufferPointer,
87 ID3DXBufferImpl_GetBufferSize
90 HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer) {
91 ID3DXBufferImpl *object;
93 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXBufferImpl));
94 if (NULL == object) {
95 *ppBuffer = NULL;
96 return E_OUTOFMEMORY;
98 object->lpVtbl = &D3DXBuffer_Vtbl;
99 object->ref = 1;
100 object->bufferSize = NumBytes;
101 object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
102 if (NULL == object->buffer) {
103 HeapFree(GetProcessHeap(), 0, object);
104 *ppBuffer = NULL;
105 return E_OUTOFMEMORY;
107 *ppBuffer = (LPD3DXBUFFER)object;
108 return D3D_OK;
111 HRESULT WINAPI D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags,
112 LPD3DXBUFFER* ppConstants,
113 LPD3DXBUFFER* ppCompiledShader,
114 LPD3DXBUFFER* ppCompilationErrors) {
115 FIXME("(void): stub\n");
116 return D3D_OK;
119 HRESULT WINAPI D3DXAssembleShaderFromFileA(LPCSTR pSrcFile, DWORD Flags,
120 LPD3DXBUFFER* ppConstants,
121 LPD3DXBUFFER* ppCompiledShader,
122 LPD3DXBUFFER* ppCompilationErrors) {
123 LPWSTR pSrcFileW = NULL;
124 DWORD len;
125 HRESULT ret;
127 if (!pSrcFile) return D3DXERR_INVALIDDATA;
129 len = MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, NULL, 0 );
130 pSrcFileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
131 MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, pSrcFileW, len );
132 ret=D3DXAssembleShaderFromFileW(pSrcFileW, Flags, ppConstants, ppCompiledShader, ppCompilationErrors);
133 HeapFree( GetProcessHeap(), 0, pSrcFileW );
134 return ret;
137 HRESULT WINAPI D3DXAssembleShaderFromFileW(LPCWSTR pSrcFile, DWORD Flags,
138 LPD3DXBUFFER* ppConstants,
139 LPD3DXBUFFER* ppCompiledShader,
140 LPD3DXBUFFER* ppCompilationErrors) {
141 FIXME("(void): stub\n");
142 return D3D_OK;
145 HRESULT WINAPI D3DXCreateFont(LPDIRECT3DDEVICE8 pDevice, HFONT hFont, LPD3DXFONT* ppFont) {
146 FIXME("(void): stub\n");
147 return D3D_OK;