diff --git a/CMakeLists.txt b/CMakeLists.txt index fece6a9..e82930c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,39 @@ -set(PNAME Game) - -set(SFML_ROOT root CACHE STRING "User specified path") +# Check versions +message(STATUS "CMake version: ${CMAKE_VERSION}") +cmake_minimum_required(VERSION 3.1) -set(SFML_VERSION 2.1) +# Set the project name +set(PNAME Game) +project(${PNAME}) +# Set up variables, and find SFML +#set(SFML_ROOT root CACHE STRING "User specified path") set(SFML_COMPONENTS graphics window system network audio) - -cmake_minimum_required(VERSION 3.0) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +find_package(SFML 2.1 COMPONENTS ${SFML_COMPONENTS} REQUIRED) +message(STATUS "SFML found: ${SFML_FOUND}") -project(${PNAME}) -find_package(SFML ${SFML_VERSION} COMPONENTS ${SFML_COMPONENTS} REQUIRED) +# Find OpenCL +find_package( OpenCL REQUIRED ) +message(STATUS "OpenCL found: ${OPENCL_FOUND}") +# Find OpenGL +find_package( OpenGL REQUIRED) +message(STATUS "OpenGL found: ${OPENGL_FOUND}") +# Include the directories for the main programs headers, and SFML's headers include_directories(${SFML_INCLUDE_DIR}) include_directories(include) + +# Set the .cpp sources file(GLOB SOURCES "src/*.cpp") add_executable(${PNAME} ${SOURCES}) -# Handle OpenCL -find_package(OpenCL REQUIRED) -include_directories(${OpenCL_INCLUDE_DIRS}) -link_directories(${OpenCL_LIBRARY}) - +# Link CL, GL, and SFML target_link_libraries(${PNAME} ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) -target_link_libraries (Game ${OpenCL_LIBRARY}) +target_link_libraries (${PNAME} ${OpenCL_LIBRARY}) +target_link_libraries (${PNAME} ${OpenGL_LIBRARY}) +# Setup to use C++11 set_property(TARGET ${PNAME} PROPERTY CXX_STANDARD 11) # Use C++11 diff --git a/src/main.cpp b/src/main.cpp index fb577af..92d2176 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,23 @@ const int WINDOW_Y = 150; int main(){ + cl_uint num_devices, i; + clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices); + + cl_device_id* devices = (cl_device_id*)calloc(sizeof(cl_device_id), num_devices); + clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, num_devices, devices, NULL); + + char buf[128]; + for (i = 0; i < num_devices; i++) { + clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 128, buf, NULL); + fprintf(stdout, "Device %s supports ", buf); + + clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, 128, buf, NULL); + fprintf(stdout, "%s\n", buf); + } + + free(devices); + // Get the number of platforms cl_uint platformIdCount = 0; clGetPlatformIDs(0, nullptr, &platformIdCount);