jME3 test with Eclipse 3.5

I have succeeded in building JME 3 with Eclipse 3.5 but I have had to do this:

http://lkamal.blogspot.com/2008/09/eclipse-access-restriction-on-library.html

Because I had some error messages telling "is not accessible due to restriction on required library" concerning JOGL. I hope that helps.



I have found a bug. My machine has no shader support and I get a NPE in LwjglRenderer when launching TestApplication:

GRAVE G3DSystem 17:42:08 Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
   at com.g3d.renderer.lwjgl.LwjglRenderer.initialize(LwjglRenderer.java:127)
   at com.g3d.system.lwjgl.LwjglContext.create(LwjglContext.java:38)
   at com.g3d.system.lwjgl.LwjglDisplay.initInThread(LwjglDisplay.java:155)
   at com.g3d.system.lwjgl.LwjglDisplay.run(LwjglDisplay.java:221)
   at java.lang.Thread.run(Thread.java:619)



The fix is here:
### Eclipse Workspace Patch 1.0
#P jme3
Index: src/com/g3d/renderer/lwjgl/LwjglRenderer.java
===================================================================
--- src/com/g3d/renderer/lwjgl/LwjglRenderer.java (revision 4528)
+++ src/com/g3d/renderer/lwjgl/LwjglRenderer.java (working copy)
@@ -124,7 +124,9 @@
        TempVars vars = TempVars.get();

        String version = glGetString(GL_SHADING_LANGUAGE_VERSION);
-        if (version.startsWith("1.4")){
+        if (version == null || version.equals("")){
+            glslVer = -1;
+        }else if (version.startsWith("1.4")){
            glslVer = 140;
        }else if (version.startsWith("1.3")){
            glslVer = 130;
@@ -134,8 +136,6 @@
            glslVer = 110;
        }else if (version.startsWith("1.")){
            glslVer = 100;
-        }else if (version == null || version.equals("")){
-            glslVer = -1;
        }

        glGetInteger(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, vars.intBuffer16);


It is not enough, there is another problem with an invalid enumerant, I'm going to fix it:
GRAVE G3DSystem 17:45:31 Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
at org.lwjgl.opengl.Util.checkGLError(Util.java:54)
at org.lwjgl.opengl.Display.swapBuffers(Display.java:640)
at org.lwjgl.opengl.Display.update(Display.java:660)
at com.g3d.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:166)
at com.g3d.system.lwjgl.LwjglDisplay.run(LwjglDisplay.java:226)
at java.lang.Thread.run(Thread.java:619)


What is this shit??
INFO LwjglDisplay 17:54:47 Selected display mode: 640 x 480 x 0 @0Hz


It seems to work now with the fix below:

Index: src/com/g3d/renderer/lwjgl/LwjglRenderer.java
===================================================================
--- src/com/g3d/renderer/lwjgl/LwjglRenderer.java   (revision 4528)
+++ src/com/g3d/renderer/lwjgl/LwjglRenderer.java   (working copy)
@@ -123,8 +123,15 @@
     public void initialize(){
         TempVars vars = TempVars.get();
 
-        String version = glGetString(GL_SHADING_LANGUAGE_VERSION);
-        if (version.startsWith("1.4")){
+        String version;
+        if (GLContext.getCapabilities().GL_ARB_shading_language_100){
+            version = glGetString(GL_SHADING_LANGUAGE_VERSION);
+        }else{
+            version = "";
+        }
+        if (version == null || version.equals("")){
+            glslVer = -1;
+        }else if (version.startsWith("1.4")){
             glslVer = 140;
         }else if (version.startsWith("1.3")){
             glslVer = 130;
@@ -134,24 +141,28 @@
             glslVer = 110;
         }else if (version.startsWith("1.")){
             glslVer = 100;
-        }else if (version == null || version.equals("")){
-            glslVer = -1;
         }
-
-        glGetInteger(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, vars.intBuffer16);
-        vertexTextureUnits = vars.intBuffer16.get(0);
+        if (GLContext.getCapabilities().GL_ARB_vertex_shader){
+            glGetInteger(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, vars.intBuffer16);
+            vertexTextureUnits = vars.intBuffer16.get(0);
+            glGetInteger(GL_MAX_VERTEX_UNIFORM_COMPONENTS, vars.intBuffer16);
+            vertexUniforms = vars.intBuffer16.get(0);
+            glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS, vars.intBuffer16);
+            fragTextureUnits = vars.intBuffer16.get(0);
+        }else{
+            vertexTextureUnits = 0;
+            vertexUniforms = 0;
+            fragTextureUnits = 0;
+        }
         logger.log(Level.FINER, "VTF Units: {0}", vertexTextureUnits);
-
-        glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS, vars.intBuffer16);
-        fragTextureUnits = vars.intBuffer16.get(0);
+        logger.log(Level.FINER, "Vertex Uniforms: {0}", vertexUniforms);
         logger.log(Level.FINER, "Texture Units: {0}", fragTextureUnits);
-
-        glGetInteger(GL_MAX_VERTEX_UNIFORM_COMPONENTS, vars.intBuffer16);
-        vertexUniforms = vars.intBuffer16.get(0);
-        logger.log(Level.FINER, "Vertex Uniforms: {0}", vertexUniforms);
-
-        glGetInteger(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, vars.intBuffer16);
-        fragUniforms = vars.intBuffer16.get(0);
+        if (GLContext.getCapabilities().GL_ARB_fragment_shader){
+            glGetInteger(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, vars.intBuffer16);
+            fragUniforms = vars.intBuffer16.get(0);
+        }else{
+            fragUniforms = 0;
+        }      
         logger.log(Level.FINER, "Fragment Uniforms: {0}", fragUniforms);
        
         glGetInteger(GL_MAX_ELEMENTS_VERTICES, vars.intBuffer16);
@@ -166,8 +177,12 @@
         maxTexSize = vars.intBuffer16.get(0);
         logger.log(Level.FINER, "Maximum Texture Resolution: {0}", maxTexSize);
 
-        glGetInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE, vars.intBuffer16);
-        maxCubeTexSize = vars.intBuffer16.get(0);
+        if (GLContext.getCapabilities().GL_ARB_texture_cube_map){
+            glGetInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE, vars.intBuffer16);
+            maxCubeTexSize = vars.intBuffer16.get(0);
+        }else{
+            maxCubeTexSize = 0;
+        }
         logger.log(Level.FINER, "Maximum CubeMap Resolution: {0}", maxCubeTexSize);
 
         if (GLContext.getCapabilities().GL_EXT_framebuffer_object){
Index: src/com/g3d/system/lwjgl/LwjglDisplay.java
===================================================================
--- src/com/g3d/system/lwjgl/LwjglDisplay.java   (revision 4528)
+++ src/com/g3d/system/lwjgl/LwjglDisplay.java   (working copy)
@@ -129,8 +129,12 @@
             String vendor = glGetString(GL_VENDOR);
             String version = glGetString(GL_VERSION);
             String renderer = glGetString(GL_RENDERER);
-            String shadingLang = glGetString(GL_SHADING_LANGUAGE_VERSION);
-
+            String shadingLang;
+            if(GLContext.getCapabilities().GL_ARB_shading_language_100){
+                shadingLang = glGetString(GL_SHADING_LANGUAGE_VERSION);
+            }else{
+                shadingLang = "";
+            }
             logger.info("Vendor: "+vendor);
             logger.info("Renderer: "+renderer);
 



I get this too:
INFO JoglDisplay 18:45:19 Selected display mode: 640x480x0 @0

I don't know how you handle the case of java.awt.DisplayMode.MULTI_BIT_DEPTH and java.awt.DisplayMode.REFRESH_RATE_UNKNOWN.
gouessej said:

I have found a bug. My machine has no shader support and I get a NPE in LwjglRenderer when launching TestApplication

Thanks for trying it out!  :)
The LWJGL renderer requires OpenGL2 to run, so its not really a bug that it doesn't work. It really should just throw an error if the OpenGL version is less than 2.0. I'll apply your fixes though so its more obvious.

gouessej said:

What is this shit??

INFO LwjglDisplay 17:54:47 Selected display mode: 640 x 480 x 0 @0Hz



This is completely fine if you're running in window mode (not fullscreen). Is this causing any issues?

gouessej said:

I get this too:
INFO JoglDisplay 18:45:19 Selected display mode: 640x480x0 @0

I don't know how you handle the case of java.awt.DisplayMode.MULTI_BIT_DEPTH and java.awt.DisplayMode.REFRESH_RATE_UNKNOWN.

Yeah, I had this problem before when running in linux. It was causing problems with the settings dialog, which I think I fixed..
Momoko_Fan said:

Thanks for trying it out!  :)
The LWJGL renderer requires OpenGL2 to run, so its not really a bug that it doesn't work. It really should just throw an error if the OpenGL version is less than 2.0. I'll apply your fixes though so its more obvious.

But now it works with OpenGL 1.3 on my machine. Why do you want to support only OpenGL 2 and later versions?

Momoko_Fan said:

This is completely fine if you're running in window mode (not fullscreen). Is this causing any issues?

It does not cause any issue as far as I know.

Momoko_Fan said:

Yeah, I had this problem before when running in linux. It was causing problems with the settings dialog, which I think I fixed..

Ok that's fine.

I will investigate more. The keyboard works fine when using the JOGL renderer, it is a good thing, really, nice job. Can someone contribute to JME 3? I would like to modify JoglRenderer to perform the same thing than LwjglRenderer. It would be fine to write a class that does not depend on a specific binding to represent the capabilities instead of calling GLContext.getContextCapabilities() in LWJGL and gl.isExtensionAvailable() in JOGL, it would allow to check capabilities without needing to check explicitly which renderer is used.
gouessej said:

But now it works with OpenGL 1.3 on my machine. Why do you want to support only OpenGL 2 and later versions?

That's strange  :? It shouldn't work because every single test uses a shader. Why support OpenGL2 only? Well, don't you think it's time to move on? OpenGL2 has been around for years and now OpenGL3 is out. If you want to maintain compatibility with older PCs, you have the jME3 JOGL renderer which only requires OpenGL1.1, or you could use jME2, Ardor3D or any other java engine. But jME3 is probably the only Java engine that is specifically designed to work with modern hardware. Making an engine that is compatible with every single PC and makes full use of its hardware capabilities is very difficult. Thats why you have to choose, the new or the old.

gouessej said:

I will investigate more. The keyboard works fine when using the JOGL renderer, it is a good thing, really, nice job. Can someone contribute to JME 3? I would like to modify JoglRenderer to perform the same thing than LwjglRenderer. It would be fine to write a class that does not depend on a specific binding to represent the capabilities instead of calling GLContext.getContextCapabilities() in LWJGL and gl.isExtensionAvailable() in JOGL, it would allow to check capabilities without needing to check explicitly which renderer is used.

Are you referring to issue 52? As OpenGL2 only requires support of shaders, there are many other capabilities that need to be checked in order to ensure that all tests work on all GPUs. The HDR issue came up for example which attempted to use half-float textures and renderbuffers but crashed because the GPU did not support them.
Momoko_Fan said:

That's strange  :? It shouldn't work because every single test uses a shader.

I have no error message but it is only black.

Momoko_Fan said:

Why support OpenGL2 only? Well, don't you think it's time to move on? OpenGL2 has been around for years and now OpenGL3 is out. If you want to maintain compatibility with older PCs, you have the jME3 JOGL renderer which only requires OpenGL1.1, or you could use jME2, Ardor3D or any other java engine. But jME3 is probably the only Java engine that is specifically designed to work with modern hardware. Making an engine that is compatible with every single PC and makes full use of its hardware capabilities is very difficult. Thats why you have to choose, the new or the old.

Maybe some advanced features are hard to implement without shaders. A good compromise would be to disable these features on low end machines (then you don't implement a fallback). Do you really think it would be complicated? Do you plan to rewrite every possible operations with shaders?

I'm sorry but there are only a few engines that work correctly with JOGL. There are Xith3D, Aviatrix3D, ... and that's all. You know I have not fixed several problems in the mouse handling in JME 2, Ardor3D mouse and keyboard support with JOGL/AWT is absent under Linux, JME 3 is becoming the best option on my view.

Momoko_Fan said:

Are you referring to issue 52? As OpenGL2 only requires support of shaders, there are many other capabilities that need to be checked in order to ensure that all tests work on all GPUs. The HDR issue came up for example which attempted to use half-float textures and renderbuffers but crashed because the GPU did not support them.

I was not referring to this. If you're already working on it, you don't need my help.

Hi all,



I'm getting the same error on the 6/21 nightly under the Eclipse Helios RC4 release on Snow Leopard.  Here's my exception (truncated for brevity).  I'm new to jME3 and I'm just trying to do the Hello World example.  Any idea what to do?



Jun 21, 2010 2:24:31 PM com.jme3.asset.DesktopAssetManager <init>
INFO: DesktopAssetManager created.
INFO JmeSystem 2:24:52 PM Running on jMonkey Engine 3 ALPHA 0.50
INFO Natives 2:24:52 PM Extraction Directory #1: file:/Users/rmnoon/acode/jME3_06-21-2010/
INFO Natives 2:24:52 PM Extraction Directory #2: /Users/rmnoon/eclipse_workspace/HelloJME3
INFO Natives 2:24:52 PM Extraction Directory #3: /Users/rmnoon/eclipse_workspace/HelloJME3
INFO LwjglAbstractDisplay 2:24:52 PM Using LWJGL 2.4.2
INFO LwjglDisplay 2:24:52 PM Selected display mode: 640 x 480 x 0 @0Hz
INFO LwjglAbstractDisplay 2:24:52 PM Display created.
INFO LwjglAbstractDisplay 2:24:52 PM Adapter: null
INFO LwjglAbstractDisplay 2:24:52 PM Driver Version: null
INFO LwjglAbstractDisplay 2:24:52 PM Vendor: NVIDIA Corporation
INFO LwjglAbstractDisplay 2:24:52 PM OpenGL Version: 2.1 NVIDIA-1.6.10
INFO LwjglAbstractDisplay 2:24:52 PM Renderer: NVIDIA GeForce GT 330M OpenGL Engine
INFO LwjglAbstractDisplay 2:24:52 PM GLSL Ver: 1.20
INFO LwjglTimer 2:24:52 PM Timer resolution: 1000 ticks per second
INFO Camera 2:24:52 PM Camera created (W: 640, H: 480)
INFO LwjglMouseInput 2:24:52 PM Mouse created.
INFO LwjglKeyInput 2:24:52 PM Keyboard created.
SEVERE Application 2:24:52 PM Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.StackOverflowError
   at java.nio.Bits.byteOrder(Bits.java:555)
   at java.nio.ByteBuffer.<init>(ByteBuffer.java:1361)
   at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:52)
   at java.nio.ByteBuffer.wrap(ByteBuffer.java:350)
   at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:137)
   at java.lang.StringCoding.decode(StringCoding.java:173)
   at java.lang.StringCoding.decode(StringCoding.java:185)
   at java.lang.String.<init>(String.java:570)
   at java.lang.String.<init>(String.java:593)
   at org.lwjgl.openal.ALC10.nalcGetString(Native Method)
   at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:155)
   at org.lwjgl.openal.Util.checkALCError(Util.java:55)
   at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:156)
   at org.lwjgl.openal.Util.checkALCError(Util.java:55)
   at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:156)

I found the other thread where this exception is popping up and it looks like the fix was added after the nightly got made.  I'm grabbing the repo and compiling now.  Will advise.

Ok, so I successfully checked out and built, but running the test application throws the same stack overflow:



noonmac:jme3 rmnoon$ ant run
Buildfile: build.xml

-pre-init:

-init-private:

-pre-init-libraries:

-init-private-libraries:

-init-libraries:

-init-user:

-init-project:

-init-macrodef-property:

-do-init:

-post-init:

-init-check:

-init-macrodef-javac:

-init-macrodef-junit:

-init-debug-args:

-init-macrodef-nbjpda:

-init-macrodef-debug:

-init-macrodef-java:

-init-presetdef-jar:

init:

-deps-jar-init:
   [delete] Deleting: /Users/rmnoon/acode/jme3/build/built-jar.properties

deps-jar:

-warn-already-built-jar:
[propertyfile] Updating property file: /Users/rmnoon/acode/jme3/build/built-jar.properties

-check-automatic-build:

-clean-after-automatic-build:

-verify-automatic-build:

-pre-pre-compile:

-pre-compile:

-compile-depend:

-do-compile:
    [javac] Compiling 2 source files to /Users/rmnoon/acode/jme3/build/classes

-post-compile:

compile:

run:
     [java] Jun 21, 2010 2:43:57 PM jme3test.TestChooser start
     [java] INFO: Composing Test list...
     [java] Jun 21, 2010 2:43:57 PM jme3test.TestChooser find
     [java] INFO: Searching for Demo classes in "jme3test".
     [java] Creating application..
     [java] Jun 21, 2010 2:44:07 PM com.jme3.asset.DesktopAssetManager <init>
     [java] Starting application in LWJGL mode..
     [java] INFO: DesktopAssetManager created.
     [java] INFO JmeSystem 2:44:07 PM Running on jMonkey Engine 3 ALPHA 0.50
     [java] INFO Natives 2:44:07 PM Extraction Directory #1: file:/Users/rmnoon/acode/jme3/build/classes/com/jme3/system/
     [java] INFO Natives 2:44:07 PM Extraction Directory #2: /Users/rmnoon/acode/jme3
     [java] INFO Natives 2:44:07 PM Extraction Directory #3: /Users/rmnoon/acode/jme3
     [java] Waiting 5 seconds
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Using LWJGL 2.4.2
     [java] INFO LwjglDisplay 2:44:07 PM Selected display mode: 640 x 480 x 0 @0Hz
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Display created.
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Adapter: null
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Driver Version: null
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Vendor: NVIDIA Corporation
     [java] INFO LwjglAbstractDisplay 2:44:07 PM OpenGL Version: 2.1 NVIDIA-1.6.10
     [java] INFO LwjglAbstractDisplay 2:44:07 PM Renderer: NVIDIA GeForce GT 330M OpenGL Engine
     [java] INFO LwjglAbstractDisplay 2:44:07 PM GLSL Ver: 1.20
     [java] INFO LwjglTimer 2:44:07 PM Timer resolution: 1000 ticks per second
     [java] INFO Camera 2:44:08 PM Camera created (W: 640, H: 480)
     [java] INFO LwjglMouseInput 2:44:08 PM Mouse created.
     [java] INFO LwjglKeyInput 2:44:08 PM Keyboard created.
     [java] SEVERE Application 2:44:08 PM Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
     [java] java.lang.StackOverflowError
     [java]    at java.nio.ByteBuffer.<init>(ByteBuffer.java:259)
     [java]    at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:52)
     [java]    at java.nio.ByteBuffer.wrap(ByteBuffer.java:350)
     [java]    at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:137)
     [java]    at java.lang.StringCoding.decode(StringCoding.java:173)
     [java]    at java.lang.StringCoding.decode(StringCoding.java:185)
     [java]    at java.lang.String.<init>(String.java:570)
     [java]    at java.lang.String.<init>(String.java:593)
     [java]    at org.lwjgl.openal.ALC10.nalcGetString(Native Method)
     [java]    at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:155)
     [java]    at org.lwjgl.openal.Util.checkALCError(Util.java:55)
     [java]    at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:156)
     [java]    at org.lwjgl.openal.Util.checkALCError(Util.java:55)
     [java]    at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:156)
     [java]    at org.lwjgl.openal.Util.checkALCError(Util.java:55)