Game Development Community

TGE 1.5.2] Using dglDrawBitmap crashes engine.

by Kuju Manila · in Torque Game Engine · 10/06/2007 (6:58 pm) · 2 replies

Hello.

I am modifying the engine such that I'm creating a GuiControl that renders a colored life bar above the object's "head." I successfully achieved this. Now, I am tasked to do replace the rectangular life bars to use a 2D bitmap. However, my engine crashes when I am trying to use the dglDrawBitmap bitmap-drawing function provided by Torque.

I already have this somewhere before my dglDrawBitmap:
mTexture1 = TextureHandle( "./lifered.png", BitmapTexture, true ); //somewhere before; hardcoded path for now; console doesn't report any missing texturefiles so I guess it's ok.

//my onRender:
if( mTexture1 )
{
    Con::errorf( "casting Texture" );
    TextureObject * to = static_cast< TextureObject * >( mTexture1 );
    Con::errorf( "drawing bitmap using dglDrawBitmap" );
    dglDrawBitmap( mTexture1, Point2I( 0, 0 ), false ); //crashes here
    Con::errorf( "lifebar render end" );
}

Are there any gotcha's I missed when using primitive rendering of Torque?

#1
10/07/2007 (7:01 pm)
I found my problem and it's not the dglDrawBitmap.
It's actually my improper use of getting the width of the texture, and now I fixed it.

It's funny that it seems printing checkpoints on the console/log file isn't reliable as always. I ended up using the VS2005's debugger by attaching the running process of the DEBUG version. This brings me to another question, how do you guys get to build->run the DEBUG version of Torque? Whenever I do that there's always the missing main.cs file error (I assume it's because of the paths). How do I fix my environment so that whenever I use the Run in VS2005 it will work with Torque?
#2
10/07/2007 (7:28 pm)
You need to set the "Working Directory" in your project settings to where your game files are.