wordpad: Remove untranslated resources from the Turkish translation.
[wine/testsucceed.git] / dlls / d3dx9_36 / core.c
blob3b63e9e46886c72cc2494c3dfdccd2583bd4cc87
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 "d3dx9_36_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)
36 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
38 if (IsEqualGUID(riid, &IID_IUnknown)
39 || IsEqualGUID(riid, &IID_ID3DXBuffer))
41 IUnknown_AddRef(iface);
42 *ppobj = This;
43 return D3D_OK;
46 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
47 return E_NOINTERFACE;
50 static ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface)
52 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
53 ULONG ref = InterlockedIncrement(&This->ref);
55 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
57 return ref;
60 static ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface)
62 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
63 ULONG ref = InterlockedDecrement(&This->ref);
65 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
67 if (ref == 0)
69 HeapFree(GetProcessHeap(), 0, This->buffer);
70 HeapFree(GetProcessHeap(), 0, This);
72 return ref;
75 /* ID3DXBuffer Interface follow: */
76 static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface)
78 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
79 return This->buffer;
82 static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface)
84 ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
85 return This->bufferSize;
88 const ID3DXBufferVtbl D3DXBuffer_Vtbl =
90 ID3DXBufferImpl_QueryInterface,
91 ID3DXBufferImpl_AddRef,
92 ID3DXBufferImpl_Release,
93 ID3DXBufferImpl_GetBufferPointer,
94 ID3DXBufferImpl_GetBufferSize
97 HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer)
99 ID3DXBufferImpl *object;
101 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXBufferImpl));
102 if (object == NULL)
104 *ppBuffer = NULL;
105 return E_OUTOFMEMORY;
107 object->lpVtbl = &D3DXBuffer_Vtbl;
108 object->ref = 1;
109 object->bufferSize = NumBytes;
110 object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
111 if (object->buffer == NULL)
113 HeapFree(GetProcessHeap(), 0, object);
114 *ppBuffer = NULL;
115 return E_OUTOFMEMORY;
118 *ppBuffer = (LPD3DXBUFFER)object;
119 return D3D_OK;