[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Opengl text output

Posted on 2011-03-15
7
Medium Priority
?
594 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 41

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 41

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

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

vsprintf_s(buffer, format, args);

0
 
LVL 41

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 41

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Simple Linear Regression
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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