javax.media.opengl.GL.glRenderbufferStorageMultisampleEXT

Have jReality programming problems or questions? Post them here.
Post Reply
ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

javax.media.opengl.GL.glRenderbufferStorageMultisampleEXT

Post by ted » Fri 10. Aug 2012, 03:13

Any idea how to fix this or what it means or what it's trying to do?

I'm trying to call JReality from MATLAB through a class that I wrote (below the error)

Here's MATLAB session with the error. You can see that I set up the librarypath the way it sounds like it should be set up, but it seems it couldn't find something in JNI. Not sure why. Any clue?

Code: Select all

  Student License -- for use in conjunction with courses offered at a 
  degree-granting institution.  Professional and commercial use prohibited.

EDU>> java.lang.System.getProperty('java.library.path')
 
ans =
 
/Applications/MATLAB_R2009aSV.app/bin/maci:/Users/ted/workspace/jreality/jni/macosx/:/Users/ted/workspace/jreality/jni/macosx/libgluegen-rt:/Users/ted/workspace/jreality/jni/macosx/libjacknative:/Users/ted/workspace/jreality/jni/macosx/libjinput-osx:/Users/ted/workspace/jreality/jni/macosx/libjogl_awt:/Users/ted/workspace/jreality/jni/macosx/libjogl_cg:/Users/ted/workspace/jreality/jni/macosx/libjogl:/Users/ted/workspace/jreality/jni/macosx/libpdnative:/Users/ted/workspace/jreality/jni/macosx/libSMSLib:/Users/ted/workspace/jreality/jni/macosx/libgluegen-rt.jnilib:/Users/ted/workspace/jreality/jni/macosx/libjacknative.dylib:/Users/ted/workspace/jreality/jni/macosx/libjinput-osx.jnilib:/Users/ted/workspace/jreality/jni/macosx/libjogl_awt.jnilib:/Users/ted/workspace/jreality/jni/macosx/libjogl_cg.jnilib:/Users/ted/workspace/jreality/jni/macosx/libjogl.jnilib:/Users/ted/workspace/jreality/jni/macosx/libpdnative.dylib:/Users/ted/workspace/jreality/jni/macosx/libSMSLib.jnilib
 
EDU>> import edu.utsa.ace.*
EDU>> jr4m = JReality4MatLab(100)
 
jr4m =
 
edu.utsa.ace.JReality4MatLab@d18a80
 
EDU>> jr4m.getFloats()
Allocating BI of size 100:100
??? Java exception occurred:
javax.media.opengl.GLException: java.lang.NoSuchMethodError:
javax.media.opengl.GL.glRenderbufferStorageMultisampleEXT(IIIII)V
	at
        javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:271)
        	at
        javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:256)
        	at
        javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
	at
        de.jreality.jogl.JOGLOffscreenRenderer.renderOffscreen(JOGLOffscreenRenderer.java:92)
        	at
        de.jreality.jogl.AbstractViewer.renderOffscreen(AbstractViewer.java:341)
        	at
        de.jreality.jogl.AbstractViewer.renderOffscreen(AbstractViewer.java:332)
        	at
        de.jreality.jogl.AbstractViewer.renderOffscreen(AbstractViewer.java:328)
        	at
        edu.utsa.ace.JReality4MatLab.getBufferedImage(JReality4MatLab.java:54)
        	at
        edu.utsa.ace.JReality4MatLab.getFloats(JReality4MatLab.java:63)
        Caused by: java.lang.NoSuchMethodError:
        javax.media.opengl.GL.glRenderbufferStorageMultisampleEXT(IIIII)V
        	at
        de.jreality.jogl.JOGLFBO.preRender(JOGLFBO.java:114)
	at
        de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:557)
	at
        de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:416)
	at
        de.jreality.jogl.AbstractViewer.display(AbstractViewer.java:410)
        	at
        com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
        	at
        javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
        	at
        com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
        	at
        javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:298)
        	at
        java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        	at
        java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at
        java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        	at
        java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
	at
        java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        	at
        java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        	at
        java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        	at
        java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        	at
        java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        	at
        java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 
max render buffer size = 8192
creating fbo 1
EDU>> 

Here's my program.

Code: Select all

package edu.utsa.ace;

import java.awt.Component;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

import de.jreality.geometry.Primitives;
import de.jreality.io.JrSceneFactory;


public class JReality4MatLab {

	private final de.jreality.jogl.Viewer v = new de.jreality.jogl.Viewer();
    private int w,h;
    private float[][][] fData;
    private int[][][] iData;
	
	/**
	 * Create a producer of images of nominal size
	 */
	public JReality4MatLab() {
		this(1024,768);
	}
	/**
	 * Create a producer of images of the given size
	 * @param size
	 */
    public JReality4MatLab(int size) {
		this(size,size);
	}
    /**
     * Create a producer of images of the given size
     * @param width
     * @param height
     */
    public JReality4MatLab(int width,int height) {
		w=width;
		h=height;
	    iData = new int[h][w][3];
	    fData = new float[h][w][3];
	 
		v.setSceneRoot(Primitives.wireframeSphere());		
		v.setCameraPath(JrSceneFactory.getDefaultDesktopScene().getPath("cameraPath"));
	
		JFrame frame = new JFrame();
		frame.getContentPane().add((Component) v.getViewingComponent());	
		frame.setVisible(true);
		frame.setVisible(false);
	}

    private BufferedImage getBufferedImage() {
    	v.render();
    	return v.renderOffscreen(w,h);
    }
    
    /**
     * Get an image formatted as MATLAB-organized array of floating point numbers
     * 
     * @return the image
     */
    public float[][][] getFloats() {
        BufferedImage image = getBufferedImage();
		int height = image.getHeight();
		int width = image.getWidth();
		for (int row = 0; row < height; row++ ) {
		    for (int col = 0; col < width; col++ ) {
		        fData[col][row][0] = ( (image.getRGB(row, col) >> 16) & 0xFF) / 256f;
		        fData[col][row][1] = ( (image.getRGB(row, col) >> 8) & 0xFF) / 256f;
		        fData[col][row][2] = (image.getRGB(row, col) & 0xFF) / 256f;
		    }
		}
		return fData;
    }

    /**
     * Get an image formatted as MATLAB-organized array of integers
     * 
     * @return the image
     */
    public int[][][] getInts() {
        BufferedImage image = getBufferedImage();
		int height = image.getHeight();
		int width = image.getWidth();
		for (int row = 0; row < height; row++ ) {
		    for (int col = 0; col < width; col++ ) {
		        iData[col][row][0] = (image.getRGB(row, col) >> 16) & 0xFF;
		        iData[col][row][1] = (image.getRGB(row, col) >> 8) & 0xFF;
		        iData[col][row][2] = image.getRGB(row, col) & 0xFF;
		    }
		}
		return iData;
    }
}
If we can get this to work I'll contribute a tutorial (practically completed) about how to do this and post it on the Wiki.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by gunn » Fri 10. Aug 2012, 07:47

Could it be that it's not a jni problem? The error message you are receiving is also consistent, in my experience, with loading an old jogl.jar, one that does not have the method

Code: Select all

javax.media.opengl.GL.glRenderbufferStorageMultisampleEXT(IIIII)V
Another fact in favor of this interpretation is that the stack trace includes quite a few methods in javax.media.opengl; if the jni libraries were not being found, I'd expect that none of these methods would be available.
jReality core developer

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Fri 10. Aug 2012, 18:12

Thanks for the input. I'll try changing the order of the jars in the path and classpath of MATAB in case there's an older jar earlier in MATLAB's library path or classpath that's messing things up... Beyond that, I'm not sure what else I might try. Dynamic libraries are often such a pain to deal with, it's too bad there's not a better established way in the PC world. :-(

Please let me know if you think of anything else.

_-T

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Fri 10. Aug 2012, 18:28

Still no dice... Any other ideas? These are the same jars and dynlib files that work fine in the Eclipse environment direct from SVN with only the JNI path updated to point to the mac osx folder...

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Sat 11. Aug 2012, 06:44

Here's what I tried on SnowLeopard OSX, using Juno Eclipse and Java 1.6.0_33
(mostly in tutorial format with screendumps removed)

Post-install Configuration

Start with JReality project in Eclipse.

You will need to configure for your operating system to get off-screen rendering.

RightClick jreality, and choose properties.

Choose Java Build Path -> Source -> src-core -? Native library location -> edit

Chose your OS from one of the jni folders in jreality. One of: inux32, linux64, macosx, win32, or win64

New Project Configuration
Create a new Java project for your own work.
File -> New -> Java Project

Choose a name for your project such as jr4matlab. Click NEXT

For Java Settings, click Projects -> Add

check jreality and accept

With jreality added, click Finish. You're ready to create your own classes.

Your project appears along with jreality. You can create classes.

Create a new class in a new package: File -> New -> Class

Choose a globally unique package name based on a reversed internet computer name related to you. Mine is edu.utsa.ace
You will use the name you select again when you import it in MATLAB to access the classes that you create in it.

Choose a name for your class such as JReality4MatLab.

When your package and name are both entered, Finish.

Code: Select all

package edu.utsa.ace;

import java.awt.Component;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

import de.jreality.geometry.Primitives;
import de.jreality.io.JrSceneFactory;


public class JReality4MatLab {

	private final de.jreality.jogl.Viewer v = new de.jreality.jogl.Viewer();
    private int w,h;
    private float[][][] fData;
    private int[][][] iData;
	
	/**
	 * Create a producer of images of nominal size
	 */
	public JReality4MatLab() {
		this(1024,768);
	}
	/**
	 * Create a producer of images of the given size
	 * @param size
	 */
    public JReality4MatLab(int size) {
		this(size,size);
	}
    /**
     * Create a producer of images of the given size
     * @param width
     * @param height
     */
    public JReality4MatLab(int width,int height) {
		w=width;
		h=height;
	    iData = new int[h][w][3];
	    fData = new float[h][w][3];
	 
		v.setSceneRoot(Primitives.wireframeSphere());		
		v.setCameraPath(JrSceneFactory.getDefaultDesktopScene().getPath("cameraPath"));
	
		JFrame frame = new JFrame();
		frame.getContentPane().add((Component) v.getViewingComponent());	
		frame.setVisible(true);
		frame.setVisible(false);
	}

    private BufferedImage getBufferedImage() {
    	v.render();
    	return v.renderOffscreen(w,h);
    }
    
    /**
     * Get an image formatted as MATLAB-organized array of floating point numbers
     * 
     * @return the image
     */
    public float[][][] getFloats() {
        BufferedImage image = getBufferedImage();
		int height = image.getHeight();
		int width = image.getWidth();
		for (int row = 0; row < height; row++ ) {
		    for (int col = 0; col < width; col++ ) {
		        fData[col][row][0] = ( (image.getRGB(row, col) >> 16) & 0xFF) / 256f;
		        fData[col][row][1] = ( (image.getRGB(row, col) >> 8) & 0xFF) / 256f;
		        fData[col][row][2] = (image.getRGB(row, col) & 0xFF) / 256f;
		    }
		}
		return fData;
    }

    /**
     * Get an image formatted as MATLAB-organized array of integers
     * 
     * @return the image
     */
    public int[][][] getInts() {
        BufferedImage image = getBufferedImage();
		int height = image.getHeight();
		int width = image.getWidth();
		for (int row = 0; row < height; row++ ) {
		    for (int col = 0; col < width; col++ ) {
		        iData[col][row][0] = (image.getRGB(row, col) >> 16) & 0xFF;
		        iData[col][row][1] = (image.getRGB(row, col) >> 8) & 0xFF;
		        iData[col][row][2] = image.getRGB(row, col) & 0xFF;
		    }
		}
		return iData;
    }
}
After entering the program, right-click your project and Export…

choose to export it as a Java JAR file.

Take note of the export destination JAR file. You may want to copy it to the clipboard.

Check both the checkboxes for your project (jr4matlab) and for jreality, then finish.

(warnings are OK. errors are not.) no errors.

Now your jar file is ready to use with MATLAB, but you first need to add it to MATLAB's classpath.

In matlab you need to edit the classpath.txt file to do add the JAR file name to the end:

>> edit classpath.txt
This is where you paste the JAR file name on a new line at the end of the file and save it.

Likewise, you need to tell MATLAB where to find those jni files for your os by editing librarypath.txt.

>> edit librarypath.txt

Then In Eclipse's Package Explorer under jreality > jni, right-click on the first file name in the folder for your operating system name,
and choose Copy Qualified Name

Back in MATLAB, paste the names to a new line at the end of librarypath.txt

Back in Eclipse Package Explorer, right-click the reality project and select Properties

Highlight and copy the location

with Resource highlighted, select the location up to but not including "/jreality" and copy it.
Paste it in the front of each line that you added to librarypath.txt in MATLAB

Then save and restart MATLAB.

Now you're ready to import and use your class

>> import edu.utsa.ace.*

>> jr4m = JReality4MatLab(100)

>> image(jr4m.getFloats())


FAILS!

Try moving the dependencies to the top of the paths.

FAILS!

Try developing a project not connected to jreality project
First jar the jr project and add it to a new project, and simply start a JRViewer to display a simple primitive.

FAILS!

Try loading dynamic libraries manually

System.load("/Users/ted/workspace/jreality/jni/macosx/libSMSLib.jnilib");
System.load("/Users/ted/workspace/jreality/jni/macosx/libgluegen-rt.jnilib");
System.load("/Users/ted/workspace/jreality/jni/macosx/libjinput-osx.jnilib");
System.load("/Users/ted/workspace/jreality/jni/macosx/libjogl.jnilib");
System.load("/Users/ted/workspace/jreality/jni/macosx/libjogl_awt.jnilib");
System.load("/Users/ted/workspace/jreality/jni/macosx/libpdnative.dylib");

// System.load("/Users/ted/workspace/jreality/jni/macosx/libjacknative.dylib"); // audio?
System.load("/Users/ted/workspace/jreality/jni/macosx/libjogl_cg.jnilib");

FAILS FOR 2 FILES:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/ted/workspace/jreality/jni/macosx/libjacknative.dylib: Library not loaded: /Library/Frameworks/Jackmp.framework/Versions/A/Jackmp Referenced from: /Users/ted/workspace/jreality/jni/macosx/libjacknative.dylib Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1020)
at TestJrJarApp.main(TestJrJarApp.java:14)

Maybe related to audio and not needed? The other is:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/ted/workspace/jreality/jni/macosx/libjogl_cg.jnilib: Library not loaded: @executable_path/../Frameworks/Cg.framework/Cg Referenced from: /Users/ted/workspace/jreality/jni/macosx/libjogl_cg.jnilib Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1020)
at TestJrJarApp.main(TestJrJarApp.java:15)

Web search suggests loading cg toolkit from dead link

NVIDIA Cg Toolkit
http://developer.nvidia.com/object/cg_t ... #downloads

Google finds a live link that has code:

http://developer.nvidia.com/cg-toolkit/

Run installer

That gets rid of the error with libjogl_cg

Still when you try to construct JRViewer you get

Exception in thread "main" java.lang.NoClassDefFoundError: de/jtem/jrworkspace/plugin/sidecontainer/template/ShrinkPanelPlugin
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at TestJrJarApp.main(TestJrJarApp.java:17)
Caused by: java.lang.ClassNotFoundException: de.jtem.jrworkspace.plugin.sidecontainer.template.ShrinkPanelPlugin
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 25 more


Has anyone deployed Jreality on OSX stuff outside of Eclipse?
(It looks like I need to get that working first)

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by gunn » Fri 17. Aug 2012, 10:54

Here's something you can do to make sure that you are loading the jars which you think you are loading. Insert somewhere at the beginning of your code:

Code: Select all

		String cp = System.getProperty("java.class.path").replace(':', '\n');
		System.err.println("cp = "+cp);
For example, you could check which jogl.jar and which jrworkspace.jar files, if any, are in the classpath when you run your application, since they have been the source of the "NoSuchMethod" exceptions.
jReality core developer

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Wed 22. Aug 2012, 21:43

Thanks.. maybe getting a bit closer... I copied the entire classpath to the top of MATLAB's classpath.txt file

Code: Select all

/Users/ted/workspace/jr-practice/bin
/Users/ted/workspace/jreality/bin
/Users/ted/workspace/jreality/lib/antlr.jar
/Users/ted/workspace/jreality/lib/jogl.jar
/Users/ted/workspace/jreality/lib/jterm.jar
/Users/ted/workspace/jreality/lib/smrj.jar
/Users/ted/workspace/jreality/lib/janino.jar
/Users/ted/workspace/jreality/lib/sunflow.jar
/Users/ted/workspace/jreality/lib/xpp3.jar
/Users/ted/workspace/jreality/lib/xstream.jar
/Users/ted/workspace/jreality/lib/jinput.jar
/Users/ted/workspace/jreality/lib/smrj-app.jar
/Users/ted/workspace/jreality/lib/bsh.jar
/Users/ted/workspace/jreality/lib/iText-2.1.3.jar
/Users/ted/workspace/jreality/lib/colorpicker.jar
/Users/ted/workspace/jreality/lib/gluegen-rt.jar
/Users/ted/workspace/jreality/lib/vrData.jar
/Users/ted/workspace/jreality/lib/jacknativeclient.jar
/Users/ted/workspace/jreality/lib/netutil.jar
/Users/ted/workspace/jreality/lib/vrExamples.jar
/Users/ted/workspace/jreality/lib/beans.jar
/Users/ted/workspace/jreality/lib/pd.jar
/Applications/eclipse/plugins/org.junit_4.10.0.v4_10_0_v20120426-0900/junit.jar
/Applications/eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar
/Users/ted/workspace/jreality/lib/jrworkspace.jar
Then, after importing these:

Code: Select all

import java.awt.Component;
import java.awt.image.BufferedImage;
import java.lang.String;
import javax.swing.JFrame;
import de.jreality.geometry.Primitives;
import de.jreality.io.JrSceneFactory;
import de.jreality.jogl.Viewer;
I created a jogl Viewer in MATLAB,
added a scene graph component to it,
set up a camera path
added the viewing component to a JFrame
(note: there's no parenthesis for parameterless MATLAB function calls, as it would interpret that as attempting to index as an array)

Code: Select all

v = de.jreality.jogl.Viewer;
v.setSceneRoot(Primitives.wireframeSphere());
p = java.lang.String('cameraPath');
v.setCameraPath(JrSceneFactory.getDefaultDesktopScene.getPath(p));
frame = JFrame;
Thus far, everything seems OK...
but setVisible seems to cause some internal problems.

Code: Select all

frame.setVisible(true)
What can I do about this?

Code: Select all

Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Attempt to make the same context current twice on thread Thread[AWT-EventQueue-0,6,main]
	at com.sun.opengl.impl.GLContextLock.lock(GLContextLock.java:83)
	at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:131)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
	at sun.awt.RepaintArea.paint(RepaintArea.java:241)
	at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
	at java.awt.Component.dispatchEventImpl(Component.java:4813)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:684)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:657)
	at java.awt.EventQueue$2.run(EventQueue.java:655)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:654)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
It happens every time the JFrame tries to repaint itself. (whenever you resize the JFrame window, etc)
The JFrame window remains blank.

My goal is to achieve offscreen rendering by issuing the following additional commands. :

Code: Select all

frame.setVisible(false);
v.render;
bi = v.renderOffscreen(1024,768);
But the call to v.render causes

Code: Select all

java.lang.reflect.InvocationTargetException
	at java.awt.EventQueue.invokeAndWait(EventQueue.java:1091)
	at de.jreality.jogl.AbstractViewer.render(AbstractViewer.java:491)
Caused by: javax.media.opengl.GLException: Attempt to make the same context current twice on thread Thread[AWT-EventQueue-0,6,main]
	at com.sun.opengl.impl.GLContextLock.lock(GLContextLock.java:83)
	at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:131)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at de.jreality.jogl.AbstractViewer.run(AbstractViewer.java:451)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
so the call to renderOffscreen gives a null result.

Any ideas?

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Fri 24. Aug 2012, 21:31

I found this:
And we need to tell java where to find the corresponding native libraries. This is done by the -Djava.library.path-flag:
Isn't working yet. Under Construction ;)

java -Djava.library.path=. de.jreality.tutorial.geom.Cube05
at http://www3.math.tu-berlin.de/jreality/ ... e-tutorial

As a workaround I'm using a SocketServer to deliver rendered images to a Socket that MATLAB can call.

My next problem is that de.jreality.jogl.Viewer renderes strange random lighting that changes with each re-rendering, unlike VRViewer.

This gives good results:

Code: Select all

	public static void main(String[] unused) throws IOException {
		RoboticSystem scene = new RoboticSystem();
		final Viewer viewer = JRViewer.display(scene);
		scene.setupViewer(viewer);
	}

shown on the right of this screen-dump:
Image
But the image on the left shows uncontrolled lighting using de.jreality.jogl.Viewer,
produced by the code below:

Code: Select all

	BufferedImageServer() throws IOException {
		final de.jreality.jogl.Viewer v = new de.jreality.jogl.Viewer();
		RoboticSystem scene = new RoboticSystem();
		Appearance ap;
		scene.setAppearance(ap = new Appearance());
		v.setSceneRoot(scene);	
		SceneGraphComponent auxiliaryRoot = new SceneGraphComponent();
		v.setAuxiliaryRoot(auxiliaryRoot);
		scene.setupViewer(v);
			
		JFrame frame = new JFrame();
		frame.getContentPane().add((Component) v.getViewingComponent());	
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(640,480);
		v.render();
	}
I need the de.jreality.jogl.Viewer for offscreen rendering.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by gunn » Sat 25. Aug 2012, 09:29

Which backend are you using with the JRViewer option? If you're not sure, look at the menu item "Viewer". If "Viewer" is checked you are using de.jreality.jogl.Viewer. If this is the case, then it would be more promising to look for differences in the scene graphs being rendered in the two cases, since in both cases the same backend (de.jreality.jogl.Viewer) is being used.

And then I would look into the lights which are being used. In the "viewer from scratch" option, you are not creating any lights, so I assume the lights are being provided by the setupViewer() method. On the other hand, JRViewer provides its own lights and camera path and other infrastructure, so I'd be interested how what you are providing (via setupViewer()) is being used (or not used) in the JRViewer option. Perhaps posting the setupViewer() method would be advisable if it's not immediately clear what the problem is.
jReality core developer

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by ted » Thu 30. Aug 2012, 07:01

It's working ok now with the lights correctly configured, but there still seems to be a limit on the number of point light sources, around 6 not including the default sun and headlight of VRViewer.

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 9
	at java.util.Vector.remove(Vector.java:777)
	at de.jreality.jogl.JOGLLightHelper.resetLights(JOGLLightHelper.java:62)
	at de.jreality.jogl.JOGLRenderer.processLights(JOGLRenderer.java:295)
	at de.jreality.jogl.JOGLRenderer.renderOnePass(JOGLRenderer.java:259)
	at de.jreality.jogl.JOGLRenderer.render(JOGLRenderer.java:212)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:554)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:408)
	at de.jreality.jogl.AbstractViewer.display(AbstractViewer.java:410)
	at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
	at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
	at sun.awt.RepaintArea.paint(RepaintArea.java:241)
	at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
	at java.awt.Component.dispatchEventImpl(Component.java:4813)
	at java.awt.Component.dispatchEvent(Component.java:4565)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:684)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
	at java.awt.EventQueue$2.run(EventQueue.java:657)
	at java.awt.EventQueue$2.run(EventQueue.java:655)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:654)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
java.lang.reflect.InvocationTargetException
	at java.awt.EventQueue.invokeAndWait(EventQueue.java:1091)
	at de.jreality.jogl.AbstractViewer.render(AbstractViewer.java:491)
	at de.jreality.ui.viewerapp.ViewerSwitch.render(ViewerSwitch.java:189)
	at de.jreality.util.RenderTrigger$RenderTriggerSingleCaster.render(RenderTrigger.java:222)
	at de.jreality.util.RenderTrigger.fireRender(RenderTrigger.java:138)
	at de.jreality.util.RenderTrigger.finishCollect(RenderTrigger.java:260)
	at de.jreality.toolsystem.ToolSystem.processToolEvent(ToolSystem.java:486)
	at de.jreality.toolsystem.ToolEventQueue$1.run(ToolEventQueue.java:82)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 9
	at java.util.Vector.remove(Vector.java:777)
	at de.jreality.jogl.JOGLLightHelper.resetLights(JOGLLightHelper.java:62)
	at de.jreality.jogl.JOGLRenderer.processLights(JOGLRenderer.java:295)
	at de.jreality.jogl.JOGLRenderer.renderOnePass(JOGLRenderer.java:259)
	at de.jreality.jogl.JOGLRenderer.render(JOGLRenderer.java:212)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:554)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:408)
	at de.jreality.jogl.AbstractViewer.display(AbstractViewer.java:410)
	at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
	at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at de.jreality.jogl.AbstractViewer.run(AbstractViewer.java:451)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Vendor = NVIDIA Corporation
Have automipmap generation = true
java.lang.reflect.InvocationTargetException
	at java.awt.EventQueue.invokeAndWait(EventQueue.java:1091)
	at de.jreality.jogl.AbstractViewer.render(AbstractViewer.java:491)
	at de.jreality.ui.viewerapp.ViewerSwitch.render(ViewerSwitch.java:189)
	at de.jreality.util.RenderTrigger$RenderTriggerSingleCaster.render(RenderTrigger.java:222)
	at de.jreality.util.RenderTrigger.fireRender(RenderTrigger.java:138)
	at de.jreality.util.RenderTrigger.finishCollect(RenderTrigger.java:260)
	at de.jreality.toolsystem.ToolSystem.processToolEvent(ToolSystem.java:486)
	at de.jreality.toolsystem.ToolEventQueue$1.run(ToolEventQueue.java:82)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 9
	at java.util.Vector.remove(Vector.java:777)
	at de.jreality.jogl.JOGLLightHelper.resetLights(JOGLLightHelper.java:62)
	at de.jreality.jogl.JOGLRenderer.processLights(JOGLRenderer.java:295)
	at de.jreality.jogl.JOGLRenderer.renderOnePass(JOGLRenderer.java:259)
	at de.jreality.jogl.JOGLRenderer.render(JOGLRenderer.java:212)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:554)
	at de.jreality.jogl.JOGLRenderer.display(JOGLRenderer.java:408)
	at de.jreality.jogl.AbstractViewer.display(AbstractViewer.java:410)
	at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
	at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at de.jreality.jogl.AbstractViewer.run(AbstractViewer.java:451)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: javax.media.opengl.GL.glRenderbufferStorageMultisampleEX

Post by gunn » Thu 30. Aug 2012, 16:03

Yes, there is currently a limit of 8 lights in the JOGL backend. I believe that's related to some related constant in the OpenGL specification regarding the minimum number of lights an OpenGL implementation must support. It shouldn't be too hard to change; look in the class JOGLLIghtHelper and specifically the line 25:

Code: Select all

	private  int maxLights = 8;
We're currently switching over to a newer version of OpenGL and do not plan to used fixed functionality pipeline in the future so we'll probably leave this old code the way it is.
jReality core developer

Post Reply