PDA

View Full Version : Simulate Console Program (In Full Screen Mode)



lmsmi1
06-16-2013, 06:06 PM
I've been looking into OpenGL for quite a while, and would like to know if I can use GLUT (or a similar lib) with C++ to simulate a console program in full screen mode (without borders and title bar). I don't want to make an OS, I just would like to know if it's possible to use OpenGL to make a virtual console that takes up the entire screen.

By the way, other methods have failed for me mostly because I'm running Win7. If anyone knows how to simulate a console program in C++ with OpenGL, please post your method here. Thanks for reading, and I hope you can help :)

thokra
06-17-2013, 01:49 AM
The notion of a "fullscreen" window is a platform-dependent, window-system specific feature. X11 does it differently than Windows. So the first problem, getting a fullscreen window, isn't an OpenGL problem and is actually not a problem at all.

The biggest problem with simulating anything involving text is that OpenGL doesn't natively support font rendering - at all. Usually this is solved by using some for of image(s) storing the visual approximation of characters which can then be used as data for a texture which is rendered onto a quad. Such images, or a single image if you're going to use an atlas (a single image comprising of multiple sub-images), can either be created by you, e.g. by drawing stuff in a paint program, or generated at runtime by a font rendering library such as FreeType2. Either way, you'll have to take care of handling generation and rendering of appropriate textures representing characters on you keyboard.

If you want to go really basic on this, it's merely rendering a black background and some white text on top of it, just like good old DOS. What do you need this for?

lmsmi1
06-17-2013, 10:22 AM
Well thokra, I've also looked into SDL for this, and am wondering if I can associate an image of a character to a keystroke, then print it to the screen when the key is pressed. I think the simplest way would be to make a full screen black BG, then associate keystrokes with images so while the user types, it prints the images to the screen. Then if the user pressed BS, it would remove the last image printed from the screen.

But what about aligning the images? Is there something special needed for this? (By the way, this is just for fun. I want to mess around and see what I can do with OpenGL and/or SDL.)

Deception
06-17-2013, 11:45 PM
Do a google search for freetype-gl. The source even has an example for a console.