Lets say i have a function called
Int Total();
that returns an integer value.
What draw function can I use to display the return value to the Graphic screen, in a font of my choosing?
you can check examples/graphics/fontsExample to see how to use the font of your choosing.
you can us ofToString(myInteger) to convert a number to a string.
hope that helps
|error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]|
int testing = Pile_counter(Pile); //tired storing the total in a variable
ofToString(testing); // conversion as you stated
pilefont.drawString("Pile total: ", 570,200); // this works
pilefont.drawString(testing, 570,260); //this does not work, error here
this works for me:
This is kind of hard to follow since I’m relatively new…
But isn’t there a way to do this
int x = 99;
SomeFunctionThatPrintsintergers(x, x_coordinate, y_coordinate);
?
The simplest way to draw that would be this line:
ofDrawBitmapString(ofToString(x), 500, 500, 0);
Where 500, 500, and 0 are the x, y, and z coordinates to draw it respectively. If you need to use a specific font, you can do this instead:
ofTrueTypeFont font;
int x;
void ofApp::setup(){
//This will load whatever font you want and set its size. Make sure you have the font file in
//your project's bin/data folder (for example,
//of_v0.8.4_vs_release\apps\myApps\testApp\bin\data).
font.loadFont ("verdana.ttf", 32);
x = 99;
}
void ofApp::draw(){
font.drawString (ofToString(x), 500, 500);
}
Your issue is in the second line. You need to assign that value to a string variable, like
string testString = ofToString(testing);
and then use that in the drawString function
Thanks a bunch this really helped