Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
db0ad52b
Commit
db0ad52b
authored
Mar 26, 2012
by
Christian Costa
Committed by
Alexandre Julliard
Mar 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3drm: Move mesh loading code into a separate function so it can be shared.
parent
e3c78137
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
102 deletions
+131
-102
d3drm_private.h
dlls/d3drm/d3drm_private.h
+11
-0
meshbuilder.c
dlls/d3drm/meshbuilder.c
+120
-102
No files found.
dlls/d3drm/d3drm_private.h
View file @
db0ad52b
...
...
@@ -22,6 +22,7 @@
#define __D3DRM_PRIVATE_INCLUDED__
#include "d3drm.h"
#include "dxfile.h"
HRESULT
Direct3DRM_create
(
IUnknown
**
ppObj
)
DECLSPEC_HIDDEN
;
HRESULT
Direct3DRMDevice_create
(
REFIID
riid
,
IUnknown
**
ppObj
)
DECLSPEC_HIDDEN
;
...
...
@@ -29,4 +30,14 @@ HRESULT Direct3DRMFrame_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN;
HRESULT
Direct3DRMMeshBuilder_create
(
REFIID
riid
,
IUnknown
**
ppObj
)
DECLSPEC_HIDDEN
;
HRESULT
Direct3DRMViewport_create
(
REFIID
riid
,
IUnknown
**
ppObj
)
DECLSPEC_HIDDEN
;
HRESULT
load_mesh_data
(
IDirect3DRMMeshBuilder3
*
iface
,
LPDIRECTXFILEDATA
pData
)
DECLSPEC_HIDDEN
;
typedef
struct
{
WORD
major
;
WORD
minor
;
DWORD
flags
;
}
Header
;
extern
char
templates
[];
#endif
/* __D3DRM_PRIVATE_INCLUDED__ */
dlls/d3drm/meshbuilder.c
View file @
db0ad52b
...
...
@@ -52,13 +52,7 @@ typedef struct {
Coords2d
*
pCoords2d
;
}
IDirect3DRMMeshBuilderImpl
;
typedef
struct
{
WORD
major
;
WORD
minor
;
DWORD
flags
;
}
Header
;
static
char
templates
[]
=
{
char
templates
[]
=
{
"xof 0302txt 0064"
"template Header"
"{"
...
...
@@ -1025,22 +1019,13 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBu
return
E_NOTIMPL
;
}
/*** IDirect3DRMMeshBuilder3 methods ***/
static
HRESULT
WINAPI
IDirect3DRMMeshBuilder3Impl_Load
(
IDirect3DRMMeshBuilder3
*
iface
,
LPVOID
filename
,
LPVOID
name
,
D3DRMLOADOPTIONS
loadflags
,
D3DRMLOADTEXTURE3CALLBACK
cb
,
LPVOID
arg
)
HRESULT
load_mesh_data
(
IDirect3DRMMeshBuilder3
*
iface
,
LPDIRECTXFILEDATA
pData
)
{
IDirect3DRMMeshBuilderImpl
*
This
=
impl_from_IDirect3DRMMeshBuilder3
(
iface
);
DXFILELOADOPTIONS
load_options
;
LPDIRECTXFILE
pDXFile
=
NULL
;
LPDIRECTXFILEENUMOBJECT
pEnumObject
=
NULL
;
LPDIRECTXFILEDATA
pData
=
NULL
;
LPDIRECTXFILEOBJECT
pObject
=
NULL
;
LPDIRECTXFILEDATA
pData2
=
NULL
;
const
GUID
*
pGuid
;
DWORD
size
;
Header
*
pHeader
;
LPBYTE
ptr
;
HRESULT
hr
;
HRESULT
ret
=
D3DRMERR_BADOBJECT
;
...
...
@@ -1053,90 +1038,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3*
DWORD
faces_data_size
=
0
;
DWORD
i
;
TRACE
(
"(%p)->(%p,%p,%x,%p,%p)
\n
"
,
This
,
filename
,
name
,
loadflags
,
cb
,
arg
);
/* First free allocated buffers of previous mesh data */
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pVertices
);
This
->
pVertices
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pNormals
);
This
->
pNormals
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pFaceData
);
This
->
pFaceData
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pCoords2d
);
This
->
pCoords2d
=
NULL
;
if
(
loadflags
==
D3DRMLOAD_FROMMEMORY
)
{
load_options
=
DXFILELOAD_FROMMEMORY
;
}
else
{
FIXME
(
"Load options %d not supported yet
\n
"
,
loadflags
);
return
E_NOTIMPL
;
}
hr
=
DirectXFileCreate
(
&
pDXFile
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFile_RegisterTemplates
(
pDXFile
,
templates
,
strlen
(
templates
));
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFile_CreateEnumObject
(
pDXFile
,
filename
,
load_options
,
&
pEnumObject
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFileEnumObject_GetNextDataObject
(
pEnumObject
,
&
pData
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFileData_GetType
(
pData
,
&
pGuid
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
TRACE
(
"Found object type whose GUID = %s
\n
"
,
debugstr_guid
(
pGuid
));
if
(
!
IsEqualGUID
(
pGuid
,
&
TID_DXFILEHeader
))
{
ret
=
D3DRMERR_BADFILE
;
goto
end
;
}
hr
=
IDirectXFileData_GetData
(
pData
,
NULL
,
&
size
,
(
void
**
)
&
pHeader
);
if
((
hr
!=
DXFILE_OK
)
||
(
size
!=
sizeof
(
Header
)))
goto
end
;
TRACE
(
"Version is %d %d %d
\n
"
,
pHeader
->
major
,
pHeader
->
minor
,
pHeader
->
flags
);
/* Version must be 1.0.x */
if
((
pHeader
->
major
!=
1
)
||
(
pHeader
->
minor
!=
0
))
{
ret
=
D3DRMERR_BADFILE
;
goto
end
;
}
IDirectXFileData_Release
(
pData
);
pData
=
NULL
;
hr
=
IDirectXFileEnumObject_GetNextDataObject
(
pEnumObject
,
&
pData
);
if
(
hr
!=
DXFILE_OK
)
{
ret
=
D3DRMERR_NOTFOUND
;
goto
end
;
}
hr
=
IDirectXFileData_GetType
(
pData
,
&
pGuid
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
TRACE
(
"Found object type whose GUID = %s
\n
"
,
debugstr_guid
(
pGuid
));
if
(
!
IsEqualGUID
(
pGuid
,
&
TID_D3DRMMesh
))
{
ret
=
D3DRMERR_NOTFOUND
;
goto
end
;
}
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
pData
);
hr
=
IDirectXFileData_GetData
(
pData
,
NULL
,
&
size
,
(
void
**
)
&
ptr
);
if
(
hr
!=
DXFILE_OK
)
...
...
@@ -1170,7 +1072,7 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3*
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFileObject_QueryInterface
(
pObject
,
&
IID_IDirectXFileData
,
(
void
**
)
&
pData2
);
hr
=
IDirectXFileObject_QueryInterface
(
pObject
,
&
IID_IDirectXFileData
,
(
void
**
)
&
pData2
);
IDirectXFileObject_Release
(
pObject
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
...
...
@@ -1285,11 +1187,127 @@ static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3*
}
}
TRACE
(
"Mesh data loaded successfully
\n
"
);
ret
=
D3DRM_OK
;
end:
HeapFree
(
GetProcessHeap
(),
0
,
faces_normal_idx_data
);
HeapFree
(
GetProcessHeap
(),
0
,
faces_vertex_idx_data
);
return
ret
;
}
/*** IDirect3DRMMeshBuilder3 methods ***/
static
HRESULT
WINAPI
IDirect3DRMMeshBuilder3Impl_Load
(
IDirect3DRMMeshBuilder3
*
iface
,
LPVOID
filename
,
LPVOID
name
,
D3DRMLOADOPTIONS
loadflags
,
D3DRMLOADTEXTURE3CALLBACK
cb
,
LPVOID
arg
)
{
IDirect3DRMMeshBuilderImpl
*
This
=
impl_from_IDirect3DRMMeshBuilder3
(
iface
);
DXFILELOADOPTIONS
load_options
;
LPDIRECTXFILE
pDXFile
=
NULL
;
LPDIRECTXFILEENUMOBJECT
pEnumObject
=
NULL
;
LPDIRECTXFILEDATA
pData
=
NULL
;
LPDIRECTXFILEDATA
pData2
=
NULL
;
const
GUID
*
pGuid
;
DWORD
size
;
Header
*
pHeader
;
HRESULT
hr
;
HRESULT
ret
=
D3DRMERR_BADOBJECT
;
TRACE
(
"(%p)->(%p,%p,%x,%p,%p)
\n
"
,
This
,
filename
,
name
,
loadflags
,
cb
,
arg
);
/* First free allocated buffers of previous mesh data */
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pVertices
);
This
->
pVertices
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pNormals
);
This
->
pNormals
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pFaceData
);
This
->
pFaceData
=
NULL
;
HeapFree
(
GetProcessHeap
(),
0
,
This
->
pCoords2d
);
This
->
pCoords2d
=
NULL
;
if
(
loadflags
==
D3DRMLOAD_FROMMEMORY
)
{
load_options
=
DXFILELOAD_FROMMEMORY
;
}
else
{
FIXME
(
"Load options %d not supported yet
\n
"
,
loadflags
);
return
E_NOTIMPL
;
}
hr
=
DirectXFileCreate
(
&
pDXFile
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFile_RegisterTemplates
(
pDXFile
,
templates
,
strlen
(
templates
));
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFile_CreateEnumObject
(
pDXFile
,
filename
,
load_options
,
&
pEnumObject
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFileEnumObject_GetNextDataObject
(
pEnumObject
,
&
pData
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
hr
=
IDirectXFileData_GetType
(
pData
,
&
pGuid
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
TRACE
(
"Found object type whose GUID = %s
\n
"
,
debugstr_guid
(
pGuid
));
if
(
!
IsEqualGUID
(
pGuid
,
&
TID_DXFILEHeader
))
{
ret
=
D3DRMERR_BADFILE
;
goto
end
;
}
hr
=
IDirectXFileData_GetData
(
pData
,
NULL
,
&
size
,
(
void
**
)
&
pHeader
);
if
((
hr
!=
DXFILE_OK
)
||
(
size
!=
sizeof
(
Header
)))
goto
end
;
TRACE
(
"Version is %d %d %d
\n
"
,
pHeader
->
major
,
pHeader
->
minor
,
pHeader
->
flags
);
/* Version must be 1.0.x */
if
((
pHeader
->
major
!=
1
)
||
(
pHeader
->
minor
!=
0
))
{
ret
=
D3DRMERR_BADFILE
;
goto
end
;
}
IDirectXFileData_Release
(
pData
);
pData
=
NULL
;
hr
=
IDirectXFileEnumObject_GetNextDataObject
(
pEnumObject
,
&
pData
);
if
(
hr
!=
DXFILE_OK
)
{
ret
=
D3DRMERR_NOTFOUND
;
goto
end
;
}
hr
=
IDirectXFileData_GetType
(
pData
,
&
pGuid
);
if
(
hr
!=
DXFILE_OK
)
goto
end
;
TRACE
(
"Found object type whose GUID = %s
\n
"
,
debugstr_guid
(
pGuid
));
if
(
!
IsEqualGUID
(
pGuid
,
&
TID_D3DRMMesh
))
{
ret
=
D3DRMERR_NOTFOUND
;
goto
end
;
}
hr
=
load_mesh_data
(
iface
,
pData
);
if
(
hr
==
S_OK
)
ret
=
D3DRM_OK
;
end:
if
(
pData2
)
IDirectXFileData_Release
(
pData2
);
if
(
pData
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment