Jump to content
  • Advertisement

Archived

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

rick_appleton

OpenGL window and DOS window

This topic is 5225 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

If I have a Win32 window with OpenGL running in it, and I want to have a simple console (DOS) window to output some debugging stuff, how would I do that? I''ve been wanting to do this for ages, but I just can''t seem to find a way. Any ideas? PS. Running from a dos-prompt, and starting the win32 windows from there is probably not an option, as I want to be able to start in win32 natively as well, without needing to change a lot, just disabling logging

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Create console project -> code Win32 window creation routines -> create new Win32 window with OpenGL support -> show new window -> render stuff into OpenGL window, and output debug messages to console window?

Share this post


Link to post
Share on other sites
That''s the idea. But if I then want to remove the debugging console, I''ll need to create a new project etc.

Is there no way to do it the other way around? Or is there some way I can code a simple window to output text to? (Preferably that also works in Linux, but that probably isn''t possible)

Share this post


Link to post
Share on other sites
The functions that you are looking for are:
(I assume your using C++ in windows)

AllocConsole();
FreeConsole();

Those will actually create the console.
Then to print to it, I believe (of the top of my head), that you use:

cprintf("String");

but im not entirly sure. Im sure you can come up with something in google if it doesnt work.

Hope this helps.

Share this post


Link to post
Share on other sites
Take a look into the AllocConsole()/FreeConsole() functions.

BTW, this isn''t a graphics question, so I''m moving it.

Share this post


Link to post
Share on other sites
Ok, I did a test, and cprintf works. but it isnt the proper way to do it.

Also, functions like clrscr, gotoxy, etc dont work (or exist).
so here is some replacements for you:

clrscr:

void clrscr() {
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT('' ''), dwConSize,
coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize,
coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}


gotoxy:

void gotoxy(int x, int y) {
COORD coord;
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}


If you need anymore help, reply here, or email me at chatterbox@xtra.co.nz

Share this post


Link to post
Share on other sites

  • 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!