Example usage for org.lwjgl.opengl ARBBindlessTexture glGetImageHandleARB

List of usage examples for org.lwjgl.opengl ARBBindlessTexture glGetImageHandleARB

Introduction

In this page you can find the example usage for org.lwjgl.opengl ARBBindlessTexture glGetImageHandleARB.

Prototype

@NativeType("GLuint64")
public static native long glGetImageHandleARB(@NativeType("GLuint") int texture, @NativeType("GLint") int level,
        @NativeType("GLboolean") boolean layered, @NativeType("GLint") int layer,
        @NativeType("GLenum") int format);

Source Link

Document

Creates and returns an image handle for level level of the texture named texture .

Usage

From source file:org.lwjgl.demo.opengl.raytracing.PhotonMappingBindlessDemo.java

License:Open Source License

/**
 * Create the cubemap texture array for our photon map.
 *//* ww w .  j av a 2s  .  co  m*/
private void createPhotonMapTextures() {
    /* Create them */
    IntBuffer textures = BufferUtils.createIntBuffer(photonMapTextures.length);
    glGenTextures(textures);
    for (int i = 0; i < photonMapTextures.length; i++) {
        TextureInfo info = new TextureInfo();
        info.openGlHandle = textures.get(i);
        Vector3f min = boxes[2 * i + 0];
        Vector3f max = boxes[2 * i + 1];
        float maxExtent = Math.max(Math.max(max.x - min.x, max.y - min.y), max.z - min.z);
        int texSize = (int) (maxExtent * texelsPerUnit);
        info.textureWidth = texSize;
        info.textureHeight = texSize;
        glBindTexture(GL_TEXTURE_CUBE_MAP, info.openGlHandle);
        glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RG16F, texSize, texSize);
        glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
        info.bindlessImageHandle = ARBBindlessTexture.glGetImageHandleARB(info.openGlHandle, 0, true, 0,
                GL_RG16F);
        info.bindlessTextureAndSamplerHandle = ARBBindlessTexture
                .glGetTextureSamplerHandleARB(info.openGlHandle, sampler);
        ARBBindlessTexture.glMakeImageHandleResidentARB(info.bindlessImageHandle, GL_READ_WRITE);
        ARBBindlessTexture.glMakeTextureHandleResidentARB(info.bindlessTextureAndSamplerHandle);
        photonMapTextures[i] = info;
    }
    /* Clear them */
    clearPhotonMapTextures();
    /* Update SSBO with bindless image handles */
    updateImageHandlesUbo();
    /* Update UBO with bindless sampler handles */
    updateSamplerHandlesUbo();
}