ReactOS 0.4.17-dev-966-gf06eace
core.c
Go to the documentation of this file.
1/*
2 *
3 * Copyright 2002 Raphael Junqueira
4 *
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.
9 *
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.
14 *
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
18 */
19
20
21#include "d3dx9_private.h"
22
24
26{
29
30 void *buffer;
32};
33
35{
37}
38
40{
41 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), ppobj);
42
44 || IsEqualGUID(riid, &IID_ID3DXBuffer))
45 {
46 IUnknown_AddRef(iface);
47 *ppobj = iface;
48 return D3D_OK;
49 }
50
51 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
52
53 return E_NOINTERFACE;
54}
55
57{
60
61 TRACE("%p increasing refcount to %lu.\n", This, ref);
62
63 return ref;
64}
65
67{
70
71 TRACE("%p decreasing refcount to %lu.\n", This, ref);
72
73 if (ref == 0)
74 {
75 free(This->buffer);
76 free(This);
77 }
78
79 return ref;
80}
81
83{
85
86 TRACE("iface %p\n", iface);
87
88 return This->buffer;
89}
90
92{
94
95 TRACE("iface %p\n", iface);
96
97 return This->size;
98}
99
100static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl =
101{
102 /* IUnknown methods */
106 /* ID3DXBuffer methods */
109};
110
112{
113 buffer->ID3DXBuffer_iface.lpVtbl = &ID3DXBufferImpl_Vtbl;
114 buffer->ref = 1;
115 buffer->size = size;
116
117 buffer->buffer = calloc(1, size);
118 if (!buffer->buffer)
119 {
120 ERR("Failed to allocate buffer memory\n");
121 return E_OUTOFMEMORY;
122 }
123
124 return D3D_OK;
125}
126
128{
129 struct ID3DXBufferImpl *object;
130 HRESULT hr;
131
132 TRACE("size %lu, buffer %p.\n", size, buffer);
133
134 if (!buffer)
135 {
136 WARN("Invalid buffer specified.\n");
137 return D3DERR_INVALIDCALL;
138 }
139
140 object = calloc(1, sizeof(*object));
141 if (!object)
142 return E_OUTOFMEMORY;
143
144 hr = d3dx9_buffer_init(object, size);
145 if (FAILED(hr))
146 {
147 WARN("Failed to initialize buffer, hr %#lx.\n", hr);
148 free(object);
149 return hr;
150 }
151
152 *buffer = &object->ID3DXBuffer_iface;
153
154 TRACE("Created ID3DXBuffer %p.\n", *buffer);
155
156 return D3D_OK;
157}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
#define D3D_OK
Definition: d3d.h:106
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(ID3DXBuffer *iface)
Definition: core.c:91
static ULONG WINAPI ID3DXBufferImpl_AddRef(ID3DXBuffer *iface)
Definition: core.c:56
static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
Definition: core.c:66
static struct ID3DXBufferImpl * impl_from_ID3DXBuffer(ID3DXBuffer *iface)
Definition: core.c:34
static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl
Definition: core.c:100
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:127
static HRESULT d3dx9_buffer_init(struct ID3DXBufferImpl *buffer, DWORD size)
Definition: core.c:111
static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(ID3DXBuffer *iface, REFIID riid, void **ppobj)
Definition: core.c:39
static void *WINAPI ID3DXBufferImpl_GetBufferPointer(ID3DXBuffer *iface)
Definition: core.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
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
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
void * buffer
Definition: core.c:30
DWORD size
Definition: core.c:31
LONG ref
Definition: core.c:28
ID3DXBuffer ID3DXBuffer_iface
Definition: core.c:27
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:3479