MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setTexture

Method setTexture

Engine/source/gfx/gfxTextureArray.cpp:116–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116void GFXTextureArray::setTexture(const GFXTexHandle& texture, U32 slot)
117{
118 PROFILE_SCOPE(GFXTextureArray_setTexture)
119 GFXTexHandle handle = texture;
120 if (texture->getPath().isNotEmpty())
121 {
122 if (texture.getHeight() != mHeight || texture.getWidth() != mWidth || texture.getFormat() != mFormat || texture->getMipLevels() < mMipLevels)
123 {
124 if (texture.getHeight() != mHeight || texture.getWidth() != mWidth)
125 {
126 AssertWarn(true, avar("GFXTextureArray::setTexture all textures should be the same size: %i vs %i", texture.getHeight(), mHeight));
127 Con::warnf(avar("GFXTextureArray::setTexture all textures should be the same size: %i vs %i", texture.getHeight(), mHeight));
128 }
129 else if (texture->getMipLevels() < mMipLevels)
130 {
131 AssertWarn(true, avar("GFXTextureArray::setTexture all textures should have at least the same number of mips: %i vs %i", texture->getMipLevels(), mMipLevels));
132 Con::warnf(avar("GFXTextureArray::setTexture all textures should have at least the same number of mips: %i vs %i", texture->getMipLevels(), mMipLevels));
133 }
134
135 GBitmap* inBitmap = TEXMGR->loadUncompressedTexture(texture->getPath(), &GFXTexturePersistentProfile, mWidth, mHeight);
136 if (!inBitmap->setFormat(mFormat))
137 {
138 AssertFatal(true, "GFXTextureArray::setTexture all textures must be convertible to GFXFormat " + mFormat);
139 Con::errorf("GFXTextureArray::setTexture all textures must be convertible to GFXFormat" + mFormat);
140 handle = NULL;
141 delete inBitmap;
142 }
143 else
144 {
145 handle = TEXMGR->createTexture(inBitmap, "", &GFXStaticTextureProfile, true);
146 }
147 }
148 }
149 if (!handle.isValid())
150 {
151 return;
152 }
153
154 if (handle.getHeight() != mHeight || handle.getWidth() != mWidth || handle.getFormat() != mFormat || handle->getMipLevels() < mMipLevels)
155 {
156 AssertFatal(true, "GFXTextureArray::setTexture all textures must have the same size and format");
157 Con::errorf("GFXTextureArray::setTexture all textures must have the same size and format");
158 return;
159 }
160
161 mTextures[slot] = handle;
162
163 _setTexture(handle, slot);
164}
165
166void GFXTextureArray::Release()
167{

Callers

nothing calls this directly

Calls 13

avarFunction · 0.85
warnfFunction · 0.50
errorfFunction · 0.50
isNotEmptyMethod · 0.45
getPathMethod · 0.45
getHeightMethod · 0.45
getWidthMethod · 0.45
getFormatMethod · 0.45
getMipLevelsMethod · 0.45
setFormatMethod · 0.45
createTextureMethod · 0.45

Tested by

no test coverage detected