thSoft
thSoft

Reputation: 22660

How to use LWJGL in an Eclipse (RCP) application?

I want to use LWJGL in an Eclipse RCP application, but either using the plug-in from http://lwjgl.org/update or manually placing the jars in the classpath and adding Bundle-NativeCode entries, my application hangs at startup after having logged:

!ENTRY org.lwjgl 1 1 2011-12-11 00:27:11.122 !MESSAGE Set org.lwjgl.librarypath to /Users/thsoft/Development/workspace/org.lwjgl/native/macosx, OS: mac os x(x86_64) 2011-12-11 00:27:11.144 java[43495:407] [Java CocoaComponent compatibility mode]: Enabled 2011-12-11 00:27:11.145 java[43495:407] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000

I do have -Dorg.lwjgl.librarypath=/Users/thsoft/Development/MRP/org.lwjgl/native/macosx among the VM arguments of the launch configuration.

(I can use LWJGL in a plain Java project without problem, the issue occurs only in the case of a plug-in project. I'm on OS X 10.7.2.)

Has anyone succeeded to create an RCP application using LWJGL?

Upvotes: 1

Views: 1143

Answers (2)

thSoft
thSoft

Reputation: 22660

It wasn't a classpath issue, but the incorrect usage of OpenGL in the context of an SWT application. I was using the example code from here:

try {
    Display.setDisplayMode(new DisplayMode(800,600));
    Display.create();
} catch (LWJGLException e) {
    e.printStackTrace();
    System.exit(0);
}

// init OpenGL here

while (!Display.isCloseRequested()) {

    // render OpenGL here

    Display.update();
}

Display.destroy();

An example of the correct usage is described here:

    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Composite comp = new Composite(shell, SWT.NONE);
    comp.setLayout(new FillLayout());
    GLData data = new GLData ();
    data.doubleBuffer = true;
    final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data);

    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch(LWJGLException e) { e.printStackTrace(); }

Upvotes: 0

Zoltán Ujhelyi
Zoltán Ujhelyi

Reputation: 13858

GEF3D uses LWJGL and works on OSX - so in theory it is possible to do it. I would look at the lwjgl-specific renderer code - see http://wiki.eclipse.org/GEF3D_Installation#Install_a_Renderer for some minor details.

Sadly, documentation for GEF3D is sparse, but maybe its a start.

Upvotes: 1

Related Questions