# OpenGL rendering with CUDA

**URL:** https://discourse.julialang.org/t/opengl-rendering-with-cuda/82063
**Category:** GPU
**Tags:** gpu, cuda, visualization
**Created:** [June 1, 2022, 4:34pm UTC](https://discourse.julialang.org/t/opengl-rendering-with-cuda/82063 "2022-06-01T16:34:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lads-oxygen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lads-oxygen/32/36821_2.png) [@Lads-oxygen](https://discourse.julialang.org/u/Lads-oxygen)
#### Post date: [June 1, 2022, 4:34pm UTC](https://discourse.julialang.org/t/opengl-rendering-with-cuda/82063/1 "2022-06-01T16:34:30Z")

</div>

I am currently working on a personal project on fractals to be specific, and have used CUDA to implement the computational aspect for a number of reasons. I haven’t optimised my kernel yet, although it runs fast enough for them to be interactible. However, I am now struggling to render my fractals live using OpenGL. My two problems are that:

1. I would like to pass data from my CUDA kernel to the OpenGL shader directly, since both are run on the GPU. But I have found very little information on CUDA and OpenGL interopability (let alone in Julia).

2. After a few days I’m still not sure which packages I should use for OpenGL, I believe ModernGL and GLFW is my only real option but looking through some examples I must admit they are harder to follow given that it is wrapper and I can’t simply look through the source code. I am almost tempted to switch to python for this part of my project.

I wasn’t sure whether to post this in the Visualisation or GPU section but hopefully it’s alright. I appreciate any advice 🙏

---

<div class="post-metadata">

### Author: ![sjkelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sjkelly/32/9280_2.png) [@sjkelly](https://discourse.julialang.org/u/sjkelly)
#### Post date: [June 1, 2022, 4:58pm UTC](https://discourse.julialang.org/t/opengl-rendering-with-cuda/82063/2 "2022-06-01T16:58:26Z")

</div>

There is a small example here that may be of help:

> [@CuArray + GLMakie](https://discourse.julialang.org/t/cuarray-glmakie/52461/10):
>
> Turns out there was some “scalar indexing” going on, where individual elements of the GPU buffers were being copied to the CPU for processing. By using GLBuffer{Point2f} directly, and using low-level APIs that avoid some of the automatic processing (e.g. center! inspects data to determine limits, lines! does a map to detect invalid vertices) I have a working example that keeps all data on the GPU: function plot(; T=Float32, N=1024, resolution=(800,600)) t = CUDA.rand(T, N) X = CUDA.rand…

This uses GLMakie which is built upon GLFW.

---

<div class="post-metadata">

### Author: ![Lads-oxygen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lads-oxygen/32/36821_2.png) [@Lads-oxygen](https://discourse.julialang.org/u/Lads-oxygen)
#### Post date: [June 1, 2022, 5:05pm UTC](https://discourse.julialang.org/t/opengl-rendering-with-cuda/82063/3 "2022-06-01T17:05:48Z")

</div>

Thanks a lot for the quick response, I will look through it. Have a nice day
