Archived

This topic is now archived and is closed to further replies.

BruiZa

printing to the console in OpenGL programs

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks for the help. I think i will try and output to a file. Hopefully that will be the easiest.

~BruiZa

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites