Game Development Community

Debugging values in C

by James Laker (BurNinG) · in Torque Game Engine · 02/27/2006 (11:09 pm) · 5 replies

How do I print values from C++ to the screen?

I've tried Con::printf("bx : %d",bx);... and that prints it to console with strange results.
Values in the millions?? Isn't it suppose to be float values?

eg. in void WheeledVehicle::updateForces(F32 dt)
I'm trying to see what the values are for bx,by,bz

Point3F bx,by,bz;
   currMatrix.getColumn(0,&bx);
   currMatrix.getColumn(1,&by);
   currMatrix.getColumn(2,&bz);

Any help appreciated...

EDIT: I've seen screenshots where it is printed on the screen without having to go to the console...

#1
02/27/2006 (11:11 pm)
The "%d" format argument for printf says to display the variable as a double...in effect, as an integer.

If you want to display a float variable, use %f.
#2
02/27/2006 (11:16 pm)
Thanx for the quick reply...

So am I right when I say it's suppose to be a float?
#3
02/28/2006 (12:07 am)
Con::printf("bx: %f %f %f", bx.x, bx.y, bx.z);

bx is a Point3F which basically consists of x, y, and z float values.

Hope it helps.

-Jase
#4
02/28/2006 (12:09 am)
Cool now that makes sense...
Is there a way to get this onscreen and not in the console?
#5
02/28/2006 (1:21 am)
You could create a textbox compent for the gui, then set its value through C