Graphics Reference
In-Depth Information
1. Define uv texture placements. Recall that in the UWBGL library, all API-
specific drawing operations are implemented in the DrawHelper class. In
this case, we have merged the new DeviceVertexFormat and primitive uv
texture placement computation into the D3D _ DrawHelper5.cpp file. The
changes involved are very similar to those of Listing 12.8 and Listing 12.9,
and we will not re-list them here.
2. Load image file as texture. As discussed in the following, Lib13 intro-
duces functionality to support working with any simple file resource. This
is in anticipation that we will work with other types of file resources (e.g.,
mesh files). The texture files are stored in a resource table defined in the
GraphicsSystem class.
3. Enable texture functionality. As discussed in the following, Lib13 sup-
ports per-primitive texture attributes by defining appropriate attributes in
the Primitive base class and extending the D3D _ DrawHelper class.
File Resource Loading and Management
Listing 12.12 shows a simple base class for searching and loading files. Load
Resource() (at label A) receives a fileName , calls FindFilePath() (at label B)
to find the full path to this file, and calls the pure virtual function LoadResource
FromFile() to load the file into D3D as a resource. Listing 12.13 shows the
implementation of loading a texture file as resource. At label C, we see that the
loaded file will be bound to this D3D texture structure. Label A defines the func-
class UWBD3D _ Resource {
.
Source file.
uwbgl _ D3DResource1.h
file in the D3D Files/
D3D_Resources
// find/load the file
subfolder
A:
virtual bool LoadResource( LPDIRECT3DDEVICE9 , fileName);
protected :
// find fullPath from filename
UWBGL _ D3D _ Lib13
of
the
project.
B:
void FindFilePath(filename, fullPath);
// subclass responsibility
C:
virtual bool LoadResourceFromFile(fullPathName) = 0;
.
Listing 12.12. Abstract support for file resource loading.
Search WWH ::




Custom Search