Usage of LWJGL 3

It is very good, because input of GLFW is very terrible. :smile: I have several problems with input for JFX :smile:

1 Like

I have this exception when I tested on Windows.

java.lang.NullPointerException
	at com.jme3.app.Application.reshape(Application.java:526)
	at com.jme3.system.lwjgl.LwjglWindow$2.invoke(LwjglWindow.java:207)
	at org.lwjgl.glfw.GLFWWindowSizeCallback.callback(GLFWWindowSizeCallback.java:45)
	at org.lwjgl.system.JNI.invokePV(Native Method)
	at org.lwjgl.glfw.GLFW.glfwShowWindow(GLFW.java:1692)
	at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:246)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:326)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:445)
	at java.lang.Thread.run(Thread.java:745)

It is fix this:

/**
     * Internal use only.
     */
    public void reshape(int w, int h){
        if(renderManager != null) {
            renderManager.notifyReshape(w, h);
        }
    }

in com.jme3.app.Application

Please pardon my ignorance, but what are we using right now? Currently joypads works well with DirectInput and sort of works for Xinput… should I expect some breakage?

1 Like

We use JInput.

The issue is when moving to lwjgl3 they use glfw or whatever instead of JInput. But the regular lwjgl that you get when you don’t monkey with things already uses JInput. We’re just talking about breaking it out so we can use it always.

3 Likes

I fixed my problems with text input in LWJGL3 in com.jme3.input.lwjgl.GlfwKeyInput

public void initialize() {
        if (!context.isRenderable()) {
            return;
        }

        glfwSetKeyCallback(context.getWindowHandle(), keyCallback = new GLFWKeyCallback() {
            @Override
            public void invoke(long window, int key, int scancode, int action, int mods) {

                int jmeKey = GlfwKeyMap.toJmeKeyCode(key);
                final KeyInputEvent evt = new KeyInputEvent(jmeKey, '\0', GLFW_PRESS == action, GLFW_REPEAT == action);

                evt.setTime(getInputTimeNanos());
                keyInputEvents.add(evt);
            }
        });

       glfwSetCharCallback(context.getWindowHandle(), charCallback = new GLFWCharCallback() {

        @Override
        public void invoke(long window, int codepoint) {

            final char keyChar = (char) codepoint;

            final KeyInputEvent evt = new KeyInputEvent(KeyInput.KEY_UNKNOWN, keyChar, true, false);
            evt.setTime(getInputTimeNanos());

            keyInputEvents.add(evt);
        }
    });

        glfwSetInputMode(context.getWindowHandle(), GLFW_STICKY_KEYS, 1);

        initialized = true;
        logger.fine("Keyboard created.");
    }
1 Like

JInput has many problems with Russian keyboard layout. I finished testing GLFWInput, it doesn’t has these problems. :smile:

2 Likes

How I can check on runtime which version of LWJGL uses in application?

" LWJGL:" + Sys.getVersion()

LWJGL3 does not have a Sys class. Actually I am not sure how to answer this question… Easiest option I see is to add a JmeContext.getVersion() method or similar.

LWJGL3 has a class called Version with a static method of getVersion(). However the Version class also has some public static int declared which will tell you what version it is.

	public static final int
		VERSION_MAJOR    = 3,
		VERSION_MINOR    = 0,
		VERSION_REVISION = 0;

Perhaps we should have a getVersion() method on the Renderer class or actually on the JmeContext like @Momoko_Fan mentioned.

Oh i skipped the 3 apparently :slight_smile:

In relation to the Joystick issues with GLFW these should now be fixed as per the following bug fixes:
https://github.com/glfw/glfw/issues/232
https://github.com/glfw/glfw/issues/700
https://github.com/glfw/glfw/issues/601

The new version of GLFW should be appearing in the nightly builds of LWJGL3 shortly. The final LWJGL 3.0.0 release is expected to be released after GLFW 3.2 is released (only a couple of issues left for that, see Issues · glfw/glfw · GitHub ).

1 Like

That looks pretty good, but it is still lacking force feedback support, which is something that JInput has.

1 Like

Hi Guys
Thought to inform about :
GLFW 3.2 Released on June 2, 2016 http://www.glfw.org/changelog.html , Release 3.2 · glfw/glfw · GitHub

LWJGL 3.0 Released on June 3,2016 Release LWJGL 3.0.0 · LWJGL/lwjgl3 · GitHub
It Dropped support for Linux x86.

There are still x86 machines?

1 Like

Um, yes. Like my PC where I accidentialy installed ubuntu 32 bit instead of 64 bit and was too lazy to make a reinstall.

… ok but that is a solveable problem XD

That’s not always solvable, no… :stuck_out_tongue:

3 Likes

Nah if the support is droped, he gets a gentle push to do a reinstall :slight_smile:

Just dropped in to say that I tried to convert our JME 3.1 project to LWJGL 2 → 3. Just a couple of Display class usages on our part replaced to JME. Conversion was easy.

I noticed:

  1. Huge FPS drop!
  2. Application icons don’t work anymore