Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (537)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Netbeans RCP + LWJGL  (Read 952 times)
0 Members and 1 Guest are viewing this topic.
Offline Tyecon

Senior Newbie





« Posted 2013-07-30 16:16:54 »

Hi, I've been working on a game engine. It uses the LWJGL, Artemis Entity Component System, and TWL Gui libraries. I have a fully working entity component based engine that loads and renders 3d models with modern gl (VBO GLSL based). However I want to put it into a netbeans rcp platform module.
The only resource I can find on this is http://netbeans.dzone.com/lwjgl-nb
However this causes problems with input and TWL, not to mention AWTGLCanvas was deprecated due to Display.setParent. But that causes a Display parent must be displayable error.
Any ideas?

Extra info: I complied my engine into a jar and imported it, LWJGL, TWL, Artemis all as wrapped jars. Natives are loaded with System.loadNatives

Please have a baggy ready before looking at my code.
Offline Tyecon

Senior Newbie





« Reply #1 - Posted 2013-08-02 16:43:08 »

Self reply incase anyone googles this.
Got it working!

To make LWJGL work with the Netbeans RCP Platform create a class that extends java.awt.Canvas
In the constructor put
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
while (!isDisplayable()) {Thread.yield();} //This is the magical line that took me a week to figure out, a little hacky
try {
   Display.setDisplayMode(new DisplayMode(640, 480));
   Display.setVSyncEnabled(false);
   Display.setParent(this); //Magic.
  Display.create();
} catch (LWJGLException ex) {
   System.err.println("Display could not be created");
   ex.printStackTrace(System.err);
   System.exit(-1);
}


Then create and add the canvas to your module. If your using the netbeans GUI designer make sure there is a no argument constructor in your canvas and go to Tools>Add to Palette and choose your canvas from project etc (If you have the file open in the editor it will ask which category to put the file in, netbeans is awesome).

I get some handled exceptions when I run it, but it runs fine regardless. E.g:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
java.lang.Exception: Dangerous reflection access to sun.misc.Unsafe by class org.lwjgl.MemoryUtilSun$AccessorUnsafe detected!
[catch] at org.netbeans.TopSecurityManager.checkMemberAccess(TopSecurityManager.java:440)
   at java.lang.Class.checkMemberAccess(Class.java:2233)
   at java.lang.Class.getDeclaredFields(Class.java:1795)
   at org.lwjgl.MemoryUtilSun$AccessorUnsafe.getUnsafeInstance(MemoryUtilSun.java:74)
   at org.lwjgl.MemoryUtilSun$AccessorUnsafe.<init>(MemoryUtilSun.java:62)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
   at java.lang.Class.newInstance(Class.java:374)
   at org.lwjgl.MemoryUtil.loadAccessor(MemoryUtil.java:375)
   at org.lwjgl.MemoryUtil.<clinit>(MemoryUtil.java:63)
   at org.lwjgl.opengl.LinuxDisplay.setTitle(LinuxDisplay.java:759)
   at org.lwjgl.opengl.Display.setTitle(Display.java:541)
   at org.lwjgl.opengl.Display.createWindow(Display.java:312)
   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 Core.Main.run(Main.java:34)
   at java.lang.Thread.run(Thread.java:724)


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
org.lwjgl.LWJGLException: X Error - disp: 0x7fc54c38cac0 serial: 8409 error: BadDrawable (invalid Pixmap or Window parameter) request_code: 153 minor_code: 8
   at org.lwjgl.opengl.LinuxDisplay.globalErrorHandler(LinuxDisplay.java:318)
   at org.lwjgl.opengl.LinuxContextImplementation.nSwapBuffers(Native Method)
   at org.lwjgl.opengl.LinuxContextImplementation.swapBuffers(LinuxContextImplementation.java:79)
   at org.lwjgl.opengl.ContextGL.swapBuffers(ContextGL.java:175)
   at org.lwjgl.opengl.DrawableGL.swapBuffers(DrawableGL.java:90)
   at org.lwjgl.opengl.Display.swapBuffers(Display.java:618)
   at org.lwjgl.opengl.Display.update(Display.java:646)
Caused: java.lang.RuntimeException
   at org.lwjgl.opengl.Display.update(Display.java:648)
   at org.lwjgl.opengl.Display.update(Display.java:628)
   at Core.Main.run(Main.java:93)
[catch] at java.lang.Thread.run(Thread.java:724)


GL HF

Please have a baggy ready before looking at my code.
Offline Tyecon

Senior Newbie





« Reply #2 - Posted 2013-08-02 18:17:35 »

http://lwjgl.org/forum/topics/hi-vs-low-level-api-performance/5129/view.html

Reported bug on lwjgl forum. I will get this to work.

Please have a baggy ready before looking at my code.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2013-08-03 10:43:45 »

You should switch to Netbeans Platform 7.3.1, it contains a fix that avoids the exception about dangerous reflection access (it doesn't force the application to quit).

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (17 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (20 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (42 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!