Example usage for org.lwjgl.opengl ARBBindlessTexture glMakeTextureHandleResidentARB

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

Introduction

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

Prototype

public static native void glMakeTextureHandleResidentARB(@NativeType("GLuint64") long handle);

Source Link

Document

Make a texture handle resident, so that it is accessible to shaders for texture mapping operations.

Usage

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

License:Open Source License

/**
 * Create the cubemap texture array for our photon map.
 *//*from   w  w  w .ja va2s.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();
}