List of usage examples for org.lwjgl.opengl ARBClearTexture glClearTexImage
public static void glClearTexImage(@NativeType("GLuint") int texture, @NativeType("GLint") int level, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") double[] data)
From source file:org.lwjgl.demo.opengl.raytracing.PhotonMappingBindlessDemo.java
License:Open Source License
/** * Clear the photon map textures./*from w w w .j ava 2 s.c o m*/ */ private void clearPhotonMapTextures() { /* * Clear the first level of the texture with black without allocating * host memory. */ if (caps.GL_ARB_clear_texture) { /* * If ARB_clear_texture is available, we can directly clear the * image of the texture. A version where you can clear the images of * multiple successive textures would be handy here! */ for (int i = 0; i < photonMapTextures.length; i++) { TextureInfo info = photonMapTextures[i]; ARBClearTexture.glClearTexImage(info.openGlHandle, 0, GL_RG, GL_HALF_FLOAT, clearTexBuffer); } } else { /* * If not, we create a temporary buffer object and use pixel unpack * to move GPU memory from that buffer to the texture image. */ for (int i = 0; i < photonMapTextures.length; i++) { TextureInfo info = photonMapTextures[i]; int texBuffer = glGenBuffers(); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texBuffer); int size = 2 * 2 * info.textureWidth * info.textureHeight; glBufferData(GL_PIXEL_UNPACK_BUFFER, size, GL_STATIC_DRAW); glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_RG16F, 0, size, GL_RG, GL_HALF_FLOAT, (ByteBuffer) null); glBindTexture(GL_TEXTURE_CUBE_MAP, info.openGlHandle); for (int f = 0; f < 6; f++) { glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, 0, 0, 0, info.textureWidth, info.textureHeight, GL_RG, GL_HALF_FLOAT, 0L); } glBindTexture(GL_TEXTURE_CUBE_MAP, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glDeleteBuffers(texBuffer); } } }
From source file:org.lwjgl.demo.opengl.raytracing.PhotonMappingDemo.java
License:Open Source License
/** * Clear the photon map texture.//from w ww . ja va2s .c om */ private void clearPhotonMapTexture() { /* * Clear the first level of the texture with black without allocating * host memory. */ if (caps.GL_ARB_clear_texture) { /* * If ARB_clear_texture is available, we can directly clear the * image of the texture. */ ARBClearTexture.glClearTexImage(photonMapTexture, 0, GL_RG, GL_HALF_FLOAT, clearTexBuffer); } else { /* * If not, we create a temporary buffer object and use pixel unpack * to move GPU memory from that buffer to the texture image. */ int texBuffer = glGenBuffers(); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texBuffer); int size = 2 * 2 * photonMapSize * photonMapSize * 6 * boxes.length / 2; glBufferData(GL_PIXEL_UNPACK_BUFFER, size, GL_STATIC_DRAW); glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_RG16F, 0, size, GL_RG, GL_HALF_FLOAT, (ByteBuffer) null); glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, photonMapTexture); glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, photonMapSize, photonMapSize, 6 * boxes.length / 2, GL_RG, GL_HALF_FLOAT, 0L); glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glDeleteBuffers(texBuffer); } }