Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Opengl text output

Posted on 2011-03-15
7
Medium Priority
?
591 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Make the most of your online learning experience.
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.
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

618 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