Game Development Community

Texture holding out of balance ???

by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 02/27/2005 (2:23 am) · 0 replies

I've run into a very annoying problem.

I'm coding up a radar that displays small icons instead of just plain OpenGL lines/points. I have gotten the radar working but then I added some code for holding the icon for an enemy to it, and the engine crashes with an "Texture holding out of balance" error in the gTexManager unlock() line 1434.

I have no clue why it would do that, because the code I use is cut'n'paste from other places where it does work.

It looks similar to the below:

From the header
protected:
	StringTableEntry mNeedleBitmapName;
	TextureHandle mNeedleTextureHandle;

void GuiShipRadarHud::setEnemyBitmap(const char *name)
{
	mEnemyBitmapName = StringTable->insert(name);
	if (*mEnemyBitmapName)
		mEnemyTextureHandle = TextureHandle(mEnemyBitmapName, BitmapTexture, true);
	else
		mEnemyTextureHandle = NULL;
	setUpdate();
}

in the onRender I use it simliar to this
TextureObject* texture = (TextureObject*) mEnemyTextureHandle;
		mBounds.extent.set(texture->bitmapWidth, texture->bitmapHeight);

		RectI outerRect(offset, mBounds.extent);
		dglDrawBitmapStretch(mEnemyTextureHandle, outerRect);

I have the exact same code in at least 3 other GUI components + the radar itselv without any problems, and what I need is some hint to why this would happen - and what the error means.

Have I hit some internal "maximum texture handles" refcounter or similar?

There are no other posts on the forums about this at all, and I've spend quite some time trying to find any issues in my code - without luck.

So I would kindly ask for some help in understanding the problem, so I can fix it

Thanks!