Starting with the Resource Class

The Resource class is relatively small, and is the base class for all resources in Direct3D, so it may be a good idea to start this section with a list of each method, and what it's intended to be used for. You will never actually create or use the Resource class itself, since it is an abstract class, but you may find yourself using these methods on your other resource classes. See Table 8.1 for the methods on the resource class:

Table 8.1. Resource Class Methods and Properties

PROPERTY OR METHOD

DESCRIPTION

Device

Read-only property that will return the device this resource was created with.

Type

Read-only property that returns the type of resource this is. Valid return values for this property are in the ResourceType enumeration.

Priority

Read-write property that returns the priority of this resource. Priorities only matter when dealing with resources that reside in the managed memory pool. They are used to determine when a resource can be removed from memory. The lower the priority, the faster a resource can be removed. By default, all managed resources have a priority of 0, and all non-managed resources will always have a priority of 0. There is also a SetPriority method, which returns the old priority after setting the new one.

PreLoad

Use this method to indicate that a managed resource will be needed shortly. This will allow Direct3D to move your resource into video memory before it is actually needed. It's important to note, that if you are already using more video memory than you have, this method will silently do nothing.

PrivateData members

There are three members that allow you to get and set private data for each of your resources. This data is never used by Direct3D and can be used by your application as you see fit.

As you can see, the resource class deals mainly with enhancing managed resources performance. While not listed in the chart above, or the resource class, it's important to note that each resource in Direct3D will also have a usage, as well as a memory pool (defined in the Usage and Pool enumerations). These properties define how the resource is used, and where it is located in memory (be it system memory, video memory, or AGP memory).

Resources all have a way to allow the CPU to access the data it stores, normally by a mechanism called Locking. In our examples thus far, we've filled our buffers with single "SetData" calls, and created our textures from files; however, it is possible to retrieve the data, or only set small subsections of that data, via locking these resources. We will discuss locking in this chapter briefly. Let's look at the first resource we were introduced to.



Managed DirectX 9 Graphics and Game Programming, Kick Start
Managed DirectX 9 Kick Start: Graphics and Game Programming
ISBN: B003D7JUW6
EAN: N/A
Year: 2002
Pages: 180
Authors: Tom Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net