[BUG] Could not query best cursor size on Linux + SWT

Started by deathpat, May 13, 2014, 23:17:40

Previous topic - Next topic

deathpat

Hi !

I'm trying to have LWJGL running inside a SWT frame, but when on linux I get the following error (it works on windows):

[LWJGL] Xrandr extension version 1.4
[LWJGL] Using Xrandr for display mode switching
[LWJGL] XF86VidMode extension version 2.2
[LWJGL] Initial mode: 1920 x 1080 x 24 @50Hz
[LWJGL] Pixel format info: r = 8, g = 8, b = 8, a = 0, depth = 24, stencil = 0, sample buffers = 0, samples = 0
[LWJGL] MemoryUtil Accessor: AccessorUnsafe
[LWJGL] XF86VidMode extension version 2.2
org.lwjgl.LWJGLException: Could not query best cursor size
	at org.lwjgl.opengl.LinuxDisplay.nCreateBlankCursor(Native Method)
	at org.lwjgl.opengl.LinuxDisplay.createBlankCursor(LinuxDisplay.java:1261)
	at org.lwjgl.opengl.LinuxDisplay.createWindow(LinuxDisplay.java:496)
	at org.lwjgl.opengl.Display.createWindow(Display.java:306)
	at org.lwjgl.opengl.Display.create(Display.java:848)
	at org.lwjgl.opengl.Display.create(Display.java:757)
	at org.lwjgl.opengl.Display.create(Display.java:739)
	at com.deathpat.shoot.test.SWTLWJGL.main(SWTLWJGL.java:27)


Linux ubuntu 14.04 LTS
Nvidia GTX 560M
Tried with the latest nightly build of LWJGL

Here is the code used to get this error:

package com.deathpat.shoot.test;

import java.awt.Frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.AWTGLCanvas;

public class SWTLWJGL {
	public static void main(String[] args) {
		System.setProperty("org.lwjgl.util.Debug", "true");
		Display display = new Display();
		Shell shell = new Shell(display, (SWT.TITLE | SWT.CLOSE | SWT.BORDER));
		shell.setLayout(new FillLayout());
		try {
			AWTGLCanvas canvas = new AWTGLCanvas();
			Composite composite = new Composite(shell, SWT.EMBEDDED);
			Frame frame = SWT_AWT.new_Frame(composite);
			frame.add(canvas);
			org.lwjgl.opengl.Display.setParent(canvas);
			org.lwjgl.opengl.Display.create();
		} catch (LWJGLException ex) {
			ex.printStackTrace();
		}
	}
}


Do you have any idea about what's wrong ?

Thanks !
Deathpat.

Cornix

If I had to guess I would say:
Quoteorg.lwjgl.LWJGLException: Could not query best cursor size

Just set the cursor size manually in your code.

deathpat

I checked the lwjgl sources, and createBlankCursor() is called by Display.create() without any condition. So even if I would be able to create somehow a transparent cursor myself, this call would still be made, producing the same result.

deathpat

I managed to get past my issue modifying the createWindow method in the LinuxDisplay class, introducing this dirty workaround:

try {
	blank_cursor = createBlankCursor();
} catch (Exception e) {
	blank_cursor = getCursorHandle(createCursor(1, 1, 0, 0, 1, BufferUtils.createIntBuffer(1), null));
}


But I'm now facing another one: in fact what I would like to do is having LWJGL running in a SWT frame, but with working Mouse and Keyboard classes from LWJGL. Using the classic way of embeding LWJGL into SWT (with SWT GLCanvas, and GLContext.useContext(canvas)) works but Mouse.create() produces an exception saying that the Display is not created.

I would like to use an SWT frame to workaround all the issues the LWJGL windowing system has with Linux in fullscreen / multiple monitors.

So now the error I have with the previously posted code is:

org.lwjgl.LWJGLException: Could not make context current
	at org.lwjgl.opengl.LinuxContextImplementation.nMakeCurrent(Native Method)
	at org.lwjgl.opengl.LinuxContextImplementation.makeCurrent(LinuxContextImplementation.java:121)
	at org.lwjgl.opengl.ContextGL.makeCurrent(ContextGL.java:194)
	at org.lwjgl.opengl.DrawableGL.makeCurrent(DrawableGL.java:110)
	at org.lwjgl.opengl.Display.makeCurrent(Display.java:706)
	at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Display.java:1025)
	at org.lwjgl.opengl.Display.create(Display.java:852)
	at org.lwjgl.opengl.Display.create(Display.java:757)
	at org.lwjgl.opengl.Display.create(Display.java:739)


I can't find a way to have this working.
Is it possible to get LWJGL in SWT with working Mouse and Keyboard ? Or is the Windows implementation working by "mistake" ?
Any help would be greatly appreciated :)

cheers