Solved

Opengl text output

Posted on 2011-03-15
7
581 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 39

Expert Comment

by:Kyle Abrahams
Comment Utility
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
Comment Utility
This still doesn't display the text onto the screen. Any other ideas?
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:tango2009
Comment Utility
You mean add a breakpoint on this line?

vsprintf_s(buffer, format, args);

0
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
Comment Utility
after it, just to make sure you have something in the buffer.

0
 

Author Comment

by:tango2009
Comment Utility
I have now solved the problem thanks for your help.
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
What was the problem?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array6 challenfge 6 62
wordmultiple challenge 12 89
White board coding practice 3 60
Path to Python 9 36
This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

11 Experts available now in Live!

Get 1:1 Help Now