# OpenGL Interoperability problem (CUDA11), error 304 occures when cuGraphicsGLRegisterBuffer

**URL:** <https://forums.developer.nvidia.com/t/opengl-interoperability-problem-cuda11-error-304-occures-when-cugraphicsglregisterbuffer/147962>\
**Category:** OpenGL\
**Tags:** cuda\
**Created:** [August 23, 2020, 10:31am UTC](https://forums.developer.nvidia.com/t/opengl-interoperability-problem-cuda11-error-304-occures-when-cugraphicsglregisterbuffer/147962 "2020-08-23T10:31:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![foroot\_08](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@foroot\_08](https://forums.developer.nvidia.com/u/foroot_08)\
**Post date:** [August 23, 2020, 10:31am UTC](https://forums.developer.nvidia.com/t/opengl-interoperability-problem-cuda11-error-304-occures-when-cugraphicsglregisterbuffer/147962/1 "2020-08-23T10:31:36Z")

</div>

hello everyone, I am a stranger to cuda and I have a problem about transfer cuda to opengl, I downloaded the video codec sdk and test the sample code AppDecGL, and it works fine, but the code attach below I wroted got an error of CUDA\_ERROR\_OPERATING\_SYSTEM when cuGraphicsGLRegisterBuffer invoked, I am so confused, may be the opengl version is not compatible? the opengl I use is opengl es 2.0 (angle libglesv2.dll), any help will be highly appreciated, thanks alot

```
    GLuint pbo = 0;
    glGenBuffers(1, &pbo );
    if (pbo <= 0)
        return;
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo );
    glBufferData(GL_PIXEL_UNPACK_BUFFER, nWidth * nHeight * 4, NULL, GL_STREAM_DRAW);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

    do
    {
        CUcontext cuda_ctx;
        CUdevice cuDevice = 0;
        if (CUDA_SUCCESS != cuDeviceGet(&cuDevice, 0))
            break;
        if (CUDA_SUCCESS != cuCtxCreate_v2(&cuda_ctx, CU_CTX_SCHED_BLOCKING_SYNC, cuDevice))
            break;
        if (CUDA_SUCCESS != cuCtxSetCurrent(cuda_ctx))
            break;
    } while (0);

    CUgraphicsResource cuResource;
    auto err = cuGraphicsGLRegisterBuffer(&cuResource, pbo, CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD);

```

---

<div class="post-metadata">

**Author:** ![foroot\_08](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@foroot\_08](https://forums.developer.nvidia.com/u/foroot_08)\
**Post date:** [August 27, 2020, 4:04am UTC](https://forums.developer.nvidia.com/t/opengl-interoperability-problem-cuda11-error-304-occures-when-cugraphicsglregisterbuffer/147962/2 "2020-08-27T04:04:06Z")

</div>

solved this problem，turns out to be cuda cannot interop with angle
