Setting Pixels on screen within Cuda

i am really new to coding with cuda so I don’t know if this is even possible. I am trying to write a Rendering Engine with the help of Cuda. I want to set Pixels from within my funktion with the SetPixel Method but it doesen’t compile.

My Funktion:

void print(int out[][501], HDC hdc)

    int i = threadIdx.x;
    int j = threadIdx.y;

    if (out[j][i] != 0)
        SetPixel(hdc, j, i, RGB(255 * (out[j][i] / PI), 0, 0));
        SetPixel(hdc, j, i, RGB(0, 255, 0));

There is no SetPixel() function in CUDA. I am not even sure which non-CUDA API offers such a function (Windows GDI?)

One cannot render to the screen just using CUDA. You would want to look into the use of CUDA’s OpenGL interoperatibility API. This allows sharing of buffers between CUDA and OpenGL. CUDA kernels can then render (off-screen) into the buffer, and the OpenGL side of the code then takes care of getting that out to the screen.

If you look around the internet, you will find anything from simple OpenGL interoperability examples to full-blown (specialized) rendering engines using CUDA in this way. My personal take is that one would want to attain a reasonable level of proficiency with both CUDA and OpenGL before tackling a project like this, otherwise it could turn into an exercise in frustration.

If you want to do something with ray tracing, you may want to look into NVIDIA’s OptiX ray tracing engine instead of rolling your own.

Thanks for the awnser!