Jump to content
  • Advertisement
Sign in to follow this  
chilun

opengl glutstrokecharacter - write text to screen

This topic is 2091 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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!