Sign in to follow this  

opengl glutstrokecharacter - write text to screen

This topic is 1509 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi;

 

I'm trying to write some code into my existing game project to write some text to the window.

I've modified the sample code to plug into project. The output function assigns element in the text string to an individual char in order to pass to the display function (subsequently output to the screen). It compiles, but I don't see any text written to the window. Does anyone know how I can fix this?

 

void output(GLfloat x, GLfloat y, char* text)
{
    glPushMatrix();
    glTranslatef(x, y, 0);
    glScalef(1/152.38, 1/152.38, 1/152.38);
    for( char* p = text; *p; p++)
    {
        glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
    }
    glPopMatrix();
}


void display()
{
  glClear(GL_COLOR_BUFFER_BIT);
  Painter p;
  game.draw(p);
  
  //write text to screen
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glEnable(GL_BLEND);
  glEnable(GL_LINE_SMOOTH);
  glLineWidth(2.0);
  output(400,200,"hello");
  
  glutSwapBuffers();
}

 

Share this post


Link to post
Share on other sites

Thank you very much. There is an alternative using the GlutBitmapCharacter function so I will test to see if this works with my existing code instead.

Share this post


Link to post
Share on other sites

This topic is 1509 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this