glMultiDrawElements, please help

Hello,

everytime I am trying to use glMultiDrawElements, I get an UnsatisfiedLinkError for both versions :

java.lang.UnsatisfiedLinkError: dispatch_glMultiDrawElements0

at com.sun.opengl.impl.GLImpl.dispatch_glMultiDrawElements0(Native Method)

at com.sun.opengl.impl.GLImpl.glMultiDrawElements(GLImpl.java:12535)

at VboFrame.renderArraySphere(VboFrame.java:421)

at VboFrame.display(VboFrame.java:165)

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:171)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

however, if I’m using glDrawElements with a for loop, it works!

Here is my example :

http://horustempel.de/OpenGL/VboFrame.java

and

http://horustempel.de/OpenGL/FPSCounter.java

What I am doing wrong ???

dj3hut1

I’m pretty sure MultiDrawElements works from JOGL; have you checked to make sure your jogl.jar and libjogl.so/jogl.dll match up?

To be honest though I would recommend you just call glDrawElements from within a loop. glMultiDrawElements is a pain to set up from Java and I think that just repeatedly calling glDrawElements is probably more efficient.

I have hte same problem with MultiDrawElements.
SO i replace MultiDrawElems w/ DrawElems and
it works. Yay! One more red book example ported!

My placement of jogl files are in the correct places.

So what is the correct setup for MultiDrawElems?

/**
 * 
 */
package glredbook1314;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
import javax.swing.JFrame;

import com.sun.opengl.util.BufferUtil;

/**
 * This program demonstrates multiple vertex arrays, specifically the OpenGL
 * routine glMultiDrawElements(), but it's a bitch to setup--so I use
 * DrawElements in a loop.
 * 
 * @author Kiet Le (JOGL port)
 */
public class mvarray //
		implements GLEventListener //
		, KeyListener {
	private GLU glu;

	private int vertices[] = { 25, 25,//
			75, 75,//
			100, 125,//
			150, 75,//
			200, 175,//
			250, 150,//
			300, 125,//
			100, 200,//
			150, 250,//
			200, 225,//
			250, 300,//
			300, 250 };

	private IntBuffer vertexBuf = //
	BufferUtil.newIntBuffer(vertices.length);

	private byte oneIndices[] = { 0, 1, 2, 3, 4, 5, 6 };

	private byte twoIndices[] = { 1, 7, 8, 9, 10, 11 };

	private int count[] = { 7, 6 };

	private ByteBuffer indices[] = {//
	BufferUtil.newByteBuffer(oneIndices.length),
			BufferUtil.newByteBuffer(twoIndices.length) };

	// static GLvoid * indices[2] = {oneIndices, twoIndices};
	/**
	 * 
	 */
	public mvarray() {
		vertexBuf.put(vertices);
		indices[0].put(oneIndices);
		indices[1].put(twoIndices);
		vertexBuf.rewind();
		indices[0].rewind();
		indices[1].rewind();
	}

	private void setupPointer(GL gl) {
		gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
		gl.glVertexPointer(2, GL.GL_INT, 0, vertexBuf);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable)
	 */
	public void display(GLAutoDrawable drawable) {
		final GL gl = drawable.getGL();
		//

		gl.glClear(GL.GL_COLOR_BUFFER_BIT);
		gl.glColor3f(1.0f, 1.0f, 1.0f);

		// gl.glMultiDrawElements(GL.GL_LINE_STRIP, count, 0,//
		// GL.GL_UNSIGNED_BYTE, indices, 2);
		for (int i = 0; i < indices.length; i++)
			gl.glDrawElements(GL.GL_LINE_STRIP, count[i], //
					GL.GL_UNSIGNED_BYTE, indices[i]);

		gl.glFlush();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.media.opengl.GLEventListener#displayChanged(javax.media.opengl.GLAutoDrawable,
	 *      boolean, boolean)
	 */
	public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
			boolean deviceChanged) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable)
	 */
	public void init(GLAutoDrawable drawable) {
		final GL gl = drawable.getGL();
		glu = new GLU();
		//
		gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		gl.glShadeModel(GL.GL_SMOOTH);
		setupPointer(gl);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable,
	 *      int, int, int, int)
	 */
	public void reshape(GLAutoDrawable drawable, int x, int y, //
			int width, int height) {
		final GL gl = drawable.getGL();
		//
		gl.glViewport(0, 0, width, height);
		gl.glMatrixMode(GL.GL_PROJECTION);
		gl.glLoadIdentity();
		glu.gluOrtho2D(0.0, (double) width, 0.0, (double) height);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		mvarray demo = new mvarray();
		//
		GLCapabilities caps = new GLCapabilities();
		caps.setSampleBuffers(true);
		GLCanvas canvas = new GLCanvas(caps);
		canvas.addGLEventListener(demo);
		canvas.addKeyListener(demo);
		//
		JFrame frame = new JFrame("mvarray");
		frame.setSize(350, 350);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(canvas);
		frame.setVisible(true);
		canvas.requestFocusInWindow();
		//

	}

	public void keyPressed(KeyEvent e) {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_ESCAPE:
			System.exit(0);
			break;

		default:
			break;
		}

	}

	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
	}

	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
	}

}

Sorry about that. There was a bug in GlueGen’s glue code generation for outgoing void** arguments. A fix has been checked in; glMultiDrawElements will be working properly in the nightly builds dated 7/9 and later, and also in the JSR-231 RI.