diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d2fa96..fece6a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) project(${PNAME}) find_package(SFML ${SFML_VERSION} COMPONENTS ${SFML_COMPONENTS} REQUIRED) -include_directories(${SFML_INCLUDE_DIR}/include) + +include_directories(${SFML_INCLUDE_DIR}) include_directories(include) 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 (Game ${OpenCL_LIBRARY}) set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11 diff --git a/include/Vector3.h b/include/Vector3.h index 5232d2f..26bb241 100644 --- a/include/Vector3.h +++ b/include/Vector3.h @@ -130,11 +130,10 @@ public: typedef Vector3 Vector3i; typedef Vector3 Vector3f; -} + #endif -}; -#endif + diff --git a/src/main.cpp b/src/main.cpp index 139d4b2..fb577af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,11 +6,53 @@ #include "RayCaster.h" #include #include "Curses.h" +#include const int WINDOW_X = 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 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 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 (platformIds [0]), + 0, 0 + }; + + cl_context context = clCreateContext ( + contextProperties, deviceIdCount, + deviceIds.data (), nullptr, + nullptr, &error); + + +}; + + + + + + float elap_time(){ static std::chrono::time_point start; static bool started = false; @@ -49,7 +91,7 @@ void test_ray_reflection(){ return; } -int main() { +int main2() { // Initialize the render window Curses curse(sf::Vector2i(5, 5), sf::Vector2i(WINDOW_X, WINDOW_Y));