?
Solved

Opengl text output

Posted on 2011-03-15
7
Medium Priority
?
588 Views
Last Modified: 2012-06-27
I am trying to ouput text to the screen in opengl. I cannot seem to get it to display this is how I have done it below.


void output(GLfloat x, GLfloat y, char *format)
{
  va_list args;
  char buffer[200], *p;

  va_start(args, format);
  vsprintf_s(buffer, format, args);
  va_end(args);
  glPushMatrix();
  glTranslatef(x, y, 0);
  for (p = buffer; *p; p++)
    glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
  glPopMatrix();
}

and in the display part of the code

 output(80, 2800, "SnowMan Game Score.");

what part am I missing?


0
Comment
Question by:tango2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 35139734
2800 should be well below the screen view no?  Try making it 0,0 just to see if you can get it to display.

eG:

output(0, 0, "SnowMan Game Score.");
0
 

Author Comment

by:tango2009
ID: 35140834
This still doesn't display the text onto the screen. Any other ideas?
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 35140946
not sure about this:

  va_start(args, format);
  vsprintf_s(buffer, format, args);
  va_end(args);

can you set a breakpoint and check buffer has the text?

Can we try a simple test:

void main()
{
 //init open GL
  Output(0, 0, "SnowMan Game Score.", 19);
}

void Output(GLfloat x, GLfloat y, char format[], length)
{
  for (int i = 0; i <length; i++)
    glutStrokeCharacter(GLUT_STROKE_ROMAN, format [ i ]);
 }

0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 

Author Comment

by:tango2009
ID: 35141430
You mean add a breakpoint on this line?

vsprintf_s(buffer, format, args);

0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 35158006
after it, just to make sure you have something in the buffer.

0
 

Author Comment

by:tango2009
ID: 35158107
I have now solved the problem thanks for your help.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 35158546
What was the problem?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Progress
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question