Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

878798 Posts in 32936 Topics- by 24347 Members - Latest Member: harry)))

May 22, 2013, 04:47:54 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)A dos prompt next to my SDL game.
Pages: [1]
Print
Author Topic: A dos prompt next to my SDL game.  (Read 353 times)
indietom
Level 2
**

Tom


View Profile Email
« on: June 27, 2012, 09:45:42 AM »

Hi there!
I'am currently developing a game in C++ and SDL.
And I want to have a dos prompt in the background that sais what is going on in the game.
What input is going on what entity are getting created and so on.
I have a dos prompt up but it's just empty, I've included iosteam, and is using namespace std, and I've written "cout << "It's alive"; but the window is empty.
What could be the problem?


Logged

Code::Blocks
This is my profile, there are many like it but this one is mine.
zacaj
Level 3
***


void main()


View Profile WWW Email
« Reply #1 on: June 27, 2012, 11:05:14 AM »

There are a couple ways to do this.  Right now SDL is redirecting the output to stdout.txt.  The way I use is to just put "#undef main" right before your main function.  I've seen a few people who said that was bad, but I never got why, and I've never had problems. 
Logged

My twitter: @zacaj_

Quote from: mcc
Well let's just take a look at this "getting started" page and see--
Quote
Download and install cmake
Noooooooo
indietom
Level 2
**

Tom


View Profile Email
« Reply #2 on: June 27, 2012, 11:25:03 AM »

There are a couple ways to do this.  Right now SDL is redirecting the output to stdout.txt.  The way I use is to just put "#undef main" right before your main function.  I've seen a few people who said that was bad, but I never got why, and I've never had problems. 


Thnaks.
Logged

Code::Blocks
This is my profile, there are many like it but this one is mine.
Evan Balster
Level 10
*****


dreaming close to metal


View Profile WWW Email
« Reply #3 on: June 27, 2012, 11:52:40 AM »

On certain platforms SDL likes to do things before and after program execution; an alternate solution is to rewrite your main function like so:

Code:
int main ( int argc, char** argv )
{
    freopen( "CON", "w", stdout ); //on windows and mac

    // the rest of your code
}

You can also compile SDL with a certain flag (NOCONSOLE or something like that) and you won't even need to do the above.  That's how I do it, for reasons I don't recall.


If you're only developing for Windows, #undef main is probably fine though.
Logged

Infinite Blank, SoundSelf, Cave Story+, Wreath
voice, accordion, mandolin, (oboe, soon)
Game audio programming consultant.
<plaid/audio>: opensource audio framework
rivon
Level 10
*****



View Profile
« Reply #4 on: June 27, 2012, 12:04:28 PM »

You can use the #undef main only on Windows...
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic