Recent posts

#31
Area Zero is coming to Steam July 15! Add it to your wish list to be notified when it is available: https://store.steampowered.com/app/3796060/Area_Zero/
#32
OpenGL / PBO makes the texture plain wh...
Last post by Silent hallucination - June 23, 2025, 07:16:57
Hello there.
I wanted to play a video using a quad-stretched texture and for the test I made a simple class that gets a ByteBuffer with the first frame of the video and creates a texture from it. However, when I tried to do the same with PBO (which will allow me to update the texture faster in the future), only a solid white rectangle was displayed.
Here is my texture class now:
public class VidTexture {
    int w, h, textureId, pbo;
    VidTexture(int w, int h, ByteBuffer buf) {
        this.w = w;
        this.h = h;
        buf.flip();

        pbo = glGenBuffers();
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
        glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*3L, GL_STREAM_DRAW);
        ByteBuffer bb = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
        bb.put(buf);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

        textureId = glGenTextures();

        glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);

        glBindTexture(GL_TEXTURE_2D, textureId);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w,
                h, 0, GL_BGR, GL_UNSIGNED_BYTE, 0);
        glGenerateMipmap(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, -1);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

        buf.clear();
    }
    //Here is cleanUp and bind functions
}
Can anyone help me, please?
#33
Bug Reports / RFE / Tab key not working with ctrl ...
Last post by MGVizor - June 05, 2025, 12:44:19
The implementation of listener looks something like this:

private static final class GlfwKeyListener implements GLFWKeyCallbackI {
    private int key;

    @Override
    public void invoke(long window, int key, int scancode, int action, int mods) {
        KeyClass.key = key;
        //schedule to set key to 0 on next frame
    }
}

Then I log the inputs with something like this:

private void logUsedKeys() {
    int key = KeyClass.key;
    if (key != 0) {
        LOGGER.info("Key {}", key);
    }
}

However, when the ctrl is down it prints any pressed key, but tab.

Using macOS if it is important. In other apps everything works fine(e.g. switching tabs in browser/intellij idea)
lwjgl version: 3.3.1
#34
Hey ss123she,

The problem is that the UTF8 method encodes strings with a null-terminator by default. However, shaderc_compile_into_spv takes an explicit size_t source_text_size parameter and LWJGL passes sourceBuffer.remaining() there implicitly, which includes the null-terminator.

You can easily fix this with sourceBuffer = stack.UTF8(shaderSource.trim(), false), which will encode the source buffer without the null-terminator.
#35
Lightweight Java Gaming Library / Creating LWJGL 2.10?
Last post by kittylyst - May 11, 2025, 14:11:29
Hi folks,

tl;dr I have a working build of LWJGL v2 that I think would be a worthy basis for a v2.10.0 release. The purpose would simply be to support modern hardware (e.g. modern Linux, Apple M1 and Raspberry Pi 4) - no new features.

Full story:

I bought a game from GOG in Nov 2024 and found that, unfortunately, it doesn't run on my Macbook.

However, I noticed that the crash indicated JavaApplicationStub and I decided to have a go at seeing if I could fix it.

I spent a few hours hacking on this and by fixing LWJGL2 and JInput, I've got a working version that runs on both macOS 14/15 (Apple Silicon) and Fedora 39-41 (Intel) and Raspberry Pi 4.

Since then, I've continued to work on forward-porting LWJGL2 - the repo is here: https://github.com/kittylyst/lwjgl2 with my fixes.

I'm also talking with the JInput folks to add a few fixes there as well (including downgrading required Java version to 8 and introducing aarch64 support).

The Ask:

Is there interest in releasing a 2.10.0 if I take responsibility for producing the patches and looking after the v2 repo? Will someone with the appropriate rights do the release and publication to Maven Central under the existing co-ordinates?

I need my changes (especially RPi support) for one of my projects so if there isn't interest in doing this upstream then I'll fork instead, but that seems silly when the delta is relatively small.
#36
Lightweight Java Gaming Library / Shader compilation failed: sim...
Last post by ss123she - March 28, 2025, 13:54:17
Shader compilation failed: simpleDraw.vs:14: error: '' : unexpected token

While trying to compile:

#version 450
layout(location = 0) in vec3 a_position;
layout(location = 1) in vec2 a_texcoord0;

layout(location = 0) out vec2 v_texcoord0;

layout(binding = 0) uniform Uniforms {
    mat4 u_modelViewProj;
};

void main() {
    v_texcoord0 = a_texcoord0;
    gl_Position = u_modelViewProj * vec4(a_position, 1.0);
}

UTF-8, no BOM

here is my compiling code:
    public static ByteBuffer compileShader(Path shaderPath, int shaderType) {
        long compiler = Shaderc.shaderc_compiler_initialize();
        long options = Shaderc.shaderc_compile_options_initialize();

        try {
            String shaderSource = Files.readString(shaderPath, StandardCharsets.UTF_8);

            try (MemoryStack stack = MemoryStack.stackPush()) {
                ByteBuffer sourceBuffer = stack.UTF8(shaderSource.trim());
                ByteBuffer shaderName = stack.UTF8(shaderPath.getFileName().toString());
                ByteBuffer entryPoint = stack.UTF8("main");

                long result = Shaderc.shaderc_compile_into_spv(
                        compiler,
                        sourceBuffer,
                        shaderType,
                        shaderName,
                        entryPoint,
                        options
                );

                if (Shaderc.shaderc_result_get_compilation_status(result) != Shaderc.shaderc_compilation_status_success) {
                    System.err.println("Shader compilation failed: " + Shaderc.shaderc_result_get_error_message(result));
                    System.err.println("Shader compile log: " + Shaderc.shaderc_result_get_error_message(result));
                    Shaderc.shaderc_result_release(result);
                    return null;
                }

                int spirvSize = (int) Shaderc.shaderc_result_get_length(result);

                ByteBuffer spirv = ByteBuffer.allocateDirect(spirvSize);
                spirv.put(Shaderc.shaderc_result_get_bytes(result)).flip();

                Shaderc.shaderc_result_release(result);
                return spirv;
            }

        } catch (IOException e) {
            System.err.println("Failed to load shader: " + e.getMessage());
            return null;
        } finally {
            Shaderc.shaderc_compile_options_release(options);
            Shaderc.shaderc_compiler_release(compiler);
        }
    }
#37
JOML / Different results when using M...
Last post by huuuubbbb - March 26, 2025, 13:06:31
When running this code
Matrix4f m = new Matrix4f();
Quaternionf q = new Quaternionf(0.0f, 0.965f, 0.2622f, 0.0f);
m.rotate(q);
AxisAngle4f a = new AxisAngle4f();
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);
m.getRotation(a);
System.out.println(a);

i get these results
( 0.000E+0  9.650E-1  2.530E-1 <|  3.142E+0)
( 0.000E+0  9.650E-1  1.000E+0 <|  3.142E+0)
( 0.000E+0  9.650E-1  2.530E-1 <|  3.142E+0)
( 0.000E+0  9.650E-1  1.000E+0 <|  3.142E+0)

This is an edge case where the rotation is around 180 degrees. But why does the result change if the DESTINATION variable has some values in it. Shouldnt the values just be overwritten? I dont understand this behavior. Is this a possible bug? Please explain it :P
#38
OpenGL / Noob failed to render a triang...
Last post by Potty_Jr - March 02, 2025, 07:37:05
Hi guys, I'm new to OpenGL & lwjgl. Today I was following the tutorial for lwjgl 3 on https://ahbejarano.gitbook.io/lwjglgamedev and trying to render a triangle in my window like in chapter 3, but even thought I copied the code given by the author, what I got was a blank window. I'm using Java 8 and the author is using a higher version, he used the record keyword in ShaderProgram which I replaced with an inner class, the rest should be exactly the same. My code is in the attachment, could anyone help?
#39
Lightweight Java Gaming Library / Re: Indie Fighting Game using ...
Last post by cpope9141 - February 20, 2025, 19:54:39
The February release of Area Zero (v0.22.0) is now available: https://ephemeraltechnicalarts.com/area-zero
#40
Lightweight Java Gaming Library / noob question
Last post by 456 - February 02, 2025, 00:36:46
hey guys, i asked AI about how to optimize my graphics and your software came up  :D

i have a real time plotter implemented in java swt, all it does is draw lines and some text and dots, this is done on the java swt canvas, it is already very fast and can update tens of thousands of lines/sec. Do you think your software would improve this?