# Error converting GpuMat to Texture2D

**URL:** <https://forum.opencv.org/t/error-converting-gpumat-to-texture2d/1975>\
**Category:** C++\
**Tags:** gpumat, opengl, cuda\
**Created:** [March 5, 2021, 1:15pm UTC](https://forum.opencv.org/t/error-converting-gpumat-to-texture2d/1975 "2021-03-05T13:15:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuelcho](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/samuelcho/32/1264_2.png) [@samuelcho](https://forum.opencv.org/u/samuelcho)\
**Post date:** [March 5, 2021, 1:15pm UTC](https://forum.opencv.org/t/error-converting-gpumat-to-texture2d/1975/1 "2021-03-05T13:15:41Z")

</div>

Hi everyone! I’m trying to convert a GpuMat (3 channels, CV\_8U format) to a texture. I’m doing this:

```cpp
cv::ogl::Texture2D tex;
tex.copyFrom(GpuMat); 

```

The code compiles but I get this error at run time.  
`OpenCV(4.5.1) Error: Gpu API call (OS call failed or operation not supported on this OS) in 'anonymous-namespace'::CudaResource::registerBuffer, file C:\lib\opencv-4.5.1\modules\core\src\opengl.cpp, line176`

More Info  
OpenCV Version: 4.5.1, with CUDA and OpenGL, x64  
Cuda Version: 10.1  
Graphics card: GTX1650  
Visual Studio 2017

Does anyone know why this is? Thanks!
