ReactOS 0.4.15-dev-8236-g99f0937
core.c
Go to the documentation of this file.
1#ifdef __REACTOS__
2#include "precomp.h"
3#else
4/*
5 *
6 * Copyright 2002 Raphael Junqueira
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23
24#include "d3dx9_private.h"
25#endif /* __REACTOS__ */
26
28
30{
33
34 void *buffer;
36};
37
39{
41}
42
44{
45 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), ppobj);
46
48 || IsEqualGUID(riid, &IID_ID3DXBuffer))
49 {
50 IUnknown_AddRef(iface);
51 *ppobj = iface;
52 return D3D_OK;
53 }
54
55 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
56
57 return E_NOINTERFACE;
58}
59
61{
64
65 TRACE("%p increasing refcount to %u\n", This, ref);
66
67 return ref;
68}
69
71{
74
75 TRACE("%p decreasing refcount to %u\n", This, ref);
76
77 if (ref == 0)
78 {
79 HeapFree(GetProcessHeap(), 0, This->buffer);
81 }
82
83 return ref;
84}
85
87{
89
90 TRACE("iface %p\n", iface);
91
92 return This->buffer;
93}
94
96{
98
99 TRACE("iface %p\n", iface);
100
101 return This->size;
102}
103
104static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl =
105{
106 /* IUnknown methods */
110 /* ID3DXBuffer methods */
113};
114
116{
117 buffer->ID3DXBuffer_iface.lpVtbl = &ID3DXBufferImpl_Vtbl;
118 buffer->ref = 1;
119 buffer->size = size;
120
122 if (!buffer->buffer)
123 {
124 ERR("Failed to allocate buffer memory\n");
125 return E_OUTOFMEMORY;
126 }
127
128 return D3D_OK;
129}
130
132{
133 struct ID3DXBufferImpl *object;
134 HRESULT hr;
135
136 TRACE("size %u, buffer %p.\n", size, buffer);
137
138 if (!buffer)
139 {
140 WARN("Invalid buffer specified.\n");
141 return D3DERR_INVALIDCALL;
142 }
143
144 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
145 if (!object)
146 return E_OUTOFMEMORY;
147
148 hr = d3dx9_buffer_init(object, size);
149 if (FAILED(hr))
150 {
151 WARN("Failed to initialize buffer, hr %#x.\n", hr);
152 HeapFree(GetProcessHeap(), 0, object);
153 return hr;
154 }
155
156 *buffer = &object->ID3DXBuffer_iface;
157
158 TRACE("Created ID3DXBuffer %p.\n", *buffer);
159
160 return D3D_OK;
161}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
#define D3D_OK
Definition: d3d.h:106
#define D3DERR_INVALIDCALL
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(ID3DXBuffer *iface)
Definition: core.c:95
static ULONG WINAPI ID3DXBufferImpl_AddRef(ID3DXBuffer *iface)
Definition: core.c:60
static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
Definition: core.c:70
static struct ID3DXBufferImpl * impl_from_ID3DXBuffer(ID3DXBuffer *iface)
Definition: core.c:38
static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl
Definition: core.c:104
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:131
static HRESULT d3dx9_buffer_init(struct ID3DXBufferImpl *buffer, DWORD size)
Definition: core.c:115
static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(ID3DXBuffer *iface, REFIID riid, void **ppobj)
Definition: core.c:43
static void *WINAPI ID3DXBufferImpl_GetBufferPointer(ID3DXBuffer *iface)
Definition: core.c:86
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
REFIID riid
Definition: atlbase.h:39
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
void * buffer
Definition: core.c:34
DWORD size
Definition: core.c:35
LONG ref
Definition: core.c:32
ID3DXBuffer ID3DXBuffer_iface
Definition: core.c:31
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364