Hello Guest

Recent Posts

Pages: 1 [2] 3 4 ... 10
11
JOML / Yet another projection matrix problem
« Last post by CDnoMlqko on September 29, 2020, 13:59:15 »
Hello!

I am really sorry if this question is stupid.

So, I am developing a 3D game engine and I need to calculate the projection matrix for the camera. Currently, I am doing it this way:
Code: [Select]
viewMatrix.identity()
   .rotateX(transform.getRotation().x)
   .rotateY(transform.getRotation().y)
   .rotateZ(transform.getRotation().z)
   .translate(new Vector3f(transform.getPosition()).mul(-1));
where "transform" is a data container for the position and rotation of the camera. And it works. But, as I am calling this every frame, I think there should be a faster solution.
I know that the view matrix should be the inverse of the camera world matrix. So I tried this:
Code: [Select]
transform.getWorldMatrix().invert(viewMatrix);
, where getWorldMatrix() looks like this:
Code: [Select]
worldMatrix.translation(position).rotateX(rotation.x).rotateY(rotation.y).rotateZ(rotation.z).scale(scale);
which should write the inverse of the world matrix in the view matrix, but the result of that is some quite confusing. It looks like all objects are rotating around the world (0,0,0), but I am not sure if exactly this is the case.
12
Lightweight Java Gaming Library / Re: Assimp memory leak
« Last post by spasi on September 29, 2020, 13:45:31 »
LWJGL callback function objects must be manually freed to avoid memory leaks.
13
I'd like to jump in here as I'm having some related issues, don't know if a new post is preferred or not.

Just trying to get the proper result on every mac. I don't really care much for this Cocoa thing.

So what I'm doing is this:

Code: [Select]
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ROOT);
if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) {
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL11.GL_FALSE);
}

I'm doing deferred rendering, so in the end I'm just doing a "blit" to the default FB. This is how I get the dimension of the default FB:

Code: [Select]
IntBuffer w = BufferUtils.createIntBuffer(1);
IntBuffer h = BufferUtils.createIntBuffer(1);
glfwGetFramebufferSize(window, w, h);
blitArea = new Coo(w.get(), h.get());
Printer.ln("---blit size: " + blitArea.x() + " " + blitArea.y());

This works on a new Imac I have. But on a macbook I'm getting a 4x zoom as a result. Everything is fine and dandy in windowed mode, but this is going full screen. I had problems on the IMac too, but solved it with the first code paragraph. Any hints for me?
14
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by ilum on September 28, 2020, 20:43:35 »
Sure, no problem. Always glad to help. I guess the morale of the story is: ALWAYS trust the output of LWJGLX/debug. If it says, you have an error, then you have an error. :D
Yup
15
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by KaiHH on September 28, 2020, 20:42:13 »
Sure, no problem. Always glad to help. I guess the morale of the story is: ALWAYS trust the output of LWJGLX/debug. If it says, you have an error, then you have an error. :D
16
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by ilum on September 28, 2020, 20:41:18 »
Oh, that was extremely stupid of me for not noticing. Thank you! Sorry for the time waste on such a trivial thing  :)
17
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by KaiHH on September 28, 2020, 20:31:42 »
Yeah, this is somewhat a problem with the trace mode, because for some methods, it does not trace the call when that call generated an error. This is for all calls that also return a return value.
But anyway, you still see the function that generated the error in the callstack of the error log.
But the problem is that you call glGetShaderi() with a program object id (to query the link status), however that function is only valid to be called with a shader object id/handle, NOT a program id/handle. See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetShader.xhtml
In order to query the program link status, you _must_ use glGetProgrami: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgram.xhtml
18
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by ilum on September 28, 2020, 20:26:18 »
Quote
There is also a difference between "the program works" as in "it renders what I expect" and: "the program does not generate any OpenGL errors".
I guess in some cases but I don't see the difference here. From the stacktrace it seems the error happens during glLinkProgram. The shaders are detached afterwards.

I'll leave a github link: https://github.com/ilumar589/LWJGLGatheredStuff

Thanks for the response!
19
Lightweight Java Gaming Library / Re: Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by KaiHH on September 28, 2020, 20:05:45 »
This error message:
Quote
GL_INVALID_OPERATION error generated. Object is not a program or shader object.
is generated by the OpenGL driver. When you see something like this, then you definitely generate invalid OpenGL calls.
There is also a difference between "the program works" as in "it renders what I expect" and: "the program does not generate any OpenGL errors".
I bet that at some point you call `glGetShaderi()` with a shader object id/handle that does not (any more?) represent a shader object. Maybe you deleted the shader object previously.
Do you have a minimal, complete and verifiable example program to check?
20
Lightweight Java Gaming Library / [SOLVED]Weird behavior with lwjglx-debug-1.0.0.jar
« Last post by ilum on September 28, 2020, 19:23:06 »
Hi,

    I was trying to see what kind of problems the debug jar catches so I ran a simple program that renders the basic triangle with the basic vertex and fragment shaders and to my surprise a render that works without the javaagent running, fails when using it it.
    These are the VM options I used:  -javaagent:<path>/lwjglx-debug-1.0.0.jar=d;t;o=trace.log
                                                      -XX:+UnlockExperimentalVMOptions
                                                      -XX:+UseZGC

I've attached the trace.log with the error but for a shorter read this is the part that baffles me
Code: [Select]
[trace][1] Shader source for shader [2]:
        1  #version 330 core
        2  layout (location=0) in vec3 aPos;
        3 
        4  void main() {
        5      gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
        6  }
[trace][1] (ShaderProgram.java:65)      glShaderSource(2, "#version 330 core\nlayout (location=0) in vec3 aPos;\n\nvoid main() {\n    gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n}\n")
[trace][1] (ShaderProgram.java:66)      glCompileShader(2)
[trace][1] (ShaderProgram.java:75)      glGetShaderi(2, GL_COMPILE_STATUS) = GL_TRUE
[trace][1] (ShaderProgram.java:68)      glAttachShader(1, 2)
[trace][1] (ShaderProgram.java:63)      glCreateShader(GL_FRAGMENT_SHADER) = 3
[trace][1] Shader source for shader [3]:
        1  #version 330 core
        2  out vec4 FragColor;
        3 
        4  void main() {
        5      FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
        6  }
[trace][1] (ShaderProgram.java:65)      glShaderSource(3, "#version 330 core\nout vec4 FragColor;\n\nvoid main() {\n    FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n}\n")
[trace][1] (ShaderProgram.java:66)      glCompileShader(3)
[trace][1] (ShaderProgram.java:75)      glGetShaderi(3, GL_COMPILE_STATUS) = GL_TRUE
[trace][1] (ShaderProgram.java:68)      glAttachShader(1, 3)
[trace][1] (ShaderProgram.java:33)      glLinkProgram(1)
[error][1] OpenGL debug message
  ID: 0x502
  Source: API
  Type: ERROR
  Severity: HIGH
  Message: GL_INVALID_OPERATION error generated. Object is not a program or shader object.
  Stacktrace: org.lwjgl.opengl.GL20C.nglGetShaderiv(Native Method)
              org.lwjgl.opengl.GL20C.glGetShaderi(GL20C.java:771)
              org.lwjgl.opengl.GL20.glGetShaderi(GL20.java:847)
              ShaderProgram.logShaderStatus(ShaderProgram.java:75)
              ShaderProgram.link(ShaderProgram.java:34)
              Main.loop(Main.java:116)
              Main.run(Main.java:37)
              Main.main(Main.java:24)
[trace][1] (Main.java:40)               glfwFreeCallbacks(window[1])
[info ] Destroying OpenGL context for window[1]
[trace] (Main.java:41)               glfwDestroyWindow(window[1])
[debug] Freeing GLFWErrorCallback
[trace] (Main.java:43)               glfwTerminate()
[trace] (Main.java:47)               glfwSetErrorCallback(null) =  pointer [0x23099BB0000]
[trace] (Main.java:48)               setCapabilities(null)

    Again, I don't understand why this works when I don't use the javaagent. I do have error reporting behavior in the shader class and I don't get any problem:
Code: [Select]
private void logShaderStatus(int shaderId, int statusToCheck) {
        try (MemoryStack stack = MemoryStack.stackPush()) {
            if (glGetShaderi(shaderId, statusToCheck) == NULL) {
                ByteBuffer infoLog = stack.malloc(256 * Integer.BYTES);
                glGetShaderInfoLog(shaderId, new int[256], infoLog);

                System.out.println(infoLog.asReadOnlyBuffer().toString());
            }
        }
    }
Pages: 1 [2] 3 4 ... 10