Hello Guest

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Lightweight Java Gaming Library / Assimp memory leak
« Last post by Edde on September 28, 2020, 16:43:36 »
I'm trying to load obj models using assimp but I get a memory leak

[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3EE50000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileCloseProc.<init>(AIFileCloseProc.java:51)
   at com.eldev.engine.loader.MeshLoader$2.<init>(MeshLoader.java:80)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:80)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3EE40000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileOpenProc.<init>(AIFileOpenProc.java:52)
   at com.eldev.engine.loader.MeshLoader$1.<init>(MeshLoader.java:40)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:40)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D40490000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileReadProc.<init>(AIFileReadProc.java:53)
   at com.eldev.engine.loader.MeshLoader$1$1.<init>(MeshLoader.java:50)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:50)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D404B0000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileTellProc.<init>(AIFileTellProc.java:50)
   at com.eldev.engine.loader.MeshLoader$1$3.<init>(MeshLoader.java:69)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:69)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D404A0000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileSeek.<init>(AIFileSeek.java:52)
   at com.eldev.engine.loader.MeshLoader$1$2.<init>(MeshLoader.java:57)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:57)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3F5D0000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileTellProc.<init>(AIFileTellProc.java:50)
   at com.eldev.engine.loader.MeshLoader$1$3.<init>(MeshLoader.java:69)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:69)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3F5C0000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileSeek.<init>(AIFileSeek.java:52)
   at com.eldev.engine.loader.MeshLoader$1$2.<init>(MeshLoader.java:57)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:57)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3F5B0000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileReadProc.<init>(AIFileReadProc.java:53)
   at com.eldev.engine.loader.MeshLoader$1$1.<init>(MeshLoader.java:50)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:50)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3FD40000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileTellProc.<init>(AIFileTellProc.java:50)
   at com.eldev.engine.loader.MeshLoader$1$3.<init>(MeshLoader.java:69)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:69)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3FD30000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileSeek.<init>(AIFileSeek.java:52)
   at com.eldev.engine.loader.MeshLoader$1$2.<init>(MeshLoader.java:57)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:57)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
[LWJGL] 16 bytes leaked, thread 1 (Game Thread), address: 0x12D3FD20000
   at org.lwjgl.system.Callback.create(Callback.java:136)
   at org.lwjgl.system.Callback.<init>(Callback.java:86)
   at org.lwjgl.assimp.AIFileReadProc.<init>(AIFileReadProc.java:53)
   at com.eldev.engine.loader.MeshLoader$1$1.<init>(MeshLoader.java:50)
   at com.eldev.engine.loader.MeshLoader$1.invoke(MeshLoader.java:50)
   at org.lwjgl.assimp.AIFileOpenProcI.callback(AIFileOpenProcI.java:33)
   at org.lwjgl.system.JNI.invokePPP(Native Method)
   at org.lwjgl.assimp.Assimp.naiImportFileEx(Assimp.java:2593)
   at org.lwjgl.assimp.Assimp.aiImportFileEx(Assimp.java:2641)
   at com.eldev.engine.loader.MeshLoader.loadMesh(MeshLoader.java:86)
   at com.eldev.game.Game.main(Game.java:26)
22
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by Fire_Blaim on September 27, 2020, 17:47:52 »
Oh my god it worked thank you so much !  :D
23
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by KaiHH on September 27, 2020, 17:42:37 »
Yes, the problem now is that now you are requesting an actual OpenGL 4.1 core context, in which all deprecated functions (including glVertexPointer, glEnableClientState and glDisableClientState) are not available anymore.
When you want to use an OpenGL >= 3.2 core context, you must use shaders and generic vertex attributes with a VAO and VBO.
So: Either you do not explicitly request an OpenGL >= 3.2 core context anymore (simply omit all glfw window hints) or you use core profile functions only, so no glVertexPointer, glEnableClientState and glDisableClientState.
24
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by Fire_Blaim on September 27, 2020, 17:32:22 »
I changed the code like you want but I have a No context error  :(

Code: [Select]
FATAL ERROR in native method: Thread[main,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
at org.lwjgl.opengl.GL11.nglVertexPointer(Native Method)
at org.lwjgl.opengl.GL11.glVertexPointer(GL11.java:7952)
at fr.fireblaim.testvbo.Main.main(Main.java:65)
25
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by KaiHH on September 26, 2020, 21:23:14 »
There are two issues with this code:
1. you set GLFW window hints AFTER you created the GLFW window, so those hints will not have any effect and you will likely get a OpenGL 2.1 context or a compatibility context with the highest version number the driver supports (depending on the driver).
2. For some reason (you didn't do this before) you specify the vbo handle/id as the first argument to glVertexPointer(). This is wrong! The first argument is the component count of the vertex attribute. It should be 2 in your case.

I highly recommend adding the following call right after GL.createCapabilities() in order for you to get any sort of OpenGL error outputs from the driver:
Code: [Select]
org.lwjgl.opengl.GLUtil.setupDebugMessageCallback();
Note that OpenGL errors will not manifest in Java exceptions with LWJGL. Without installing an OpenGL debug message callback (or calling glGetError()) you will simply never know when you make an invalid OpenGL call, which can potentially result in a crash later on.
26
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by Fire_Blaim on September 26, 2020, 20:02:48 »
I changed the code since for be more explicit and have a cleaner code :

Code: [Select]
package fr.fireblaim.testvbo;

import org.lwjgl.*;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.opengl.*;

import java.nio.*;

import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.system.MemoryUtil.*;

public class Main {

    public static void main(String[] args) {
        if (!glfwInit()) {
            System.out.println("GLFW not init.");
            return;
        }

        GLFWErrorCallback.createPrint(System.err).set();

        long window = glfwCreateWindow(500, 500, "Window", NULL, NULL);

        if (window == NULL) {
            System.out.println("Window not create.");
            return;
        }

        glfwDefaultWindowHints();
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

        glfwShowWindow(window);
        glfwMakeContextCurrent(window);

        GL.createCapabilities();

        float[]vboData=new float[] {
                10, -10,
                10, -10,
                10, 10,
                -10, 10
        };

        FloatBuffer buf = BufferUtils.createFloatBuffer(vboData.length);
        buf.put(vboData).flip();

        int vbo = glGenBuffers();

        glBindBuffer(GL_ARRAY_BUFFER,vbo);
        glBufferData(GL_ARRAY_BUFFER, buf, GL_STATIC_DRAW);

        while (!glfwWindowShouldClose(window)) {
            glClearColor(0.2f, 0.2f, 0.2f, 1);
            glClear(GL_COLOR_BUFFER_BIT);

            glEnableClientState(GL_VERTEX_ARRAY);

            glVertexPointer(vbo, GL_FLOAT, 0, 0);
            glDrawArrays(GL_QUADS, 0, 4);

            glDisableClientState(GL_VERTEX_ARRAY);

            glfwSwapBuffers(window);
            glfwPollEvents();
        }

        glfwDestroyWindow(window);
        glfwTerminate();
    }
}

The buffer would be ok but I have the same jvm error....
27
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by KaiHH on September 26, 2020, 16:12:17 »
The next problem is that you are putting far too few data in your vertexBuffer and colorBuffer FloatBuffers. In your draw call you are telling OpenGL that you have 2 * 2 * 4 = 16 vertices, however you only specify 4 vertices' worth of position data (one vertex position being 2 floats, and you only put 8 floats in the vertexBuffer FloatBuffer) and you only specify 1 vertex' worth of color data (one vertex color being 3 floats and you only put 3 floats in the colorBuffer FloatBuffer). So, after flipping the buffers, the effective remaining() element count in the vertexBuffer FloatBuffer is 8 floats and in the colorBuffer FloatBuffer is 2 floats.
That is too few to draw 16 vertices.
28
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by Fire_Blaim on September 26, 2020, 16:00:16 »
I changed the code :
Code: [Select]
package fr.fireblaim.template.game;

import org.lwjgl.BufferUtils;

import java.nio.FloatBuffer;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;

public class Game {

    int vbo;
    int cbo;

    int vertexSize = 2;
    int colorSize = 3;

    int verticesSize;

    FloatBuffer vertexBuffer;
    FloatBuffer colorBuffer;

    public Game() {
        verticesSize = 2 * 2 * 4;

        vertexBuffer = BufferUtils.createFloatBuffer(verticesSize * vertexSize);
        colorBuffer = BufferUtils.createFloatBuffer(verticesSize * colorSize);

        int size = 1;

        colorBuffer.put(1).put(1).put(1);

        vertexBuffer.put(1).put(1);
        vertexBuffer.put(1 + size).put(1);
        vertexBuffer.put(1 + size).put(1 + size);
        vertexBuffer.put(1).put(1 + size);

        vertexBuffer.flip();
        colorBuffer.flip();

        vbo = glGenBuffers();
        cbo = glGenBuffers();

        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(vbo, vertexBuffer, GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, cbo);
        glBufferData(cbo, colorBuffer, GL_STATIC_DRAW);

        vertexBuffer.clear();
        colorBuffer.clear();
    }

    public void render() {
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);

        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);

        glBindBuffer(GL_ARRAY_BUFFER, cbo);
        glColorPointer(colorSize, GL_FLOAT, 0, 0L);

        glDrawArrays(GL_QUADS, 0, verticesSize);

        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);
    }

    public void update() {

    }

}

But I have the same error :( Thanks for your response Kaihh you're a good guy !
29
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by KaiHH on September 26, 2020, 15:58:13 »
I told you what the problem is. And I also told you how you can fix it (e.g. by actually specifying the color data via glColorPointer - if you want to stay with client-side arrays). glVertexPointer ONLY sets the vertex "position" data, NOT the color data!
Now, if you don't understand what that means, then you should consult more OpenGL learning resources and do some more research/learning yourself.
30
Bug Reports / RFE / Re: Error JVM with glDraysArrays (VBO)
« Last post by Fire_Blaim on September 26, 2020, 15:49:52 »
I don't understand what do you mean for the "You enable the client-side color array, however you never specified any vertex data for the color attribute for it. You are using the fixed-function and deprecated glVertexPointer function. This is for setting the fixed-function "position" vertex attribute ONLY! There is a corresponding glColorPointer function for setting the fixed-function color vertex attribute data.". Please give me the solution if it doesn't bother you.  I know it would be better to use shaders but this code is for test purposes only I would like to use them later. I've followed some tutorial videos on lwjgl 3 but it should work fine...
Pages: 1 2 [3] 4 5 ... 10