Jump to content

c++ no console


Dozz
 Share

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

  • Upvote 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Roland Strålberg
Website: https://rstralberg.com

Link to comment
Share on other sites

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"" )

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Roland Strålberg
Website: https://rstralberg.com

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Roland Strålberg
Website: https://rstralberg.com

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

How come you guys don't use BSD and Java...?

 

 

 

I'm being SARCASTIC.

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

  • 4 years later...

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

Win7 64-bit | Intel i7-3770 3.40GHz | NVIDIA GeForce GTX 660

Link to comment
Share on other sites

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")

  • Upvote 3

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

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

  • Upvote 1

Roland Strålberg
Website: https://rstralberg.com

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...