Optimize color changing with OpenMP.
This commit is contained in:
parent
766a2d597c
commit
e1f7cbaa1d
@ -39,6 +39,7 @@ set(OpenGL_GL_PREFERENCE "GLVND")
|
|||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLUT REQUIRED)
|
find_package(GLUT REQUIRED)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
|
find_package(OpenMP REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_search_module(SDL2 REQUIRED sdl2)
|
pkg_search_module(SDL2 REQUIRED sdl2)
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ set(SRCS
|
|||||||
"src/simulation.cpp")
|
"src/simulation.cpp")
|
||||||
|
|
||||||
# Define C++ compiler flags
|
# Define C++ compiler flags
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wextra -Wpedantic -Wfatal-errors -Werror -pedantic-errors -fno-elide-constructors")
|
set(CMAKE_CXX_FLAGS "-std=c++11 ${OpenMP_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wfatal-errors -Werror -pedantic-errors -fno-elide-constructors")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
|
||||||
|
@ -84,6 +84,7 @@ void cube::render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cube::shift_colors() {
|
void cube::shift_colors() {
|
||||||
|
#pragma omp parallel for
|
||||||
for(size_t i = 0; i < colors.size(); ++i)
|
for(size_t i = 0; i < colors.size(); ++i)
|
||||||
{
|
{
|
||||||
colors[i] += color_ascending[i] ? color_shift :
|
colors[i] += color_ascending[i] ? color_shift :
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const float color_shift = 0.0001;
|
const float color_shift = 0.005;
|
||||||
void shift_colors();
|
void shift_colors();
|
||||||
|
|
||||||
// OpenGL buffers
|
// OpenGL buffers
|
||||||
|
Loading…
Reference in New Issue
Block a user