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

天行健 君子當自強而不息

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 閱讀(759) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(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>
            久久av免费一区| 久久久久五月天| 欧美天天在线| 午夜精品短视频| 亚洲一区日韩| 国产伦精品一区二区三区免费| 亚洲视频一区在线| 99在线热播精品免费99热| 欧美精品偷拍| 午夜激情综合网| 久久久久天天天天| 亚洲精品久久久久中文字幕欢迎你| 91久久精品国产91久久性色| 久久中文字幕导航| 日韩亚洲欧美在线观看| 亚洲综合色网站| 亚洲国产精品123| 99视频超级精品| 黄色欧美日韩| 亚洲人屁股眼子交8| 国产精品久久久久久久第一福利 | 午夜精品视频网站| 国精产品99永久一区一区| 欧美国产精品| 国产精品午夜国产小视频| 噜噜噜91成人网| 欧美午夜不卡在线观看免费 | 亚洲神马久久| 国产一区二区成人久久免费影院| 欧美福利精品| 国产欧美日韩另类视频免费观看| 美女免费视频一区| 国产精品久久久久7777婷婷| 蜜桃视频一区| 国产精品第13页| 欧美激情1区2区3区| 国产精品美女久久久| 亚洲成人直播| 国产综合久久久久久鬼色| 亚洲精品国产精品久久清纯直播 | 国产一区二区三区四区在线观看| 欧美顶级艳妇交换群宴| 国产日韩一区二区三区在线播放| 欧美黄色网络| 好吊色欧美一区二区三区四区| 日韩网站在线| 亚洲精品视频啊美女在线直播| 欧美一区在线看| 亚洲欧美日韩精品久久久| 欧美ed2k| 亚洲成人在线网| 一区二区三区在线不卡| 亚洲欧美亚洲| 午夜精品婷婷| 国产精品美女www爽爽爽视频| 亚洲激情黄色| 亚洲精品黄色| 欧美成人午夜免费视在线看片| 久久综合色88| 精品成人在线| 久久免费99精品久久久久久| 久久精品视频网| 国产一区二区三区精品欧美日韩一区二区三区| 日韩视频免费在线观看| 亚洲美女电影在线| 欧美精品一区二区三区高清aⅴ| 欧美大色视频| 亚洲人成毛片在线播放| 免费久久精品视频| 亚洲国产乱码最新视频| 亚洲电影中文字幕| 久久婷婷国产综合国色天香| 免费日韩av| 亚洲精品小视频在线观看| 欧美阿v一级看视频| 欧美激情bt| 日韩视频免费看| 欧美日韩亚洲一区二区三区在线| 99在线精品免费视频九九视| 亚洲午夜精品久久久久久浪潮| 欧美色图五月天| 亚洲午夜免费视频| 久久久久www| 亚洲精品国产精品乱码不99| 欧美日本中文字幕| 亚洲欧美国产不卡| 美女主播精品视频一二三四| 亚洲精品黄色| 国产精品露脸自拍| 欧美专区中文字幕| 亚洲国产精品一区制服丝袜| 一区二区三区国产盗摄| 国产精品夜夜夜| 久久人人爽国产| 亚洲精品日韩久久| 久久精品五月婷婷| 亚洲人成在线观看一区二区| 欧美日韩在线高清| 久久精选视频| 日韩视频在线播放| 久久这里有精品视频| 亚洲卡通欧美制服中文| 国产精品一二三| 美女视频黄a大片欧美| 艳女tv在线观看国产一区| 久久久美女艺术照精彩视频福利播放| 精品成人a区在线观看| 欧美日韩精品免费观看视频| 欧美一区二区三区四区视频| 亚洲黄色天堂| 久久综合久久综合久久| 亚洲社区在线观看| 在线成人小视频| 国产精品一二一区| 欧美人成在线视频| 久久蜜臀精品av| 亚洲制服av| 日韩亚洲视频在线| 亚洲国产成人av好男人在线观看| 亚洲欧美日韩一区二区在线| 亚洲精品乱码久久久久久蜜桃麻豆| 国产精品一区二区久久久| 欧美另类高清视频在线| 久久精品人人爽| 午夜精品国产| 亚洲影院色无极综合| 99国产一区二区三精品乱码| 欧美aⅴ99久久黑人专区| 久久精品国产一区二区三| 亚洲手机视频| 99视频+国产日韩欧美| 亚洲青色在线| 亚洲人成在线播放| 亚洲国内自拍| 亚洲国产cao| 在线观看视频一区| 黄色在线一区| 黄色日韩网站| 伊人色综合久久天天| 韩国成人理伦片免费播放| 国产伦精品一区二区三区高清版| 欧美丝袜第一区| 欧美午夜视频在线观看| 欧美日韩亚洲激情| 欧美日韩一区成人| 国产精品激情| 国产日韩精品视频一区二区三区| 欧美日韩综合视频| 国产精品美腿一区在线看 | 日韩视频免费观看| 亚洲美女视频网| 一区二区三区精品国产| 99re6热在线精品视频播放速度| 亚洲国产一区二区精品专区| 欧美二区不卡| 夜夜精品视频| 夜夜嗨av一区二区三区中文字幕 | 亚洲男人的天堂在线观看 | 国产一区二区日韩精品欧美精品| 国产欧美一区二区三区久久| 国产亚洲一本大道中文在线| 国产亚洲精品久| 亚洲第一精品电影| 亚洲人成网站777色婷婷| av不卡在线观看| 亚洲一二三级电影| 久久精品国产综合| 狂野欧美激情性xxxx| 免费精品视频| 夜夜嗨av色综合久久久综合网| 日韩视频免费在线观看| 午夜精品久久久久久久| 理论片一区二区在线| 欧美日韩视频免费播放| 国产欧美日韩一区二区三区在线观看 | 蜜臀av性久久久久蜜臀aⅴ| 欧美激情亚洲| 国产精品综合| 亚洲人成人一区二区三区| 亚洲影院色无极综合| 久热爱精品视频线路一| 亚洲精品久久久久中文字幕欢迎你| 亚洲综合二区| 美女日韩在线中文字幕| 国产精品三区www17con| 亚洲国产成人精品视频| 亚洲在线播放电影| 亚洲二区免费| 欧美亚洲综合另类| 欧美三日本三级少妇三99| 伊人天天综合| 欧美一区91| 99re亚洲国产精品| 久久精品网址| 国产精品免费在线| 一区二区三区日韩精品| 欧美高清hd18日本| 欧美一区二区三区视频| 国产精品劲爆视频| 99国内精品|