GBitmap and TextureHandle
by Xavier "eXoDuS" Amado · in Torque Game Engine · 11/26/2002 (8:53 pm) · 7 replies
I'm trying to get the bitmap data from an existing TextureHandle (which was loaded through the mission editor), modify it and then put it back into the texture handle. Well i tried the following:
GBitmap *test = mBaseTextureHandle.getBitmap(); int a; mBaseTextureHandle = TextureHandle(mBaseTextureName, test, BitmapTexture, true);But that gives an Access Violation error when doing the second line. Anyone can help me a bit here please?
About the author
#2
You should be aware that not all uploaded textures are set to keep their original bitmap and so asking for one doesn't always give you one.
Textures that have the type, "BitmapKeepTexture" or "BitmapNoDownloadTexture" keep their associated bitmap else nada.
- Melv.
11/27/2002 (1:03 am)
Xavier,You should be aware that not all uploaded textures are set to keep their original bitmap and so asking for one doesn't always give you one.
Textures that have the type, "BitmapKeepTexture" or "BitmapNoDownloadTexture" keep their associated bitmap else nada.
- Melv.
#3
Edit: Never mind, found it and changed it to BitmapKeepTexture when the TextureHandle is being initially created. But it still keeps crashing inside the GBitmap::getWidth() function. Any other ideas?
11/27/2002 (6:10 am)
And where is that supposed to be set Melv?Edit: Never mind, found it and changed it to BitmapKeepTexture when the TextureHandle is being initially created. But it still keeps crashing inside the GBitmap::getWidth() function. Any other ideas?
#4
11/27/2002 (6:17 am)
Mmmm.... debugging says that "test" is set to NULL values. (0x0000000) inside pBits where the actual bitmap data should be.... I'm missing something....
#5
Bump mapping here I come :P
11/27/2002 (6:34 am)
Doh. unpackData is called after onAdd().. hehe... moved everything to unpackData now and works like a charm! :)Bump mapping here I come :P
#7
11/27/2002 (6:01 pm)
Actually I had more problems after that. I ended doing this:if (*mBumpTextureName)
{
TextureHandle tempHandle(mBumpTextureName, BitmapKeepTexture, true);
GBitmap *source = tempHandle.getBitmap();
GBitmap *temp = new GBitmap( source->getWidth(), source->getHeight(), false, source->getFormat() );
dMemcpy( temp->getAddress(0,0), source->getAddress( 0, 0), sizeof( U8 ) * source->getWidth() * source->getHeight() * source->bytesPerPixel);
// Now modify the bitmap data
for (int a = 0; a < (temp->getWidth()*temp->getHeight()); a++)
{
temp->pBits[3*a] = temp->pBits[3*a]/2.f + 0.5f;
temp->pBits[3*a+1] = temp->pBits[3*a+1]/2.f + 0.5f;
temp->pBits[3*a+2] = temp->pBits[3*a+2]/2.f + 0.5f;
}
// Make a new texture handle with the modified data
mBumpTextureHandle.set( mBumpTextureName, temp, BitmapTexture, true);
}
Torque 3D Owner Robert Blanchet Jr.