Skip to content

Commit

Permalink
examples/heightmap: Fixed Windows build
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Pecka <[email protected]>
  • Loading branch information
peci1 authored Sep 16, 2024
1 parent 03060ba commit 81761c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/heightmap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if (NOT APPLE)
link_directories(${GLEW_LIBRARY_DIRS})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()

configure_file (example_config.hh.in ${PROJECT_BINARY_DIR}/example_config.hh)

Expand Down
7 changes: 7 additions & 0 deletions examples/heightmap/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif

#include <iostream>
Expand All @@ -39,8 +41,13 @@
using namespace gz;
using namespace rendering;

#if not defined(_WIN32)
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "media");
#else
const std::string RESOURCE_PATH =
common::joinPaths(std::string(PROJECT_BINARY_PATH), "..", "media");
#endif

//////////////////////////////////////////////////
void createImageHeightmaps(const ScenePtr _scene, VisualPtr _root)
Expand Down
11 changes: 9 additions & 2 deletions tutorials/21_heightmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ It loads 2 different heightmaps (image and Digital Elevation Model (DEM)) with d

## Compile and run the example

Clone the source code, create a build directory and use `cmake` and `make` to compile the code:
Clone the source code, create a build directory and use `cmake` to compile the code:

```{.sh}
git clone https://github.com/gazebosim/gz-rendering
cd gz-rendering/examples/heightmap
mkdir build
cd build
cmake ..
make
# Linux
cmake --build .
# Windows
cmake --build . --config Release
```
Example 1 (image heightmap):

```{.sh}
# Linux
./heightmap
# Windows
.\Release\heightmap.exe
```

You'll see:
Expand Down

0 comments on commit 81761c5

Please sign in to comment.