Trouble creating a BitmapTex programmatically in C++

Trouble creating a BitmapTex programmatically in C++

l_wakefordJ2S8U
Explorer Explorer
94 Views
1 Reply
Message 1 of 2

Trouble creating a BitmapTex programmatically in C++

l_wakefordJ2S8U
Explorer
Explorer

Hi,

I'm trying to create a Bitmap and BitmapTex objects in C++, but I'm running into an issue with actually assigning the bitmaps. It seems like calling SetBitmap() doesn't actually set the bitmap.

 

The below code will always print "Bitmap created!" and then "No bitmap retrieved!"

BitmapInfo bitmapInfo;
bitmapInfo.SetType(BMM_TRUE_64);
bitmapInfo.SetHeight(debugSquareSize);
bitmapInfo.SetWidth(debugSquareSize);

Bitmap* newBitmap = TheManager->Create(&bitmapInfo);
if(newBitmap != nullptr)
{
   DebugPrint("Bitmap created!");
}

BitmapTex* newBitmapTexture = NewDefaultBitmapTex();
newBitmapTexture->SetBitmap(newBitmap);

Bitmap* retrievedBitmap = newBitmapTexture->GetBitmap(0);
if(retrievedBitmap == nullptr)
{
   DebugPrint("No bitmap retrieved!");
}


I'm wondering if anyone has attempted something similar and knows what might be going wrong here?

0 Likes
Accepted solutions (1)
95 Views
1 Reply
Reply (1)
Message 2 of 2

l_wakefordJ2S8U
Explorer
Explorer
Accepted solution

I figured it out.

 

If you look at the source for BMTex (the implementation of BitmapTex) in the SDK samples. There is a slot for a "proxy" bitmap and a slot for a "non proxy" bitmap. The BMTex seems to start in "proxy mode" and there's no accessible way of turning this off.

 

GetBitmap returns the bitmap in the proxy or non-proxy slot based on whether the BMTex is in proxy mode or not. But SetBitmap puts the bitmap in the proxy or non-proxy slot based on the bitmap's flags. So if you want to use Bitmap Texture's in the way I'm trying to above, then you need to add the MAP_PROXY flag to the bitmapinfo.

 

bitmapInfo.SetFlags(MAP_PROXY|MAP_ALPHA_PREMULTIPLIED);

 

0 Likes