MCPcopy Create free account
hub / github.com/boostorg/compute / initializeGL

Method initializeGL

example/resize_image.cpp:93–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void ImageWidget::initializeGL()
94{
95 // setup opengl
96 glDisable(GL_LIGHTING);
97
98 // create the OpenGL/OpenCL shared context
99 context_ = compute::opengl_create_shared_context();
100
101 // get gpu device
102 compute::device gpu = context_.get_device();
103 std::cout << "device: " << gpu.name() << std::endl;
104
105 // setup command queue
106 queue_ = compute::command_queue(context_, gpu);
107
108 // allocate image on the device
109 compute::image_format format =
110 compute::qt_qimage_format_to_image_format(qt_image_.format());
111
112 image_ = compute::image2d(
113 context_, qt_image_.width(), qt_image_.height(), format, CL_MEM_READ_ONLY
114 );
115
116 // transfer image to the device
117 compute::qt_copy_qimage_to_image2d(qt_image_, image_, queue_);
118
119 // setup image sampler (use CL_FILTER_NEAREST to disable linear interpolation)
120 sampler_ = compute::image_sampler(
121 context_, false, CL_ADDRESS_NONE, CL_FILTER_LINEAR
122 );
123
124 // build resize program
125 program_ = compute::program::build_with_source(source, context_);
126}
127
128void ImageWidget::resizeGL(int width, int height)
129{

Callers

nothing calls this directly

Calls 11

image2dClass · 0.85
image_samplerClass · 0.85
formatMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
command_queueClass · 0.50
get_deviceMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected