Quote from: spasi on August 01, 2024, 11:17:06Not yet, but if JSpecify gets the expected adoption, we could migrate to it in an upcoming major release (3.4.0 or 3.5.0).
Quote from: vanzomerenc on July 31, 2024, 22:12:58Is there any plan to move LWJGL to a different annotation package such as JSpecify?Not yet, but if JSpecify gets the expected adoption, we could migrate to it in an upcoming major release (3.4.0 or 3.5.0). Also note that jsr305 is not bundled/distributed by LWJGL. It is entirely optional and up to the user if they want to use it during development.
// Setup
depthTexture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, (FloatBuffer) null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0);
computeProgram = ShaderProgram.fromFiles("src\\game\\test.compute", "offscreenrenderer", 0);
quad = new FullscreenQuad();
computeProgram.use();
glBindImageTexture(0, renderedTexture, 0, false, 0, GL_READ_ONLY, GL_RGBA32F);
glBindImageTexture(1, depthTexture, 0, false, 0, GL_READ_ONLY, GL_R32F);
glBindImageTexture(2, processedTexture, 0, false, 0, GL_WRITE_ONLY, GL_RGBA32F);
computeProgram.unuse();
// Methods in the code for starting the rendering and for doing the post processing:
public void start() {
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
//glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
glViewport(0, 0, width, height);
}
public void runPostProcess() {
computeProgram.use();
glDispatchCompute((int) Math.ceil(width / 16.0), (int) Math.ceil(height / 16.0), 1);
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
computeProgram.unuse();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT);
quad.setTexture(processedTexture);
quad.render();
}
#version 430
layout(local_size_x = 16, local_size_y = 16) in;
layout(binding = 0, rgba32f) uniform image2D inputImage; // Works
layout(binding = 1, r32f) uniform image2D depthImage; // Doesn't work
layout(binding = 2, rgba32f) uniform image2D outputImage; // Works
void main() {
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
imageStore(outputImage, pos, imageLoad(depthImage, pos));
}
// Java
int t3dim = 64;
int[] tex3d_r = new int[t3dim*t3dim*t3dim*4];
int r,g,b,a,color;
for(int i=0;i<(t3dim*t3dim*t3dim);i++) {
r = (int)(Mati.fRand_static()*255.0f);
g = (int)(Mati.fRand_static()*255.0f);
b = (int)(Mati.fRand_static()*255.0f);
a = (int)(Mati.fRand_static()*255.0f);
color = (a << 24) | (r << 16) | (g << 8) | b;
tex3d_r[i]=color;
}
glTexImage3D(GL_TEXTURE_3D, 0, GL30.GL_RGBA, t3dim , t3dim , t3dim , 0, GL30.GL_RGBA, GL_UNSIGNED_BYTE, tex3d_r);
// GLSL
if(volumeMode>0) {
pixel = texture(volumeMap, vec3(uvs_vs0.xy,dbg_val1));
return;
}