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

天行健 君子當自強而不息

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>
            亚洲国产精品999| 欧美巨乳在线| 亚洲欧美www| 欧美国产日韩视频| 久久国产欧美日韩精品| 欧美视频一区二区三区…| 免费观看成人| 国内精品福利| 亚洲免费综合| 亚洲天堂视频在线观看| 欧美1区2区| 免费视频亚洲| 精品不卡一区| 久久国产视频网| 久久精品亚洲国产奇米99| 国产精品av久久久久久麻豆网| 亚洲国产成人av| 在线高清一区| 久久艳片www.17c.com| 久久嫩草精品久久久精品一| 国产日韩亚洲| 久久国产精品99国产精| 久久久一区二区| 国产自产女人91一区在线观看| 亚洲嫩草精品久久| 午夜伦欧美伦电影理论片| 国产精品久久久久毛片软件| 一个色综合av| 欧美一区亚洲二区| 国产精品一区亚洲| 午夜老司机精品| 久久在线观看视频| 永久久久久久| 欧美成人伊人久久综合网| 亚洲国产成人精品久久久国产成人一区 | 国产农村妇女精品一区二区| 亚洲无人区一区| 欧美一区影院| 精品动漫3d一区二区三区免费版| 久色婷婷小香蕉久久| 欧美大尺度在线| 亚洲看片网站| 国产精品免费观看视频| 亚洲欧美在线免费| 免费看av成人| 一本一本久久a久久精品综合麻豆| 欧美日韩一区二区三区四区在线观看 | 亚洲激情一区| 欧美日韩精品系列| 亚洲欧美国产另类| 老司机午夜精品视频| 亚洲激情视频在线| 欧美色大人视频| 性久久久久久久久久久久| 老司机67194精品线观看| 亚洲精品美女91| 国产精品久久777777毛茸茸| 亚洲综合三区| 欧美激情视频在线免费观看 欧美视频免费一| 亚洲国产裸拍裸体视频在线观看乱了中文 | 久久男人av资源网站| 91久久精品国产91久久| 亚洲欧美日本在线| 韩国在线一区| 欧美视频一区二区三区…| 久久国产乱子精品免费女| 亚洲日本在线观看| 久久久久久夜| 在线午夜精品自拍| 国产夜色精品一区二区av| 欧美国产日韩在线观看| 校园春色综合网| 亚洲人成久久| 久久综合一区二区三区| 亚洲永久免费| 亚洲精品乱码久久久久久黑人| 欧美午夜片在线免费观看| 久久综合久久美利坚合众国| 亚洲一区免费视频| 亚洲日本电影| 免费观看日韩av| 性欧美暴力猛交另类hd| 日韩五码在线| 亚洲电影网站| 国产一区二区三区四区hd| 欧美午夜免费电影| 欧美国产在线视频| 久久久精品久久久久| 亚洲欧美日韩一区| 9色精品在线| 亚洲日本一区二区三区| 欧美成人福利视频| 久久久久99精品国产片| 亚洲在线视频免费观看| 99国产精品久久久久久久| 在线成人av.com| 国产视频在线观看一区| 国产精品任我爽爆在线播放| 欧美日韩国产影片| 欧美成人午夜激情视频| 老牛影视一区二区三区| 久久久久久久国产| 欧美在线免费视频| 午夜精品久久久久久久男人的天堂| 99re6热在线精品视频播放速度| 亚洲国产精品久久91精品| 欧美电影打屁股sp| 欧美成人国产一区二区| 麻豆av福利av久久av| 久久久夜色精品亚洲| 久久一二三区| 久久免费视频在线| 久久久久久久综合日本| 久久久久久久久久久一区| 香蕉尹人综合在线观看| 欧美中文字幕久久| 欧美一区二区三区在| 欧美中文字幕在线| 久久大综合网| 久久久综合网| 美脚丝袜一区二区三区在线观看| 麻豆精品精品国产自在97香蕉| 久久综合九色欧美综合狠狠| 免费成人av在线| 亚洲第一在线视频| 亚洲精品日韩一| 国产精品私拍pans大尺度在线| 午夜在线不卡| 欧美激情按摩在线| 欧美亚洲综合久久| 日韩一级免费| 校园春色综合网| 欧美激情一区二区| 亚洲一区二区精品视频| 免费在线欧美黄色| 亚洲欧美日韩专区| 亚洲在线视频观看| 欧美在线观看你懂的| 亚洲综合好骚| 99国内精品久久久久久久软件| 欧美一区二区三区日韩视频| 99国产一区| 欧美精品日韩一本| 欧美日韩国产在线观看| 欧美电影在线播放| 亚洲高清久久| 久久九九精品99国产精品| 欧美在线看片a免费观看| 99精品国产福利在线观看免费| 嫩草国产精品入口| 久久中文字幕一区| 亚洲丰满在线| 最新中文字幕亚洲| 欧美mv日韩mv国产网站| 亚洲欧洲精品一区二区三区不卡 | 夜夜嗨av一区二区三区网站四季av| 亚洲黄网站在线观看| 久久久成人精品| 亚洲二区免费| 最新中文字幕亚洲| 久久综合亚州| 亚洲国产精品久久人人爱蜜臀 | 曰韩精品一区二区| 欧美中文字幕视频| 午夜日韩激情| 欧美一二区视频| 久久蜜桃av一区精品变态类天堂| 免费在线亚洲欧美| 国产丝袜美腿一区二区三区| 国产偷自视频区视频一区二区| 欧美一区二区三区婷婷月色| 中日韩美女免费视频网站在线观看| 欧美成人中文字幕| 蜜臀久久99精品久久久久久9 | 亚洲欧洲精品一区二区精品久久久 | 久久综合999| 亚洲一区二区三区四区五区黄| 欧美福利精品| 亚洲高清在线观看一区| 久久精品首页| 亚洲欧美精品在线| 欧美涩涩视频| 一区二区福利| 亚洲激情影院| 欧美sm重口味系列视频在线观看| 加勒比av一区二区| 久久久久国产精品厨房| 亚洲综合不卡| 国产精品亚洲综合一区在线观看 | 国产精品hd| 99热精品在线观看| 亚洲国产精品一区在线观看不卡| 久久久久免费视频| 国内精品伊人久久久久av影院| 久久经典综合| 久久aⅴ国产紧身牛仔裤| 国产日韩欧美成人| 欧美伊久线香蕉线新在线| 亚洲免费在线播放| 国产精品无码永久免费888|