diff --git a/include/OpenCL.h b/include/OpenCL.h index 3d1ee9b..3975d30 100644 --- a/include/OpenCL.h +++ b/include/OpenCL.h @@ -51,10 +51,10 @@ public: bool compile_kernel(std::string kernel_path, std::string kernel_name); // Create an image buffer from an SF texture. Access Type is the read/write specifier required by OpenCL - bool create_image_buffer(std::string buffer_name, sf::Texture* texture, cl_int access_type); + bool create_image_buffer_from_texture(std::string buffer_name, sf::Texture* texture, cl_int access_type); // Have CL create and manage the texture for the image buffer. Access Type is the read/write specifier required by OpenCL - bool create_image_buffer(std::string buffer_name, sf::Vector2i size, cl_int access_type); + bool create_image_buffer(std::string buffer_name, sf::Vector2i size, sf::Vector2f position, cl_int access_type); // Create a buffer with CL_MEM_READ_ONLY and CL_MEM_COPY_HOST_PTR int create_buffer(std::string buffer_name, cl_uint size, void* data); diff --git a/src/OpenCL.cpp b/src/OpenCL.cpp index 77f06bd..ef71787 100644 --- a/src/OpenCL.cpp +++ b/src/OpenCL.cpp @@ -226,7 +226,7 @@ bool OpenCL::compile_kernel(std::string kernel_path, std::string kernel_name) { return true; } -bool OpenCL::create_image_buffer(std::string buffer_name, sf::Texture* texture, cl_int access_type) { +bool OpenCL::create_image_buffer_from_texture(std::string buffer_name, sf::Texture* texture, cl_int access_type) { if (buffer_map.count(buffer_name) > 0) { release_buffer(buffer_name); @@ -249,7 +249,7 @@ bool OpenCL::create_image_buffer(std::string buffer_name, sf::Texture* texture, } -bool OpenCL::create_image_buffer(std::string buffer_name, sf::Vector2i size, cl_int access_type) { +bool OpenCL::create_image_buffer(std::string buffer_name, sf::Vector2i size, sf::Vector2f position, cl_int access_type) { if (buffer_map.count(buffer_name) > 0) { release_buffer(buffer_name); @@ -270,8 +270,9 @@ bool OpenCL::create_image_buffer(std::string buffer_name, sf::Vector2i size, cl_ return false; sf::Sprite sprite(*texture); + sprite.setPosition(position); - image_map[buffer_name] = std::pair>(sf::Sprite(*texture), std::move(texture)); + image_map[buffer_name] = std::pair>(sprite, std::move(texture)); store_buffer(buff, buffer_name); diff --git a/src/main.cpp b/src/main.cpp index a17f954..808d00b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,7 +47,7 @@ int main() { std::cin.get(); } - cl.create_image_buffer("viewport_image", image_resolution, CL_MEM_WRITE_ONLY); + cl.create_image_buffer("viewport_image", image_resolution, sf::Vector2f(100, 100), CL_MEM_WRITE_ONLY); cl.create_buffer("image_res", sizeof(sf::Vector2i), &image_resolution); cl.create_buffer("range", sizeof(sf::Vector4f), (void*)&range, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR);