Enable OpenMP

Use proper loop variable types
Fixes #759
This commit is contained in:
Sascha Willems 2020-09-17 13:55:26 +02:00
parent 3cb3df4cbf
commit 5b357931ec
2 changed files with 8 additions and 3 deletions

View file

@ -11,6 +11,7 @@ function(buildExample EXAMPLE_NAME)
if(EXISTS ${EXAMPLE_FOLDER}/${EXAMPLE_NAME}.h)
SET(MAIN_HEADER ${EXAMPLE_FOLDER}/${EXAMPLE_NAME}.h)
ENDIF()
find_package(OpenMP)
# imgui example requires additional source files
IF(${EXAMPLE_NAME} STREQUAL "imgui")
file(GLOB ADD_SOURCE "../external/imgui/*.cpp")
@ -38,6 +39,10 @@ function(buildExample EXAMPLE_NAME)
endif(WIN32)
set_target_properties(${EXAMPLE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
if(OpenMP_CXX_FOUND)
message(STATUS "OpenMP found")
target_compile_options(${EXAMPLE_NAME} PRIVATE ${OpenMP_CXX_FLAGS})
endif()
if(RESOURCE_INSTALL_DIR)
install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -308,11 +308,11 @@ public:
const float noiseScale = static_cast<float>(rand() % 10) + 4.0f;
#pragma omp parallel for
for (uint32_t z = 0; z < texture.depth; z++)
for (int32_t z = 0; z < texture.depth; z++)
{
for (uint32_t y = 0; y < texture.height; y++)
for (int32_t y = 0; y < texture.height; y++)
{
for (uint32_t x = 0; x < texture.width; x++)
for (int32_t x = 0; x < texture.width; x++)
{
float nx = (float)x / (float)texture.width;
float ny = (float)y / (float)texture.height;