Using the Console Window With SDL

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Using the Console Window With SDL

Post by XianForce »

So I've been wanting to get a console window working with SDL for quite some time now, and I've gone through a few google searches, but can't really find a concise answer.

So does anyone know how to get it working? Or have a link to an article/tutorial on it?
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Using the Console Window With SDL

Post by Ginto8 »

XianForce wrote:So I've been wanting to get a console window working with SDL for quite some time now, and I've gone through a few google searches, but can't really find a concise answer.

So does anyone know how to get it working? Or have a link to an article/tutorial on it?
If by "console window" you mean the terminal that comes up when you sometimes start the app, you can't really use it, primarily due to the fact that stdout and stderr are both redirected to files by SDL. If you mean an in-game console, lazyfoo has a tutorial on text input in SDL: http://www.lazyfoo.net/SDL_tutorials/lesson23/index.php
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Using the Console Window With SDL

Post by XianForce »

Ginto8 wrote:
XianForce wrote:So I've been wanting to get a console window working with SDL for quite some time now, and I've gone through a few google searches, but can't really find a concise answer.

So does anyone know how to get it working? Or have a link to an article/tutorial on it?
If by "console window" you mean the terminal that comes up when you sometimes start the app, you can't really use it, primarily due to the fact that stdout and stderr are both redirected to files by SDL. If you mean an in-game console, lazyfoo has a tutorial on text input in SDL: http://www.lazyfoo.net/SDL_tutorials/lesson23/index.php
I meant the terminal. And I know it's rerouted, but I thought there was a way to 're'reroute it... hmmm
User avatar
combatant936
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Wed Jul 29, 2009 11:11 pm
Current Project: It's a secret!!
Favorite Gaming Platforms: N64, SNES, PS2, PC
Programming Language of Choice: C++, 65816 asm
Location: Pennsylvania
Contact:

Re: Using the Console Window With SDL

Post by combatant936 »

If you're using Visual Studio you can set it up to use the console window.

Go to project->properties and under configuration properties go to linker then system.
Where it says "SubSystem", change that to "Console (/SUBSYSTEM:CONSOLE)".

That will make a console window come up along with the SDL window and you can use iostream or whatever you want.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Using the Console Window With SDL

Post by dandymcgee »

XianForce wrote:
Ginto8 wrote:
XianForce wrote:So I've been wanting to get a console window working with SDL for quite some time now, and I've gone through a few google searches, but can't really find a concise answer.

So does anyone know how to get it working? Or have a link to an article/tutorial on it?
If by "console window" you mean the terminal that comes up when you sometimes start the app, you can't really use it, primarily due to the fact that stdout and stderr are both redirected to files by SDL. If you mean an in-game console, lazyfoo has a tutorial on text input in SDL: http://www.lazyfoo.net/SDL_tutorials/lesson23/index.php
I meant the terminal. And I know it's rerouted, but I thought there was a way to 're'reroute it... hmmm

Code: Select all

freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );
Toss that in there somewhere. Works for output.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

Re: Using the Console Window With SDL

Post by davidthefat »

If you use codeblocks, the debug build always has the console window, the release build does not
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Using the Console Window With SDL

Post by Falco Girgis »

Both visual studio and xcode still allow virtual terminals for standard output with the correct type of project...
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: Using the Console Window With SDL

Post by XianForce »

GyroVorbis wrote:Both visual studio and xcode still allow virtual terminals for standard output with the correct type of project...

Wow... Are you kidding me?

I just tried it and it worked.

I tried it like a few months ago and got a BSOD... lol


Well thanks for that then
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Using the Console Window With SDL

Post by eatcomics »

XianForce wrote: I tried it like a few months ago and got a BSOD... lol
:shock: there's no way your program did that, there's something else going on there
Image
Post Reply