Main Menu

Recent posts

#1
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);
        }
    }
#2
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
#3
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?
#4
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
#5
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?
#6
Bug Reports / RFE / Re: [BUG] Double free on Point...
Last post by spasi - January 09, 2025, 12:29:49
Hey KGAFT,

The name of this method is meant as a hint that it uses ByteBuffer.allocateDirect internally, which allocates a GC-managed ByteBuffer. The free method has this javadoc:

QuoteFrees the buffer allocation.

This method should not be used if the memory backing this buffer is not owned by the buffer.
All MemoryUtil methods that allocate explicitly-managed memory have the following note (or similar):

QuoteMemory allocated with this method must be freed with memFree.
ByteBuffer.allocateDirect, PointerBuffer.allocateDirect, BufferUtils methods and MemoryStack methods do not have such a note because, well, you don't have to do anything special to deallocate the returned buffer.

You may read Memory management in LWJGL for more details.
#7
Bug Reports / RFE / [BUG] Double free on PointerBu...
Last post by KGAFT - January 09, 2025, 10:26:18
During development of my vulkan app with lwjgl, i noticed there are a lot of glibc errors like: double free detected in tcache. After continuously investigation, i found out that all PointerBuffer object allocated through allocateDirect are garbage collected automatically, with no need to free it manually, despite there existing free method. There is need to do something with this, add notice to docs, or make this method private.

P.S: You can repeat it by running this code, and specify the memory limit for java vm:
while(true){
    PointerBuffer pb = PointerBuffer.allocateDirect(9999);
    pb.free();
}
#8
Bug Reports / RFE / Re: Unusual Window / Startup /...
Last post by spasi - January 08, 2025, 19:10:48
Hey Ir3n!cus,

If the Raspberry defaults to Wayland, then that's the most likely problem. LWJGL versions before 3.3.5 always used GLX by default. With 3.3.5, Wayland is detected automatically and LWJGL switches to EGL internally.

If you cannot update to 3.3.5+, a workaround is possible. Add the following before init:

if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
    Configuration.OPENGL_EXPLICIT_INIT.set(true);
    GL.create(EGL.getFunctionProvider());
}
#9
Lightweight Java Gaming Library / Re: LWJGL 3.3.5
Last post by cpope9141 - January 07, 2025, 15:09:03
Great! Thank you!
#10
Bug Reports / RFE / Unusual Window / Startup / Tas...
Last post by Ir3n!cus - January 07, 2025, 10:05:13
I try to develope a java application with LibGdx for Raspberry 4. The Raspberry runs the standard OS.
For short debug cycles I ran this application during developement mostly on windows and only deploy it to the raspberry after bigger features are complete.

I want the app to get a "Taskbar-Item" and to start in fullscreen mode. Since both happends on windows, i would assume I configured the app internal settings correct.

On the raspberry there are two problems.
  • The app starts minimized / iconified. There is no visual window on the desktop.
  • The app gets no "Taskbar-Item". There is no "clickable instance" on the desktop to bring the app to front.

I already opened a thread to the second problem in the raspberry forum, but got no answer:

Raspberry Forum Post

My main problem is, that I cannot figure out the root cause and the element to take care of.
What participates on this problems and must be changed?
  • Java Runtime Environment?
  • LibGdx?
  • LWJGL?
  • OpenGL?
  • Wayfire?
  • Wayland?
  • LabWC?
  • mf-panel-pi?
  • ..... ?

The only point I can say is that this does not happend with a selfmade Java-Swing-Gui-App to test this.
The swing app gets a Taskbar-Item and the window show up on startup normally.
And all other applications like the raspberry terminal app getting window and taskbar-item, too

This seems to happend only with LibGdx/LWJGL - Java - Appllications.