I'm trying to write real-time raytracer. I use Java and Jogamp bindings of OpenGL and OpenCL for it (calls Jogl and Jocl). I already have raytracing code in my .cl kernel and its works well. I get output as FloatBuffer and pass it to the OpenGL texture via glTexImage2D. Now I want to go realtime, and to achive this I want to remove FloatBuffer copy which happens twice in my program (first - from OpenCL kernel result to RAM, and second from RAM to OpenGL texture). Obvious there is a way to point OpenCL buffer from OpenGL texture direct, cause all calculations works on GPU. I know that there is cl_khr_gl_sharing extention for OpenCL which do what I want. But I can't understand how to use this in Java Jogamp bindings (jocl/jogl). Can somebody helps me or give some sample JAVA code (not C++ which is really differs in details)?
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in OPENGL
- How to fix "Access violation executing location" when using GLFW and GLAD
- getting Access violation writing location when calling glDrawElements caused by shader
- Experimenting with GLFW library: window boundary problem and normalized coordinates
- OpenGL Framebuffer/FBO RTT subpixel movement discrepancy
- Why isn't my glfw window showing anything?
- How can glPushMatrix affect the rotation of an object around a rotating object?
- g++ / vscode apparently cannot see my src folder? "cc1plus.exe: fatal error: src/glad.c No such file or directory"
- Does addition-assignment cause dependency chain in GLSL?
- Compiling C++ program with Opengl and Glut in windows
- Using Silk.NET in WinForms
- What happens when rendering an OpenGL buffer that has been padded with NULL (or another value)?
- How can I make a sphere follow an eight-like path in Python using OpenGL?
- OpenGL only rendering second triangle, first triangle not visible
- OpenGL shows black texture on quad
- My Visual Studio 2022 consistently gives me errors saying that the GLchar variable type is undefined
Related Questions in OPENCL
- What is the parameter for CLI YOLOv8 predict to use Intel GPU?
- How to exploit Unified Memory in OpenCL with CL_MEM_ALLOC_HOST_PTR flag?
- PyOpenCl code hanging on a simple get() - how can I troubleshoot?
- OpenCL dynamic parallelism enqueue_kernel() functionality
- Do all OpenCL drivers come with the IntelOneAPI compiler
- How to move an array of structures to the GPU?
- Passing arguments to OpenCL kernel, before execution finished
- OpenCV acceleration (OpenCL) of gaussian blur
- CL_DEVICE_NOT_AVAILABLE using Intel(R)Xeon(R)Gold 6240 CPU
- Launch Single Kernel on problem space vs Launch same kernel, multiple times on smaller problem spaces
- Running OpenCL programs on baremetal RISC-V core
- Why did an OpenCL rendering optimization make my code slower?
- OpenCL Kernel hangs at clEnqueueReadBuffer on AMD rocm
- Is it possible to assign works to each GPU thread instead of a work to group of GPU threads?
- Fast way to rearrange bit into new byte
Related Questions in JOGL
- How do you configure JOGL with java in 2024 lol
- can't import com.jogamp in visual studio code
- Orienting a camera that orbits spheres in JOGL2
- Camera not stable as it orbits an object
- Difficulties setting up JOGL on IntelliJ Idea
- JOGL z-buffer rendering problems
- JOGL Passing Integer Value to Fragment Shader
- Java ServiceLoader can't find class
- Why are my JOGL lighting shaders not working?
- Java classpath for my self contained MacOS java app does not work
- JOGL sample code compile error "cannot access WriteCloneable"
- How to initialize nifty after update to 1.4.2
- myCanvas.addKeyListener(this) throws an error in JOGL
- How to embed a 3D graphics panel (LibGDX or JOGL) into a desktop GUI (JavaFX or Desktop Compose) in 2022?
- Errors loading Blender Wavefront Model
Related Questions in JOCL
- JOCL CL_OUT_OF_RESOURCES only if value is assigned
- MVN is not letting me install JOCL
- OpenCL: memory recovery and threading?
- Why would JOCL CL.clEnqueueReadBuffer never return?
- Efficiently synchronously queue many small OpenCL kernels
- copying an image onto another with JOCL/OpenCL
- How to pass an array of structs to kernel with JOCL
- Very odd OpenCL CL_OUT_OF_RESOURCES behavior
- CL_INVALID_MEM_OBJECT error when calling clSetKernelArg in JOCL
- OpenCL & Java - Weird Performance Results
- Releasing Memory Allocated by Native Libraries in Java
- how to create CL GL interop context?
- JOCL Char not returning all chars
- JOCL Program build error when given char array in kernel
- OpenCL double precision error on Surface 3 pro
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
So, after few days of research I find how to do it. Posting an answer for anybody who interest.
In "init" method of Jogl's GLEventListener you create GL context. You must create CL context in that method too. My sample code for this:
The core line is:
clContext.createFromGLTexture2d(GL4.GL_TEXTURE_2D, textureIndex, 0, Mem.WRITE_ONLY);You should create an OpenCL texture object for your previous created OpenGL texture. Code of creating OpenGL texture:And the last - you must use right data type of texture argument in your OpenCL kernel. In my case kernel method has the following signature:
and I use write_imagef build-in OpenCL method to write float data (0.0f - 1.0f) into this texture.
Feel free to ask me about this approach if you interested.