Jump to content
Dozz

c++ no console

Recommended Posts

I'm a bit wary to change settings in visual c++ 2008 express. I want to disable the console window that displays loading shaders etc. but not sure how I do that. I want the splash screen to display straight away & not be interrupted by the console.

Thanks Dozz

Share this post


Link to post

1. In Linker/System/SubSystem change Console to Windows

 

2. In your code

 

change

int main( int argn, char* argv[] )

 

to

int CALLBACK WinMain(
 __in  HINSTANCE hInstance,
 __in  HINSTANCE hPrevInstance,
 __in  LPSTR lpCmdLine,
 __in  int nCmdShow
)

Share this post


Link to post

That did the trick, thanks Roland.

When I run the .exe the screen flashes black, then there is a delay of a few seconds before it runs. Is this the engine setting up? Even though it's only a few seconds, it bugs me. Is it typical for this to happen with Leadwerks? If so then so be it, else I will try invoking the splash screen earlier in the code. Thanks again.

Dozz

Share this post


Link to post

Loading a map take time, i was working this week in designing a splash screen, idk if somobody did this already, gotta check.

Share this post


Link to post

Instead of doing that complicated WinMain function, you can just use the main function and add the compiler option -mwindows for g++.

Share this post


Link to post

I'm a bit wary to change settings in visual c++ 2008 express. I want to disable the console window that displays loading shaders etc. but not sure how I do that. I want the splash screen to display straight away & not be interrupted by the console.

Thanks Dozz

Instead of doing that complicated WinMain function, you can just use the main function and add the compiler option -mwindows for g++.

You are not answering the question ;). As you see he's using Visual c++ 2008. There is no g++ there.

Share this post


Link to post

It's similar in Visual Studio also, there you can disable the console window with compiler settings without the need to write a WinMain functions. The easiest way is to use a compiler pragma like:

#pragma comment( linker, "/subsystem:"windows" /entry:"mainCRTStartup"" )

Share this post


Link to post

It's similar in Visual Studio also, there you can disable the console window with compiler settings without the need to write a WinMain functions. The easiest way is to use a compiler pragma like:

#pragma comment( linker, "/subsystem:"windows" /entry:"mainCRTStartup"" )

Yes. That's more relevant for Visual Studio and will work also if you find it more easy the WinMain function.

Share this post


Link to post

I think g++ is also related to Visual Studio though, that's why I mentioned that first: g++ is just a cheaper, better, faster Visual Studio.

Share this post


Link to post

Just in your opinion Lumooja.Visual Studio is also an IDE which has some good features.

But thats like your discussion about SDL, SDL_Net and so on ... another story.

 

I would use Rolands suggestion that makes it more clear its an windows project not console.

Share this post


Link to post
Guest Red Ocktober

not wanting to get into the msvc++ vs. gcc debate ... me thinks you guys are missing something quite obvious (console v. no console)...

 

if you choose to make a console project in msvc++, the startup code looks like this...

 

#include "engine.h"
int main( int argn, char* argv[] )

 

 

if you choose a to make a win version, it looks like this...

 

#include "engine.h"
int WINAPI WinMain( HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPSTR lpCmdLine,
 int nShowCmd )

 

 

 

if you don't want to display the console, choose a win project...

 

i don't see what the problem is... or am i missing the point of the question...

 

--Mike

Share this post


Link to post

not wanting to get into the msvc++ vs. gcc debate ... me thinks you guys are missing something quite obvious (console v. no console)...

 

if you choose to make a console project in msvc++, the startup code looks like this...

 

#include "engine.h"
int main( int argn, char* argv[] )

 

 

if you choose a to make a win version, it looks like this...

 

#include "engine.h"
int WINAPI WinMain( HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPSTR lpCmdLine,
 int nShowCmd )

 

 

 

if you don't want to display the console, choose a win project...

 

i don't see what the problem is... or am i missing the point of the question...

 

--Mike

Absolutely no problems, this is exactly what I told in my answer. The rest is more or less the old 'g++ is better', which is quite unneeded as answer to person asking about what to do in Visual Studio. Not really a 'thread rape' but ... :)

 

Anyway again. This is the way to do it.

Share this post


Link to post

not wanting to get into the msvc++ vs. gcc debate ... me thinks you guys are missing something quite obvious (console v. no console)...

 

if you choose to make a console project in msvc++, the startup code looks like this...

 

#include "engine.h"
int main( int argn, char* argv[] )

 

 

if you choose a to make a win version, it looks like this...

 

#include "engine.h"
int WINAPI WinMain( HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPSTR lpCmdLine,
 int nShowCmd )

 

 

 

if you don't want to display the console, choose a win project...

 

i don't see what the problem is... or am i missing the point of the question...

 

--Mike

 

Completly right, i just got the problem that lumooja says "oh its much easier in g++ use -mwindows". The Threadopener said he use Visual Studio and Roland showed him a good solution... i just dont get why lumooja has to go on his g++ crusade again.

 

Nobody says g++/linux is worse but in this case its about Visual Studio, thats my problem so far.

Share this post


Link to post

Hi guys,

 

I understand this is a very old thread, but I think main.cpp may have changed since, and in the interest of keeping things updated...

 

I've followed the answers to this question, but main.cpp uses argv and argc to do some setup prior to running the game. So, how would I go about setting up/adjusting the main.cpp?

 

After making the changes suggested by @Roland, there are errors in main.cpp on lines:

  • #44
  • #63
  • #66

...where you can see the usage of argv and argc.

 

I've attempted adding extra #ifdef and #ifndef checks for _DEBUG mode on these lines, and changing the code accordingly, but with no success.

 

Any help and guidance would be greatly appreciated! smile.png

 

Many thanks

Share this post


Link to post

In the current version of Leadwerks, you can disable the console window by putting this in main.cpp:

 

// This will remove the cmd window from showing up with our window.
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

Share this post


Link to post

In the current version of Leadwerks, you can disable the console window by putting this in main.cpp:

 

// This will remove the cmd window from showing up with our window.
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

That was a nice one. I always have replaced the main with WinMain, changed the subsystem and fixed the argv stuff. This is far better. Great

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...