JOCL v2.6.0-rc-20250722
JOCL, OpenCL® API Binding for Java™ (public API).
CLGLTexture3d.java
Go to the documentation of this file.
1/*
2 * Copyright 2009 - 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opencl.gl;
30
31import com.jogamp.opencl.llb.CL;
32import com.jogamp.opencl.CLContext;
33import com.jogamp.opencl.CLException;
34import com.jogamp.opencl.CLImage3d;
35import com.jogamp.opencl.CLImageFormat;
36import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
37
38import java.nio.Buffer;
39
40import com.jogamp.opengl.GLContext;
41
42/**
43 * 3D OpenCL image representing an 3D OpenGL texture.
44 * @author Michael Bien, et.al.
45 */
46public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLGLObject, CLGLTexture {
47
48 /**
49 * The OpenGL object handle.
50 */
51 public final int GLID;
52
53 public final int target;
54
55 public final int mipMapLevel;
56
57 private CLGLTexture3d(final CLContext context, final B directBuffer, final CLImageFormat format, final CLImageInfoAccessor accessor, final int target, final int mipLevel, final int width, final int height, final int depth, final long id, final int glid, final int flags) {
58 super(context, directBuffer, format, accessor, width, height, depth, id, flags);
59 this.GLID = glid;
60 this.target = target;
61 this.mipMapLevel = mipLevel;
62 }
63
64 static <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final CLContext context, final B directBuffer, final int flags, final int target, final int mipLevel, final int texture) {
65
66 CLGLBuffer.checkBuffer(directBuffer, flags);
67
68 final CL cl = getCL(context);
69 final int[] result = new int[1];
70
71 final long id = cl.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0);
72 CLException.checkForError(result[0], "can not create CLGLTexture3d from texture #"+texture+".");
73
74 final CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id);
75
78
79 final int width = (int)accessor.getLong(CL.CL_IMAGE_WIDTH);
80 final int height = (int)accessor.getLong(CL.CL_IMAGE_HEIGHT);
81 final int depth = (int)accessor.getLong(CL.CL_IMAGE_DEPTH);
82
83 return new CLGLTexture3d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, depth, id, texture, flags);
84 }
85
86 @Override
87 public int getGLObjectID() {
88 return GLID;
89 }
90
91 @Override
92 public int getTextureTarget() {
93 return target;
94 }
95
96 @Override
97 public int getMipMapLevel() {
98 return mipMapLevel;
99 }
100
101 @Override
104 }
105
106 /**
107 * Returns the shared CLGLContext.
108 */
109 @Override
111 return (CLGLContext) super.getContext();
112 }
113
114 @Override
115 public GLContext getGLContext() {
116 return getContext().getGLContext();
117 }
118
119}
CLContext is responsible for managing objects such as command-queues, memory, program and kernel obje...
Definition: CLContext.java:79
Main Exception type for runtime OpenCL errors and failed function calls (e.g.
static void checkForError(final int status, final String message)
Throws a CLException when status != CL_SUCCESS.
Represents the OpenCL image format with its channeltype and order.
CLImageFormatImpl getFormatImpl()
Returns the struct accessor for the cl_image_format struct.
static CLImageFormat createUninitializedImageFormat()
Definition: CLImage.java:67
final long ID
The OpenCL object handle.
Definition: CLObject.java:41
Shared buffer between OpenGL and OpenCL contexts.
Definition: CLGLBuffer.java:45
OpenCL Context supporting JOGL-JOCL interoperablity.
GLContext getGLContext()
Returns the OpenGL context this context was shared with.
CLGLContext getContext()
Returns the context for this OpenCL object.
3D OpenCL image representing an 3D OpenGL texture.
CLGLContext getContext()
Returns the shared CLGLContext.
int getGLObjectID()
Returns the OpenGL object id of this shared object.
GLContext getGLContext()
Returns the OpenGL context of this shared object.
final int GLID
The OpenGL object handle.
GLObjectType getGLObjectType()
Returns the OpenGL buffer type of this shared object.
Struct accessor for cl_image_format.
final java.nio.ByteBuffer getBuffer()
Return the underlying native direct ByteBuffer.
static int size()
Returns the aligned total size of a native instance.
Java bindings to OpenCL, the Open Computing Language.
Definition: CL.java:26
static final int CL_IMAGE_FORMAT
Define "CL_IMAGE_FORMAT" with expression '0x1110', CType: int.
Definition: CL.java:333
static final int CL_IMAGE_DEPTH
Define "CL_IMAGE_DEPTH" with expression '0x1116', CType: int.
Definition: CL.java:167
static final int CL_IMAGE_HEIGHT
Define "CL_IMAGE_HEIGHT" with expression '0x1115', CType: int.
Definition: CL.java:61
long clCreateFromGLTexture3D(long context, long flags, int target, int miplevel, int texture, IntBuffer errcode_ret)
Interface to C language function: cl_mem {@native clCreateFromGLTexture3D}(cl_context context,...
static final int CL_IMAGE_WIDTH
Define "CL_IMAGE_WIDTH" with expression '0x1114', CType: int.
Definition: CL.java:619