3d-game-shaders-for-beginners
3d-game-shaders-for-beginners copied to clipboard
How to configure builds for Windows users
There are probably still people who want to run this project on Windows. So I tell you how I tried
It works in VS2022 (msvc v143), so it works in most cases
- Clone this project and install Panda3D(1.10.9)
git clone https://github.com/lettier/3d-game-shaders-for-beginners.git
- Open the visual studio
- Create new c++ empty project
- project name: whatever you want
- location:
{cloned directory}\demonstration
- check "place solution and project in the same directory"
- Move
demonstration\src\main.cxx
to the project directoy - Add to the project by 'Add Existing File'
- Open
main.cxx
and comment out#include <unistd.h>
- Change "Debug" to "Release" below the menu bar
- Open up the project configuration pages
- Change output directory to
$(SolutionDir)..\
in the General tab - Add
PATH=C:\Panda3D-1.10.9-x64\bin;%PATH%
in the Debugging tab -> Environment - Add
C:\Panda3D-1.10.9-x64\include
in the VC++ directory tab -> External include directoies - Add
C:\Panda3D-1.10.9-x64\lib
in the VC++ directories tab -> Library directories - Add the path below in the Linker tab -> input -> Additional Dependencies
C:\Panda3D-1.10.9-x64\lib\libp3framework.lib C:\Panda3D-1.10.9-x64\lib\libpanda.lib C:\Panda3D-1.10.9-x64\lib\libpandaexpress.lib C:\Panda3D-1.10.9-x64\lib\libp3dtool.lib C:\Panda3D-1.10.9-x64\lib\libpandaphysics.lib C:\Panda3D-1.10.9-x64\lib\libp3dtoolconfig.lib C:\Panda3D-1.10.9-x64\lib\libp3openal_audio.lib
- Build the project
- Execute the binary file (.exe) created in
{cloned directory}\demonstration
Thank you for the detailed instructions.
For those using CMake: Here is my solution to avoid manual project configuration. See CMakeLists.txt for usage instructions.
don't forget to choose the solution platform to x64 if the original is x86
If using a different version of Panda3D, please note the filename prefix, may be different from “Panda3D-1.10.9-x64”
@StarJade-Park thanks to make this explicit for newbies. very appreciated!
Minor nitpick.
C:\Panda3D-1.10.9-x64\lib\libp3framework.lib
C:\Panda3D-1.10.9-x64\lib\libpanda.lib
C:\Panda3D-1.10.9-x64\lib\libpandaexpress.lib
C:\Panda3D-1.10.9-x64\lib\libp3dtool.lib
C:\Panda3D-1.10.9-x64\lib\libpandaphysics.lib
C:\Panda3D-1.10.9-x64\lib\libp3dtoolconfig.lib
C:\Panda3D-1.10.9-x64\lib\libp3openal_audio.lib
You don't have to hardcode the path. Since we define the path in the Additional Lib Directories, they will be found there.
Also, if you don't want to change the output directory, change current working directory in Debugging settings to $(ProjectDir)demonstration. Sidenote, this will work for everything apart Shaders. Shader::load expects a path next to the executable, so change the relative paths in loadShader by appending "../../demonstration/" to the "shaders/..." strings. I didn't go through the code, perhaps sth changes cwd prior to loading shaders and it's not a Shader::load issue.
UPDATE: Upon further investigation, the prc file contains a model path ($MAIN_DIR) which seems to be the place that VFS defaults to and that MAIN_DIR points to the binary's path and is set here: https://github.com/panda3d/panda3d/blob/4da2059758267a91cfa7fc91bc77b9332eb280dd/dtool/src/dtoolutil/executionEnvironment.cxx#L296
All loaders seem to call upon VFS (VirtualFileSystem) to resolve the relative filenames, although shader is the only place vfs::find_file is called, while all the others call resolve_filename which internally calls find_file....
VFS internally has its own cwd. Although I didn't figure out why the rest of the assets resolve properly while the shaders don't. I think I'll stop here. To do anything further, I'd have to rebuild panda and navigate using debugger to make any sense and it just sounds like a lot of work xD.