本文整理汇总了C++中CD3DTexture::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CD3DTexture::getObject方法的具体用法?C++ CD3DTexture::getObject怎么用?C++ CD3DTexture::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CD3DTexture
的用法示例。
在下文中一共展示了CD3DTexture::getObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createResource
void CTextureBundle::createResource()
{
// reload all objects
TResourceMap::iterator it;
for( it = mResourceMap.begin(); it != mResourceMap.end(); ++it ) {
CD3DTexture& res = *it->second;
assert( res.isNull() );
CD3DTexture* n = tryLoadResourceById( it->first );
assert( n );
res.setObject( n->getObject() );
delete n;
assert( !res.isNull() );
}
}
示例2: loadResourceById
CGUIFont* CFontBundle::loadResourceById( const CResourceId& id, const CResourceId& fullName )
{
// open file
FILE* f = fopen( fullName.getUniqueName().c_str(), "rb" );
if( !f ) {
return NULL;
}
assert( f );
// read magic
char magic[4];
fread( &magic, 1, 4, f );
if( magic[0]!='D' || magic[1]!='F' || magic[2]!='N' || magic[3]!='T' ) {
std::string msg = "file isn't valid font file! '" + id.getUniqueName() + "'";
CConsole::CON_ERROR.write( msg );
THROW_ERROR( msg );
}
// letter count
int letterCount;
fread( &letterCount, 1, 4, f );
// first letter
int firstLetter;
fread( &firstLetter, 1, 4, f );
// max width
unsigned short maxWidth;
fread( &maxWidth, 1, 2, f );
// max height
unsigned short maxHeight;
fread( &maxHeight, 1, 2, f );
// load texture - with same name
CD3DTexture* texture = RGET_TEX(id);
assert( texture );
D3DSURFACE_DESC desc;
texture->getObject()->GetLevelDesc( 0, &desc );
float halftexX = 0.5f / desc.Width;
float halftexY = 0.5f / desc.Height;
// create font
CGUIFont* font = new CGUIFont( letterCount, firstLetter, maxWidth, maxHeight, *texture );
assert( font );
// read letter infos
for( int i = 0; i < letterCount; ++i ) {
CGUIFont::SLetter& l = font->getLetterByNumber( i );
fread( &l.u0, 1, 4, f );
fread( &l.v0, 1, 4, f );
fread( &l.u1, 1, 4, f );
fread( &l.v1, 1, 4, f );
l.u0 += halftexX;
l.v0 += halftexY;
l.u1 += halftexX;
l.v1 += halftexY;
unsigned short v;
fread( &v, 1, 2, f );
l.width = v;
fread( &v, 1, 2, f );
l.height = v;
}
// close file
fclose( f );
CONSOLE.write( "font loaded '" + id.getUniqueName() + "'" );
return font;
}