d3d9: Introduce a separate function for vertex declaration creation.

This commit is contained in:
Henri Verbeet 2012-04-11 22:52:02 +02:00 committed by Alexandre Julliard
parent 0fccc41c3f
commit ba67df7a60
3 changed files with 34 additions and 22 deletions

View File

@ -395,8 +395,8 @@ typedef struct IDirect3DVertexDeclaration9Impl {
} IDirect3DVertexDeclaration9Impl;
void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface) DECLSPEC_HIDDEN;
HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
IDirect3DDevice9Impl *device, const D3DVERTEXELEMENT9 *elements) DECLSPEC_HIDDEN;
HRESULT d3d9_vertex_declaration_create(IDirect3DDevice9Impl *device,
const D3DVERTEXELEMENT9 *elements, IDirect3DVertexDeclaration9Impl **declaration) DECLSPEC_HIDDEN;
/* ---------------------- */
/* IDirect3DVertexShader9 */

View File

@ -2073,7 +2073,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(IDirect3DDevice9Ex *i
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevice9Ex *iface,
const D3DVERTEXELEMENT9 *elements, IDirect3DVertexDeclaration9 **declaration)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DDevice9Impl *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DVertexDeclaration9Impl *object;
HRESULT hr;
@ -2085,25 +2085,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(IDirect3DDevi
return D3DERR_INVALIDCALL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate vertex declaration memory.\n");
return E_OUTOFMEMORY;
}
if (SUCCEEDED(hr = d3d9_vertex_declaration_create(device, elements, &object)))
*declaration = (IDirect3DVertexDeclaration9 *)object;
hr = vertexdeclaration_init(object, This, elements);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created vertex declaration %p.\n", object);
*declaration = (IDirect3DVertexDeclaration9 *)object;
return D3D_OK;
return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(IDirect3DDevice9Ex *iface,

View File

@ -367,7 +367,7 @@ static HRESULT convert_to_wined3d_declaration(const D3DVERTEXELEMENT9 *d3d9_elem
return D3D_OK;
}
HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
static HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
IDirect3DDevice9Impl *device, const D3DVERTEXELEMENT9 *elements)
{
struct wined3d_vertex_element *wined3d_elements;
@ -413,3 +413,30 @@ HRESULT vertexdeclaration_init(IDirect3DVertexDeclaration9Impl *declaration,
return D3D_OK;
}
HRESULT d3d9_vertex_declaration_create(IDirect3DDevice9Impl *device,
const D3DVERTEXELEMENT9 *elements, IDirect3DVertexDeclaration9Impl **declaration)
{
IDirect3DVertexDeclaration9Impl *object;
HRESULT hr;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
ERR("Failed to allocate vertex declaration memory.\n");
return E_OUTOFMEMORY;
}
hr = vertexdeclaration_init(object, device, elements);
if (FAILED(hr))
{
WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created vertex declaration %p.\n", object);
*declaration = object;
return D3D_OK;
}