Console Window and OpenGL

Started by
4 comments, last by mfawcett 18 years, 10 months ago
Is there anyway to have a console popup, let you input variables and stuff in it, and then when you are done with it have the program resume using OpenGL?
My Current Project Angels 22 (4E5)
Advertisement
if i'm getting what you want properly then yes, but you would have to programm it all yourself
Alrighty then, thanks.
My Current Project Angels 22 (4E5)
Hmm, yes, as phantom said, you would have to do it yourself, OpenGL is kindof a rendering API :D

Anyways, assuming you meant a standard Windows(tm) console that was fairly easy, I added one to my own opengl window class, I just roughly chopped out the implementation of the console window here if it would give you any pointers to what to do: (Window:: is my own homebrewed opengl enabled window class)

void Window::RedirectIOToConsole(){    CONSOLE_SCREEN_BUFFER_INFO coninfo;    FILE                       *fp;    // allocate a console for this app    AllocConsole();    // set the screen buffer to be big enough to let us scroll text    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),                                &coninfo);    coninfo.dwSize.Y = MAX_CONSOLE_LINES;    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),                                coninfo.dwSize);    // redirect unbuffered STDOUT to the console    lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);    fp = _fdopen( hConHandle, "w" );    *stdout = *fp;    setvbuf( stdout, NULL, _IONBF, 0 );    // redirect unbuffered STDIN to the console    lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);    fp = _fdopen( hConHandle, "r" );    *stdin = *fp;    setvbuf( stdin, NULL, _IONBF, 0 );    // redirect unbuffered STDERR to the console    lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);    hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);    fp = _fdopen( hConHandle, "w" );    *stderr = *fp;    setvbuf( stderr, NULL, _IONBF, 0 );        // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog     // point to console as well    ios::sync_with_stdio();}


(I might have ripped this of someone else and modified it to my own needs in the first place btw)

usefull includes
#include <windows.h>#include <stdio.h>#include <fcntl.h>#include <io.h>#include <iostream>#include <fstream>


Don't know if some definitions are missing, but I am short on time now. Provided as is .

Edit: one of meny spelling errors corrected.
wow I had no idea it was so easy to get a console window to open up. Thanks for that code, for my last project I wound up trying to code my own console, but that would have made things sooooo much easier.
Quote:Original post by todderod
*** Source Snippet Removed ***

(I might have ripped this of someone else and modified it to my own needs in the first place btw)



Heh, yes, I thought that code looked familiar. :)
--Michael Fawcett

This topic is closed to new replies.

Advertisement