printing to the console in OpenGL programs

Started by
7 comments, last by BruiZa 21 years, 2 months ago
Hello All, I am new to programming in C++ and Opengl (although I have some experience with C and Java). I have been going through the NeHe tutorials online and I am trying to write some openGL code for my university project. I want to add some lines to my code to output the values of particular variables so that I can check they are correct. Basically I have applied some functions to the current matrix and need to print out each of the 16 values of the array. I have tried printf and cout but when I run the program from a cmd window, nothing appears when I run the program. I was writing the lines in the DrawGLScene(GLvoid) function and I guess this might be the problem but I am not sure. Cheers for any help -BruiZa
Advertisement
You can use one of the open gl text functions to output it to the screen. In everything i work on i do that, where if bool screeninfo == true i have it diplay variable vaules all over the screen.

Another option is to us fstream and output them to a file.
You can just make the program as a console application and add (after winmain):

int main( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

return WinMain(hInstance,hPrevInstance,lpCmdLine,nCmdShow);
}

Then just use cout or printf and it will show up in the seprate console window.
Thanks for the help. I think i will try and output to a file. Hopefully that will be the easiest.

~BruiZa
it just fits into the thread so ill aks here:

is there a good tutorial online how i could make a real console in my opengl application?
Make it a console application and then open the opengl window. As in my post above, you can just add main() after winmain and change it to a console app. The program will work exactly the same but also open a console window.
i ment a real console like in 3d games (eg Q3)...
i know how it works basicly..
but a good online tutorial would be nice..
hey thanx xiros, that worked. This also works without having to change to a console application:

AllocConsole();
freopen("CONOUT$", "a", stdout);

thanx to a couple of posts here ar gamedev
http://www.gamedev.net/community/forums/topic.asp?topic_id=124113
http://www.gamedev.net/community/forums/topic.asp?topic_id=140114
ARG! You guys cannot begin to understand how usefull this thread is to me! I''m working on an app that uses external renderers to make pretty pictures. I was wanting to change my program to a console program because everytime I render, the external renderer''s console comes popping over my main screen. I had no idea how to change it to a console application.

AllocConsole(); does the trick! arg, just one line of code!

Thanks!

Have fun,

Wybren van Keulen
www.funnyfarm.tv

This topic is closed to new replies.

Advertisement