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
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);
44 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
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);
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);
64 HeapFree(GetProcessHeap(), 0, This->buffer);
65 HeapFree(GetProcessHeap(), 0, This);
70 /* ID3DXBuffer Interface follow: */
71 static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
72 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
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));
98 object->lpVtbl = &D3DXBuffer_Vtbl;
100 object->bufferSize = NumBytes;
101 object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
102 if (NULL == object->buffer) {
103 HeapFree(GetProcessHeap(), 0, object);
105 return E_OUTOFMEMORY;
107 *ppBuffer = (LPD3DXBUFFER)object;
111 HRESULT WINAPI D3DXAssembleShader(LPCVOID pSrcData, UINT SrcDataLen, DWORD Flags,
112 LPD3DXBUFFER* ppConstants,
113 LPD3DXBUFFER* ppCompiledShader,
114 LPD3DXBUFFER* ppCompilationErrors) {
115 FIXME("(void): stub\n");
119 HRESULT WINAPI D3DXAssembleShaderFromFileA(LPCSTR pSrcFile, DWORD Flags,
120 LPD3DXBUFFER* ppConstants,
121 LPD3DXBUFFER* ppCompiledShader,
122 LPD3DXBUFFER* ppCompilationErrors) {
123 LPWSTR pSrcFileW = NULL;
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 );
137 HRESULT WINAPI D3DXAssembleShaderFromFileW(LPCWSTR pSrcFile, DWORD Flags,
138 LPD3DXBUFFER* ppConstants,
139 LPD3DXBUFFER* ppCompiledShader,
140 LPD3DXBUFFER* ppCompilationErrors) {
141 FIXME("(void): stub\n");
145 HRESULT WINAPI D3DXCreateFont(LPDIRECT3DDEVICE8 pDevice, HFONT hFont, LPD3DXFONT* ppFont) {
146 FIXME("(void): stub\n");