It is currently Tue Dec 12, 2017 6:43 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 20 posts ] 
Author Message
 Post subject: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Thu Jul 13, 2006 6:59 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
This video shows how to create the C++ project using Microsoft Visual Studio 2003. The WinMain is created in this video.

If you plan on using Visual C++ 2005/2008 Express, then make sure you watch VMK 45to see all the code differences between the compilers.


Last edited by Marek on Wed Nov 04, 2009 5:52 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Mon Aug 14, 2006 7:27 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
I have been notified that in the main.cpp CoInitialize() and CoUninitialize() are not required. Also in stdafx.h you do not need the following: #include <winbase.h>


Last edited by Marek on Wed Nov 04, 2009 5:54 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Jul 04, 2007 3:54 pm 

Joined: Wed Jul 04, 2007 10:07 am
Posts: 3
In the section on precompiled headers, you never mentioned why you're using underscores in all your directory structures.

Also, though I follow what the function of a "mutex" does, what does it stand for?

Thanks for the great tutorials!


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Jul 04, 2007 4:12 pm 

Joined: Wed Jul 04, 2007 10:07 am
Posts: 3
It is also possible to make the existing code compatible in VC2005 by going to Project->Properties->Configuration Properties and change character set from Unicode to either "Not Set", or "Multi-Byte Character Set". This is useful if you're using lots of clips of old code. :-P


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Jul 04, 2007 6:36 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Why am I using underscores in the directory structures? Good question. I guess I didn't mention this but if you stick an underscore in front of debug then in windows when you sort your directories alphabetically, the underscored ones will be listed first. I like to do this so that it is easy to find the important _debug & _build directories. This is just a personal preference of mine though, you don't have to do this.



What does mutex stand for? Mutex is short for [b]mutual exclusion object[/b]. In computer programming, a mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. I grabbed this definition from http://www.webopedia.com/TERM/M/mutex.html


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Mon Aug 27, 2007 3:01 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
I started watching the videos again(this time with a different plan - I will now be typing along, but not to make the same engine, but to make my own engine that is based on yours)



Now, I came across your definition of WIN32_LEAN_AND_MEAN. Just to get my facts straight (I am not correcting you or anything), isn't WIN32_LEAN_AND_MEAN inside a precompiled header pretty redundant?


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Aug 29, 2007 4:13 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Why would you say it is redundant? By having the define in the precompiled header, you don't bloat your final .exe with unnecessary windows code.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Aug 29, 2007 4:37 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
From what I've read the optimasation of the compiler should take all that's not necesary out anyway - the WIN32_LEAN_AND_MEAN command is just there to reduce compile time.



I will test this myself, by just making a program with and without it and have a look at the difference.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Aug 29, 2007 4:42 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Hmmm, interesting. I'm interested to see your results.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Aug 29, 2007 4:50 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
It does not make a difference in the size of the executable - so I guess that means it does not make any difference once you have compiled (and most importantly, linked) it


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Fri Sep 14, 2007 10:45 am 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 19
@Jasper, @Marek



The WIN32_LEAN_AND_MEAN definition excludes extraneous MFC includes. All the details can be read here -> http://msdn2.microsoft.com/en-us/library/6dwk3a1z(vs.71).aspx


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Fri Nov 02, 2007 4:38 pm 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
sure StaticHash, but we were discussing if this would in the end have consequences for the executable or it would only influence the time it took to compile.

Now, the real reason for which I am posting. Confronted with some size differences between compilers I did some research.

I was building a tutorial project I followed quite some time ago using MinGW, and it was 2 mB, which is quite a lot for a relatively simple command line program, so I checked how much space it took when I compiled the same file with Visual Studio... and that was a lot way below 1 mB. After some testing I found that standard (such as windows.h) includes add explosively to the file size.

So... was what I said before (all unused functions are taken out by the linker) not true? No. Because by the Visual Studio compiler they are taken out (both in version 6.0 and 2005 (=8.0) and by gcc/minGW they are not. I was not able to configure Microsoft's product to not do this "optimisation", while I was able to configure the open source do the "optimisation", using the -s option (strip all symbols). Using this option debugging is not an option, though...


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Nov 14, 2007 9:50 pm 

Joined: Thu Sep 13, 2007 10:38 pm
Posts: 19
Jasper

In Visual Studio 6 and 2005 you set your project configuration to RELEASE and your resulting executable file size is much smaller since you don't get all the debugging symbols included as you do when the configuration is in DEBUG. I think the default project config is DEBUG so you have to explicitly set it to RELEASE after you are finished debugging to get the smaller executable.

Is that what you were talking about?

Hope that helps.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Mar 09, 2008 8:08 am 

Joined: Tue Feb 26, 2008 3:30 am
Posts: 3
I didn't know about the mutex solution.

My solution was using Process32First and Process32Next to search the processes for the exe filename of my game. If there is a process with the same name as my game, it means that the game is already running. Then the user have the option to terminate the other game and start a new game process, or just abort.

If the user choose to end the other game process, it just sends a WM_CLOSE message and if that fails, it uses TerminateProcess to force it to close (in case the other game have crashed and won't respond).

But one disadvantage of that solution is if there are a process with the exact same exe filename as my game that isn't a copy of my game. Then it will close that process.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Apr 18, 2008 6:03 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
Mutexes (mutices?) are really the correct way to communicate between processes. (or threads...)
However, you should never be so aggressive as to force the other process to close. Just leave that as the main thread. If you really want to be be able to handle a hung process do something like firefox does: if the mutex is registered, it registers another mutex ("new process started here") and the original process respond to that by creating a new window (which makes no sense in your case) and then responding with registering a third mutex ("okey, made a new window"). Once that is done, the new process shuts down - but if the old process does not respond, the new process displays a message ("Firefox is stuck, get the original to shut down first"). Even though I would indeed recommend such a message, you might be afraid people won't know what to do with it and you could then force a quit.


disclaimer: This is only part of what Firefox does, firefox also includes a part that is based on files rather than mutexes.


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 8:03 pm 

Joined: Wed Nov 26, 2008 7:43 pm
Posts: 2
I recently started watching these videos, and something came to my mind... the strong point about using opengl is that it's multiplatform, so i decided to follow these videos and try to modify them to try to make it multiplatform...

So far I havent been too successfull.

For this first video, I found Boost libs to get access to named mutexes and they work really fine.

For the MessageBox part... well, I've tried Qt and wxWidgets. I couldn't even compile my project using Qt becouse declarations on the includes conflicted with Boost. wxWidgets was another story, I can compile and link, but it break at runtime if my exception-catching code tries to launch a wxMessageBox (which is supposed to just be a wrapped up version of the native windows MessageBox as far as I've read) which in time launches another exception getting a pretty "Windows found an error blablabla" dialog. Using the windows native MessageBox works well. Tomorrow I will try GTK+ just in case I get it to work.

For the rest of the game engine I've thought about using SDL.

I'm using Eclipse 3.4 as my IDE and mingw/gdb as my compiler/debugger.

Should I give up on this and stick to windows only or maybe try to convert all this to java?

Any help regarding my prevous issues would we welcome! Thanks!


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Wed Nov 04, 2009 2:18 am 

Joined: Wed Oct 28, 2009 3:51 am
Posts: 1
Marek wrote:
It has been brought to my attention that the szGameName variable will cause compiler errors for VC++ 2005 users, since that version uses unicode by default. Make it an array of TCHAR's instead of char's.


an alternative is to use the CreateMutexA and MessageboxA functions to use ANSI encoding rather then Unicode


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 1 - Creating FPS Game Engine Project
PostPosted: Sun Jan 31, 2010 8:15 am 

Joined: Sun Jan 31, 2010 7:37 am
Posts: 2
Location: Russia, Murom
Jasper wrote:
sure StaticHash, but we were discussing if this would in the end have consequences for the executable or it would only influence the time it took to compile.

Now, the real reason for which I am posting. Confronted with some size differences between compilers I did some research.

I was building a tutorial project I followed quite some time ago using MinGW, and it was 2 mB, which is quite a lot for a relatively simple command line program, so I checked how much space it took when I compiled the same file with Visual Studio... and that was a lot way below 1 mB. After some testing I found that standard (such as windows.h) includes add explosively to the file size.

So... was what I said before (all unused functions are taken out by the linker) not true? No. Because by the Visual Studio compiler they are taken out (both in version 6.0 and 2005 (=8.0) and by gcc/minGW they are not. I was not able to configure Microsoft's product to not do this "optimisation", while I was able to configure the open source do the "optimisation", using the -s option (strip all symbols). Using this option debugging is not an option, though...


MinGW don't include unused function in release mode.

My Reseach =)
I'm wrote a MyWin.h that keep only used function.

 Exe size
               windows.h     windows.h with Lean and mean    MyWin.h
Debug      1.98MB                       1.37MB                        648KB
Release    271KB                       271KB                          271KB


Sorry for necroposting and my english =)


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2010 3:45 pm 

Joined: Sun Apr 18, 2010 11:46 am
Posts: 8
I'm on the main-13.swf. When I try to compile I get the error messages:

"main.cpp(9) : error C2664: 'CreateMutexW' : cannot convert parameter 3 from 'char [13]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"

and

"main.cpp(16) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [60]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"

I can't figure out exactly what the problem is.

I'm pretty sure I wrote the same code as you, but just to be sure, here is the code for the main.cpp:

#include "stdafx.h"

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
   char szGameName[] = {"Name of Game"};
   //prevent multiple start ups
   HANDLE hMutex;
   CoInitialize(NULL);
   hMutex=CreateMutex(NULL, FALSE, szGameName);
   if (hMutex == NULL || ( GetLastError() == ERROR_ALREADY_EXISTS))
   {
      CloseHandle(hMutex);
      MessageBox(NULL,"Application has already been\n"
                  "started in a different window.",
                  "Application Already Running",
                  MB_ICONWARNING | MB_OK);
      return 1;
   }

   //game code

   //close this unique program to allow it to restart again.
   CloseHandle(hMutex);
   CoUninitialize();

   return 0;
}


Any ideas?

PS: I'm using 2008 Express Edition if it makes a difference.

!!! EDIT: I think I kind of fixed the problem. I changed the character set from Unicode to no set. It compiles fine now. Still, I'm a little nervous. Can anyone tell me why this fixes the problem?


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2010 6:31 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
AdamD wrote:
Any ideas?

PS: I'm using 2008 Express Edition if it makes a difference.

!!! EDIT: I think I kind of fixed the problem. I changed the character set from Unicode to no set. It compiles fine now. Still, I'm a little nervous. Can anyone tell me why this fixes the problem?


You've got the right solution. If you watch VMK45 http://www.marek-knows.com/downloadSect ... GameDev139 it tells you everything you need to know.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 20 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron