Starting on OpenCL, got cmake to link it correctly, and started on
a minimal example
This commit is contained in:
@@ -12,13 +12,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
|||||||
project(${PNAME})
|
project(${PNAME})
|
||||||
find_package(SFML ${SFML_VERSION} COMPONENTS ${SFML_COMPONENTS} REQUIRED)
|
find_package(SFML ${SFML_VERSION} COMPONENTS ${SFML_COMPONENTS} REQUIRED)
|
||||||
|
|
||||||
include_directories(${SFML_INCLUDE_DIR}/include)
|
|
||||||
|
include_directories(${SFML_INCLUDE_DIR})
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
file(GLOB SOURCES "src/*.cpp")
|
file(GLOB SOURCES "src/*.cpp")
|
||||||
|
add_executable(${PNAME} ${SOURCES})
|
||||||
|
|
||||||
add_executable(${PNAME} ${SOURCES} include/Vector3.cpp include/Vector3.h)
|
# Handle OpenCL
|
||||||
|
find_package(OpenCL REQUIRED)
|
||||||
|
include_directories(${OpenCL_INCLUDE_DIRS})
|
||||||
|
link_directories(${OpenCL_LIBRARY})
|
||||||
|
|
||||||
target_link_libraries(${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
|
target_link_libraries(${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
|
||||||
|
target_link_libraries (Game ${OpenCL_LIBRARY})
|
||||||
|
|
||||||
set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11
|
set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11
|
||||||
|
|
||||||
|
|||||||
@@ -130,11 +130,10 @@ public:
|
|||||||
typedef Vector3<int> Vector3i;
|
typedef Vector3<int> Vector3i;
|
||||||
typedef Vector3<float> Vector3f;
|
typedef Vector3<float> Vector3f;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
44
src/main.cpp
44
src/main.cpp
@@ -6,11 +6,53 @@
|
|||||||
#include "RayCaster.h"
|
#include "RayCaster.h"
|
||||||
#include <Map.h>
|
#include <Map.h>
|
||||||
#include "Curses.h"
|
#include "Curses.h"
|
||||||
|
#include <OpenCL/opencl.h>
|
||||||
|
|
||||||
const int WINDOW_X = 150;
|
const int WINDOW_X = 150;
|
||||||
const int WINDOW_Y = 150;
|
const int WINDOW_Y = 150;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
|
||||||
|
// Get the number of platforms
|
||||||
|
cl_uint platformIdCount = 0;
|
||||||
|
clGetPlatformIDs(0, nullptr, &platformIdCount);
|
||||||
|
|
||||||
|
// Fetch the platforms
|
||||||
|
std::vector<cl_platform_id> platformIds (platformIdCount);
|
||||||
|
clGetPlatformIDs(platformIdCount, platformIds.data(), nullptr);
|
||||||
|
|
||||||
|
// get the number of devices, fetch them, choose the first one
|
||||||
|
cl_uint deviceIdCount = 0;
|
||||||
|
clGetDeviceIDs (platformIds [0], CL_DEVICE_TYPE_ALL, 0, nullptr,
|
||||||
|
&deviceIdCount);
|
||||||
|
std::vector<cl_device_id> deviceIds (deviceIdCount);
|
||||||
|
clGetDeviceIDs (platformIds [0], CL_DEVICE_TYPE_ALL, deviceIdCount,
|
||||||
|
deviceIds.data (), nullptr);
|
||||||
|
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
// Set the context's properties
|
||||||
|
const cl_context_properties contextProperties [] = {
|
||||||
|
CL_CONTEXT_PLATFORM,
|
||||||
|
reinterpret_cast<cl_context_properties> (platformIds [0]),
|
||||||
|
0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
cl_context context = clCreateContext (
|
||||||
|
contextProperties, deviceIdCount,
|
||||||
|
deviceIds.data (), nullptr,
|
||||||
|
nullptr, &error);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float elap_time(){
|
float elap_time(){
|
||||||
static std::chrono::time_point<std::chrono::system_clock> start;
|
static std::chrono::time_point<std::chrono::system_clock> start;
|
||||||
static bool started = false;
|
static bool started = false;
|
||||||
@@ -49,7 +91,7 @@ void test_ray_reflection(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main2() {
|
||||||
|
|
||||||
// Initialize the render window
|
// Initialize the render window
|
||||||
Curses curse(sf::Vector2i(5, 5), sf::Vector2i(WINDOW_X, WINDOW_Y));
|
Curses curse(sf::Vector2i(5, 5), sf::Vector2i(WINDOW_X, WINDOW_Y));
|
||||||
|
|||||||
Reference in New Issue
Block a user