Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


printf()/scanf() and OpenGL/GLUT


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 jjk   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 2001 - 03:56 PM

This might be a stupid question...I apologize in advance. After I''ve started up an GLUT window, I can no longer use the printf() function to print plain-vanilla text to the console, or scanf() for that matter. I''m writing a C program with a lot of text output (in addition to OpenGL graphics), so is there an quick, easy, and painless way to retain normal text (using stdio.h?) (If it makes a difference, I''m running CodeWarrior 6, GLUT, and MacOS9.) Thanks!

Sponsor:

#2 bgreen   Members   -  Reputation: 162

Like
Likes
Like

Posted 22 August 2001 - 04:06 PM

printf won''t allow you to write text to the canvas.
You''ll have to "draw" the text to the screen as part of your normal rendering function.

However, GLUT does provide an easy way to do this. I can''t look it up now (at work). But, basically you set the raster position on the screen and them use an existing GLUT function to draw the text. The function is called something like "glutStrokeText" or something.

But wait, there''s more! GLUT creates a window for your OpenGL, but there is still the initial window from where the program is started. Printf will direct any output to this window/console.

Cheers,
Brendan

#3 bgreen   Members   -  Reputation: 162

Like
Likes
Like

Posted 22 August 2001 - 04:10 PM

Just had another thought. If the outputed text is not required at run time, why not write the output to a file. You could then run the program and view the results at the end.

#4 gph-gw   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 August 2001 - 07:09 PM

Console? I never knew Mac OS 9 had a console; on the other hand, I have never used Mac OS 9.

#5 bgreen   Members   -  Reputation: 162

Like
Likes
Like

Posted 25 August 2001 - 07:24 PM

Hmmm....
Good point. While I must admit I haven''t programmed on the mac before, GLUT is a "layer" between your program and the native windowing API. Since, in Windows land, when you run a GLUT application, you get two windows - one that is "character based" (for want of a better description) and the other has the OpenGL canvas.
I just assumed that it would be the same on the mac.....


#6 jjk   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 August 2001 - 05:08 AM

Thanks for your thoughts on this. Since my last post I''ve discovered a few more things: There is no standard console on MacOS9 (unlike MacOSX), but everyone uses a proprietary version of the console called SIOUX (which is part of the Metrowerks Standard Library). The problem now is to try to figure out how to get the SIOUX console to work with GLUT. I can get the SIOUX console to appear, but only if the printf() function is called inside the function called by glutDisplayFunc(). Doing this, however, is slowing things enormously.

I''ll let you know if I find out more.

#7 jjk   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 August 2001 - 03:25 AM

Found a solution...
Using fprintf and stderr bypasses the SIOUX console buffer and brings it a console. (Using a normal printf to stdout prints to the buffer first and doesn''t bring up the console immediately).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS