Solved

Opengl text output

Posted on 2011-03-15
7
582 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

919 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now