sdf-baking
sdf-baking copied to clipboard
Various build problems with VS 2022 and possible version mismatch with dwSampleFramework
I've had a few problems getting this to compile with VS 2022 on Windows 10 and I've worked through them, but I wanted to document them for you.
Required VS features
First, it might be worth noting in the README that VS 2022 apparently needs to be told explicitly to install the following, under "Tools" -> "Get Tools and Features" :
- "C++ CMake tools for Windows" (I think it's required but not positive)
- "Windows 10 SDK"
"WIN32" undefined
Dependencies fail to compile because "WIN32" is not defined (i.e. if defined(WIN32)
and #ifdef WIN32
return false). I just slapped add_definitions(-DWIN32)
into CMakeLists.txt
but I imagine there's a proper way to fix this.
Build flags
The build failed without the /EHsc
flag. I ended up building with:
cmake -DCMAKE_CXX_FLAGS="/EHsc" -G "Visual Studio 17 2022" ..
dwSampleFramework problem
In main.cpp
, this line kept it from compiling:
m_bake_sdf_program->set_uniform("u_VolumeSize", volume_size);
There was no suitable overload for set_uniform
in dwSampleFramework.
I declared this (in dwSampleFramework) in ogl.h
:
bool set_uniform(std::string name, glm::ivec3 value);
and defined this in olg.cpp
:
bool Program::set_uniform(std::string name, glm::ivec3 value)
{
if (m_location_map.find(name) == m_location_map.end())
return false;
glUniform3i(m_location_map[name], value.x, value.y, value.z);
return true;
}
Everything looks fine now. Thanks for sharing this example.