青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Using the .X File Format(5)

Accessing .X Files

Regardless of the version of DirectX you are using (either DirectX 8 or 9), the methods you use to access .X files are the same. In fact, the interfaces have not changed names between the two newest versions of DirectX (8 and 9), making it possible for you to quickly port your version 8 code to the newer version 9 (and vice versa if you want).

The first step to accessing any .X file is to create an IDirectXFile interface.

Applications use the methods of the IDirectXFile interface to create instances of the IDirectXFileEnumObject and IDirectXFileSaveObject interfaces, and to register templates. Deprecated.

IDirectXFile Members

Method Description
IDirectXFile::CreateEnumObject Creates an enumerator object. Deprecated.
IDirectXFile::CreateSaveObject Creates a save object. Deprecated.
IDirectXFile::RegisterTemplates Registers custom templates. Deprecated.

Remarks

The globally unique identifier (GUID) for the IDirectXFile interface is IID_IDirectXFile.

The IDirectXFile interface is obtained by calling the DirectXFileCreate function.

The LPDIRECTXFILE type is defined as a pointer to this interface.

typedef interface IDirectXFile *LPDIRECTXFILE;

You need to call the DirectXFileCreate function, as shown in the following bit of code:

IDirectXFile *pDXFile = NULL;
HRESULT Result = DirectXFileCreate(&pDXFile);

As you can see from the previous lines of code, the DirectXFileCreate function takes one parameter−the pointer to an IDirectXFile interface. You can quickly determine whether the function has succeeded in creating a valid, IDirectXFile interface by using the SUCCEEDED or FAILED macro on the return code from the DirectXFileCreate call.

Once you've successfully created the IDirectXFile interface, you can optionally register any templates you'll be using (such as the DirectX standard templates) and create an enumeration interface that weeds through the top−level data objects within your .X files.

 

Registering Custom and Standard Templates

To save storage space and improve your data security, the .X interfaces allow you to remove all template definitions from .X files and embed them into your executable. This means that instead of the .X files defining templates, your program has to do it. Don't worry−it's not as difficult as it sounds. As you'll see in a moment, Microsoft has taken the liberty of doing the hard work by defining the standard templates inside a couple include files, making everything as simple as possible.

To register the standard templates (or any template, for that matter) from within your program, you'll need to call upon the IDirectXFile::RegisterTemplates function.

HRESULT IDirectXFile::RegisterTemplates(
  LPVOID pvData, // buffer containing template definitions
  DWORD cbSize); // # of bytes of data

The pvData parameter is merely a data buffer that contains the template definitions in the exact format you'd see in an .X file. For example, you can define a template data buffer like this:

char *Templates = "
"xof 0303txt 0032 \
template CustomTemplate { \
<4c944580−9e9a−11cf−ab43−0120af71e433> \
DWORD Length; \
array DWORD Values[Length]; \
}";

Note Notice that the template definition in Templates uses the backslash character to represent a new line, and that the first line of text is a standard .X file header.

Going back to RegisterTemplates, the cbSize parameter represents the size of the template data buffer, which you can determine in this case by using the strlen of the Templates buffer. Put together, you can register the templates defined in Templates using the following code:

pFile−>RegisterTemplates(Templates, strlen(Templates));

Now let's get back to the topic at hand−registering the standard templates. You've seen RegisterTemplates at work. In order to register the standard templates, you need to include two additional files in your project−rmxftmpl.h and rmxfguid.h. These two files define the template definitions and GUIDs of the standard templates, respectively.

Tip To remember rmxftmpl.h and rmxfguid.h, just remember that rmxf stands for retained mode x−file, tmpl means template, and guid means globally unique identifier.

Inside the rmxftmpl.h file, you'll find the D3DRM_XTEMPLATES template data buffer and the D3DRM_XTEMPLATE_BYTES macro. These are used in the call to RegisterTemplates to register the standard templates, as you can see here:

pFile−>RegisterTemplates(D3DRM_XTEMPLATES,  D3DRM_XTEMPLATE_BYTES);

That's right; just by calling the above bit of code, you have successfully registered the standard templates, and you're ready to move on! A word of advice before you do: Once you begin using the .X format for your own custom templates and data, don't forget that using RegisterTemplates works perfectly for registering your own custom template definitions!

 

Opening an .X File

After you've created an IDirectXFile interface and registered the templates you'll be using, you need to open the .X file and begin enumerating the data objects within it. The process of opening the .X file and creating an enumeration object occurs in one call to the IDirectXFile::CreateEnumObject function.

HRESULT IDirectXfile::CreateEnumObject(
  LPVOID pvSource, // .X filename
  DXFILELOADOPTIONS dwLoadOptions, // Load options
  LPDIRECTXFILEENUMOBJECT* ppEnumObj); // Enum interface

When you call the CreateEnumObject function, specify the file name of the .X file to load as pvSource and the interface you'll be using as ppEnumObj. As for dwLoadOptions, you should specify the value DXFILELOAD_FROMFILE, which tells DirectX to load the file from disk. Other possible values for dwLoadOptions are DXFILELOAD_FROMRESOURCE, DXFILELOAD_FROMMEMORY, and DXFILELOAD_FROMURL. These values tell DirectX to load the .X file from a resource, memory buffer, or network URL, respectively. Yep, that's right−you can load .X files directly over the Internet!

Tip To load an .X file from the Internet using a URL, specify the complete network path in pvSource.To load from a resource or memory location, just specify the resource handle or memory pointer (both cast as LPVOID) in pvSource.

Continue the example and create an enumeration object for the .X file. The following code will create an enumeration object used to parse a file from a disk.

// Filename = filename to load ("test.x" for example)
IDirectXFileEnumObject *pEnum;
pFile−>CreateEnumObject((LPVOID)Filename, DXFILELOAD_FROMFILE, &pEnum);

From the code's comments, you can see that Filename points to a valid file name−in this case, test.x. Once successfully called, the CreateEnumObject gives you a valid enumeration object (only one is required per open .X file), ready to do all your enumeration dirty work.
 

posted on 2008-04-17 18:11 lovedday 閱讀(753) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久久久亚洲综合| 国产日韩欧美精品| 亚洲午夜一区二区三区| 亚洲精品日韩激情在线电影| 亚洲国产成人精品女人久久久| 久久久精品欧美丰满| 久久精品主播| 欧美国产精品久久| 亚洲人成小说网站色在线| 日韩视频免费| 欧美亚洲一区| 久久精品一区二区三区中文字幕| 久久一区二区三区超碰国产精品 | 久久久久久婷| 欧美精品18videos性欧美| 欧美视频日韩| 国产一区清纯| 日韩视频在线观看国产| 午夜精品视频在线观看一区二区| 久久深夜福利免费观看| 亚洲经典在线看| 亚洲宅男天堂在线观看无病毒| 欧美在线啊v| 欧美日韩视频一区二区| 国内精品视频在线播放| 一区二区三区四区精品| 久久久久久999| 日韩一区二区久久| 久久久伊人欧美| 国产精品久久午夜| 亚洲精品自在久久| 久久亚洲春色中文字幕| 99精品欧美一区二区蜜桃免费| 欧美一区二区在线| 欧美日韩麻豆| 亚洲精品美女在线| 久久久久99精品国产片| 一区二区三区国产精品| 久久综合久久综合久久| 国产区亚洲区欧美区| aⅴ色国产欧美| 欧美风情在线| 久久国产精品高清| 国产精品一区二区在线观看| 一区二区高清| 亚洲国产一区视频| 免费不卡中文字幕视频| 黄色欧美日韩| 久久免费偷拍视频| 午夜精品久久久久久| 国产精品成人va在线观看| 亚洲精品资源美女情侣酒店| 欧美国产日产韩国视频| 久久久欧美一区二区| 国产一区久久| 久久久天天操| 欧美一区二区三区日韩视频| 国产精品社区| 国产欧美日韩三级| 亚洲视频专区在线| 最新亚洲电影| 欧美极品在线播放| 亚洲免费av电影| 最新国产拍偷乱拍精品| 免费欧美视频| 亚洲激情影院| 亚洲国产裸拍裸体视频在线观看乱了中文| 久久久久91| 亚洲国产精品成人| 亚洲国产高清自拍| 欧美激情一区二区三级高清视频| 亚洲日韩中文字幕在线播放| 亚洲国产欧美久久| 欧美日本一区二区三区| 亚洲午夜高清视频| 亚洲午夜视频| 韩日精品中文字幕| 欧美jjzz| 欧美国产极速在线| 亚洲午夜在线观看视频在线| 亚洲午夜视频在线| 国内自拍一区| 欧美激情按摩| 欧美日韩色综合| 久久久精品性| 欧美激情亚洲另类| 亚洲一级片在线看| 欧美一区二区视频免费观看 | 欧美视频在线播放| 欧美一区国产一区| 久色婷婷小香蕉久久| 在线中文字幕一区| 久久不见久久见免费视频1| 亚洲激情在线激情| 亚洲性视频网址| 亚洲欧洲视频| 亚洲性图久久| 91久久精品国产| 亚洲一区免费视频| 亚洲人成在线播放| 性感少妇一区| 一区二区日韩精品| 久久久噜噜噜久久久| 亚洲天堂av电影| 久久久亚洲欧洲日产国码αv| 亚洲婷婷综合久久一本伊一区| 欧美在线视频日韩| 亚洲一区二区三区乱码aⅴ| 久久精品亚洲乱码伦伦中文| 一本综合久久| 久久综合色婷婷| 欧美一区国产在线| 欧美日韩精品系列| 亚洲电影观看| 国产综合精品| 亚洲一区3d动漫同人无遮挡| 亚洲欧洲一级| 久久天天狠狠| 久久9热精品视频| 国产精品xxx在线观看www| 亚洲美女av电影| 久久国产免费看| 亚洲欧美一区二区三区久久| 欧美高清视频一区| 蜜桃久久av| 国产一区二区三区网站| 一区二区三区四区五区精品| 亚洲欧洲美洲综合色网| 久久久欧美精品sm网站| 久久在线视频| 好看的日韩视频| 欧美中文字幕| 久久精品在线观看| 国产亚洲一区二区三区在线观看 | 亚洲精品小视频在线观看| 久久亚洲不卡| 欧美99久久| 亚洲国产高清在线| 久久婷婷国产综合精品青草| 久久中文字幕一区二区三区| 国产日产欧产精品推荐色 | 亚洲视频一区在线观看| 亚洲免费视频在线观看| 国产精品激情av在线播放| 一区二区冒白浆视频| 亚洲午夜羞羞片| 国产精品成人免费精品自在线观看| 亚洲精品久久久久久久久久久久久 | 玖玖综合伊人| 亚洲国产欧美一区二区三区久久| 久久乐国产精品| 亚洲大胆在线| 一区二区三区精品国产| 欧美性事免费在线观看| 亚洲女性裸体视频| 久久在线观看视频| 亚洲人成久久| 欧美亚洲成人精品| 欧美一级专区| 亚洲电影激情视频网站| 一区二区欧美亚洲| 国产日韩精品一区二区三区在线 | 国产日本欧美视频| 久久九九国产精品怡红院| 欧美成人综合在线| 99视频有精品| 国产伦精品一区二区三区免费 | 久久精品国产免费| 在线国产亚洲欧美| 欧美理论电影在线播放| 亚洲影音一区| 欧美激情第六页| 亚洲尤物影院| 亚洲大黄网站| 国产精品区二区三区日本| 久久一区二区三区av| 一区二区福利| 麻豆精品视频在线观看| 亚洲在线不卡| 亚洲国产婷婷香蕉久久久久久| 欧美日韩亚洲精品内裤| 久久高清一区| 一区二区高清视频| 欧美~级网站不卡| 午夜国产不卡在线观看视频| 亚洲国产日韩欧美在线图片| 国产精品福利片| 免费观看成人鲁鲁鲁鲁鲁视频| 亚洲午夜激情免费视频| 亚洲国产日韩在线| 久久综合狠狠综合久久综青草| 亚洲视频免费观看| 亚洲高清视频一区| 国产日韩久久| 国产精品久久久久一区二区三区共 | 欧美激情亚洲一区| 久久久精品tv| 欧美在线视频网站| 亚洲午夜精品久久久久久浪潮| 亚洲国产精品123|