Archived

This topic is now archived and is closed to further replies.

Electron

Reading Resources?

Recommended Posts

Hi! i''m wondering if there''s a way to store, say a 3d model file as a resource, and at runtime, load the file from the resource? All i know how to use resources is the built-in commands for reading bitmaps (LoadImage and so), but is there a common way of reading the resources as if they were external files? Electron

"Your truth can be changed simply by the way you accept it."


Share this post


Link to post
Share on other sites
D3DXLoadMeshFromXResource
Loads a mesh from a resource.

HRESULT D3DXLoadMeshFromXResource(
HMODULE Module,
LPCTSTR Name,
LPCTSTR Type,
DWORD Options,
LPDIRECT3DDEVICE8 pDevice,
LPD3DXBUFFER* ppAdjacency,
LPD3DXBUFFER* ppMaterials,
DWORD* pNumMaterials,
LPD3DXMESH* ppMesh
);

Parameters
Module
[in] Handle to the module where the resource is located, or NULL for the module associated with the image the operating system used to create the current process.
Name
[in] Pointer to a string that specifies the resource from which to create the mesh.
Type
[in] Specifies the type of resource to load the mesh from.
Options
[in] A combination of one or more flags from the D3DXMESH enumeration, specifying creation options for the mesh.
pDevice
[in] Pointer to an IDirect3DDevice8 interface, the device object associated with the mesh.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh.
ppMaterials
[out] Address of a pointer to an ID3DXBuffer interface. When this method returns, this parameter is filled with an array of D3DXMATERIAL structures, containing information saved in the Microsoft® DirectX® file.
pNumMaterials
[out] Pointer to the number of D3DXMATERIAL structures in the ppMaterials array, when the method returns.
ppMesh
[out] Address of a pointer to an ID3DXMesh interface, representing the loaded mesh.
Return Values
If the function succeeds, the return value is D3D_OK.

If the function fails, the return value can be one of the following values.

D3DERR_INVALIDCALL
E_OUTOFMEMORY


Note All the meshes in the file will be collapsed into one output mesh. If the file contains a frame hierarchy, all the transformations will be applied to the mesh.

Requirements
Header: Declared in D3dx8mesh.h.
Import Library: Use D3dx8.lib.


-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites
Ok, but how do i do if i want to load a CUSTOM file as a resource, i.e, get the raw data stored in the previous file.
Example: i''ve got an ATARI-NOT-KNOWN-SOUND-SYSTEM-FILE, which i want to have as a resource. i''m pretty confident there''s no built-in functions for that =), so i want to access the file in raw format, so i can write the driver or whatever myself.



Electron

"Your truth can be changed simply by the way you accept it."


Share this post


Link to post
Share on other sites
Look up the docs on FindResource/LockResource/LoadResource.

From there you can get a pointer to the resource, and do whatever you want with it (the pointer is to the raw data that makes up the resource).


-Brannon

Share this post


Link to post
Share on other sites
(DUH!)
Well, maybe next time i will atleast try a search on common names of what im looking for... load a resource... LoadResource()


Thank you Brannon!

Electron

"Your truth can be changed simply by the way you accept it."


Share this post


Link to post
Share on other sites