123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_BUFFER_HPP
- #define BOOST_COMPUTE_INTEROP_OPENGL_OPENGL_BUFFER_HPP
- #include <boost/compute/buffer.hpp>
- #include <boost/compute/interop/opengl/gl.hpp>
- #include <boost/compute/interop/opengl/cl_gl.hpp>
- namespace boost {
- namespace compute {
- class opengl_buffer : public buffer
- {
- public:
-
- opengl_buffer()
- : buffer()
- {
- }
-
- explicit opengl_buffer(cl_mem mem, bool retain = true)
- : buffer(mem, retain)
- {
- }
-
-
-
-
- opengl_buffer(const context &context,
- GLuint bufobj,
- cl_mem_flags flags = read_write)
- {
- cl_int error = 0;
- m_mem = clCreateFromGLBuffer(context, flags, bufobj, &error);
- if(!m_mem){
- BOOST_THROW_EXCEPTION(opencl_error(error));
- }
- }
-
- opengl_buffer(const opengl_buffer &other)
- : buffer(other)
- {
- }
-
- opengl_buffer& operator=(const opengl_buffer &other)
- {
- if(this != &other){
- buffer::operator=(other);
- }
- return *this;
- }
-
- ~opengl_buffer()
- {
- }
-
-
-
- GLuint get_opengl_object() const
- {
- GLuint object = 0;
- clGetGLObjectInfo(m_mem, 0, &object);
- return object;
- }
-
-
-
- cl_gl_object_type get_opengl_type() const
- {
- cl_gl_object_type type;
- clGetGLObjectInfo(m_mem, &type, 0);
- return type;
- }
- };
- namespace detail {
- template<>
- struct set_kernel_arg<opengl_buffer> : set_kernel_arg<memory_object> { };
- }
- }
- }
- #endif
|