QUESTION
I am trying to update the score after each iteration in my display. How to do so with The following Function.
Code
void DrawString(int x, int y, int width, int height,const string &score,
float*color) {
float fx = (float)x / width * 2 - 1, fy = (float)y / height * 2 - 1;
DrawString(fx, fy, score, color);
}
// Function draws a string at given x,y coordinates
void DrawString(float x, float y, const string& score, float * color) {
glPushMatrix();
glLoadIdentity();
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
GLvoid *font_style = GLUT_BITMAP_TIMES_ROMAN_24;
if (color)
glColor3fv(color);
glRasterPos3f(x, y, 1);
// Draw the characters one by one
for (int i = 0; i < score.size(); i++)
glutBitmapCharacter(font_style, score[i]);
glPopMatrix();
}
int main(){
int score = 45;
DrawString(250,650,"score : " + score ,colors[RED]);
//EXAMPLE
score++;
ERROR
error: invalid operands of types ‘const char [9]’ and ‘float’ to binary ‘operator+’
DrawString(250,650,"score : " + score,colors[RED]);