Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


opengl glutstrokecharacter - write text to screen


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 chilun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 29 October 2013 - 07:46 AM

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();
}

 



Sponsor:

#2 Petrov_VA   Members   -  Reputation: 596

Like
0Likes
Like

Posted 30 October 2013 - 04:54 PM

The glutStrokeCharacter seemed not working in the latest versions of MS VS.

Good sample of text output in glOrtho performance: lesson21( c++ code), lesson24(c++ code).

The codes and demo of above adapted to MS VS 2010/2012 in source files to:

Concentration of all The Lessons in Common Library GLSummary in MFC



#3 chilun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 31 October 2013 - 05:16 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS