Jump to content
  • Advertisement

Problems with sample projects from book "Programming a multiplayer fps in directx"

Recommended Posts


I have a few problems trying to run the samples from the book "Programming a Multiplayer FPS in DirectX".

I have directx 9.0c installed and use windows 10.

I can run the sample project 7 and the projects from chapter 2 - 5, but have problems with projects 6 and 7 - 10.

After I compile any of those and click on the according exe files in the debug folder they close immediately after the initial dialog.

Furthermore, I get the following error, when trying to compile the last 2 projects:

"The value of ESP was not properly saved across a function call".

I greatly appreciate any help!





Edited by NeedHelp12

Share this post

Link to post
Share on other sites

Try first
Make sure to use the recommended Microsoft build tools when building Direct3D projects and check return values for error codes that will give a clue. If static C++ libraries are called from code compiled from another compiler, it might cause opposing call paradigms regarding the stack pointer (ESP).

Deeper explanation
The stack pointer is used to allocate data on the stack on top of the frame pointer at the method's beginning. (Up might be a negative address depending on the hardware, but the stack metaphor still holds) Variables are loaded from stack memory into registers using constant address offsets relative to the frame pointer. The stack pointer increases (or decreases if up is negative) when allocating more on the stack and can become the new frame pointer when making a call to another function. The program counter (caller address) and stack pointer is also saved on the stack which allow getting back and restore the registers. All this can be heavily optimized by the compiler given that the same calling strategy is used by both caller and receiver. Dynamic link libraries have defined the interface for this using an ABI, but such a standard doesn't exist when using static libraries because a library is just a packet of object files that someone compiled without linking.

Edited by Dawoodoz

Share this post

Link to post
Share on other sites

Could you investigate what the difference is between examples 1-5 and 6-up? This could be include files, linked libraries, and compiler settings. Try to find the 'special feature' that is introduced and what its dependencies are. You also may have to recompile some external libraries yourself.

Share this post

Link to post
Share on other sites

I am both compiling the samples with visual c++ 6 and visual studio 2005.

Each solution from chapter 1 to 10 is made up of 2 projects: Engine and Test

The output of the engine project is a lib file, while the output of the test project is an exe file.

The last 3 chapters 11 -13 deal with making a fps game and the sln files consist of

a single project called "game". This project uses the engine library file.


I can compile and execute samples 2-5 wthout any problems in both vs6 and vs2005.

However I cannot execute the rest of the samples. The exe files quit right after the inital dialog. Only compiling and subsequent running of the samples works until chapter 10. 

Additionally I cannot compile the projects in vs6 from chapter 5 onwards using the library file "d3dx9dt.lib".

I need to replace it with "d3dx9.lib".

When trying to compile the last 3 sample projects I get the error: "The value of ESP was not properly saved across a function call".

I have also recompiled the engine library file for the last 3 projects, but then I get additional errors...

Edited by NeedHelp12

Share this post

Link to post
Share on other sites

Make sure you are always linking the proper library versions for debug and release mode. D3d__d.lib usually is the debug version. Set this correctly in your project settings. Try to compile in both modes and see if there's a difference.

At least you should be able to recompile the engine lib in both modes without compiler errors. This will also produce 2 libs which you should properly link for each mode.

Otherwise, there is likely some other library involved that doesn't comply with your calling convention. Check your project settings for additional libs and see if anything is dynamically loaded from code. You could even inspect your compiled exe with dependency walker.

Hope this helps, otherwise you might need to narrow the problem down.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!