Jump to content
  • Advertisement
Sign in to follow this  
mbanghart

OpenGL Output in OpenGL

This topic is 3795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am new to opengl and have some problems with output. Why will the following cout statements not print anything? Neither printf or cout works. THe system("pause") command does work. I use the following headers: #include <GL/glut.h> #include <fstream> #include <iostream> #include <list> #include <stdlib.h> CODE: int main(int argc, char** argv) { //Read File and setup world printf("fooey, the file didn't open!"); cout << "fooey, the file didn't open!" << endl; system("PAUSE"); glutInit(&argc,argv); readFile("su08_world1.dat"); myInit(); glutMainLoop();

Share this post


Link to post
Share on other sites
Advertisement
Most likely, your program is not a console program. If you don't have a console, where do you expect output from cout or printf to appear?

Share this post


Link to post
Share on other sites
More in depth of what he said:

Console = text only (DOS windows)
GUI = windows/GL/DX

Printing words in GL is a pain, check NEHE code. I suggest just learning how to draw stuff first and deal with fonts later.

Share this post


Link to post
Share on other sites
1. Is there a command prompt open when the program runs?
2. cout and endl are both in the std namespace so you'd need std::cout and std::endl

That's all I could think of really. Also I would take out system("PAUSE"); I don't know what it does, but the sound it seems bad.

Share this post


Link to post
Share on other sites
If you're going to use STL objects and functions, sometimes it's easier to add:

using namespace std;

after your list of includes, rather than specifying the namespace for each object ( std::cout, etc. ).

Share this post


Link to post
Share on other sites
Quote:
Original post by Tenac
Also I would take out system("PAUSE"); I don't know what it does, but the sound it seems bad.

All it does is issue the PAUSE command to Windows which, in a console, simply prints "Press any key to continue . . ." and waits for user input.

@mbanghart: Like Tenac asked, is the program run from the command prompt. Because cout only prints to the command line. But if your intent is actually to print to the command line and not the OGL screen then i see no reason why it shouldn't work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!