| 91 | } |
| 92 | |
| 93 | void 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 | |
| 128 | void ImageWidget::resizeGL(int width, int height) |
| 129 | { |
nothing calls this directly
no test coverage detected