Hi,
I have a set of buffers as arrays so I can have multiple objects in my scene. I tried making multiple calls with drawelements in a loop but all I get is a black screen that flashes. Do you know what I'm doing wrong or if there is a better way of loading multiple objects in a scene? |
Administrator
|
Hey
It's difficult to guess without looking at your source code. Do you use VBOs? Do you bind them correctly? Maybe this example can help: https://sourceforge.net/p/tuer/code/HEAD/tree/alpha/drawer/StaticVertexBufferObject.java#l64
Julien Gouesse | Personal blog | Website
|
public class CubeObject extends WSObject implements IThreeDimensionalObject {
@Override public void Render() { // TODO Auto-generated method stub } ShortBuffer cubeVertices; static ShortBuffer cubeTexCoords; static FloatBuffer cubeColors; static ByteBuffer cubeNormals; static ByteBuffer cubeIndices; static float[] light_position = { -50.f, 50.f, 50.f, 0.f }; static float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f }; static float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f }; static float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f }; static float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f }; public CubeObject() { this.cubeVertices = Buffers.newDirectShortBuffer(s_cubeVertices.length); cubeVertices.put(s_cubeVertices); cubeVertices.flip(); this.cubeColors = Buffers.newDirectFloatBuffer(s_cubeColors.length); cubeColors.put(s_cubeColors); cubeColors.flip(); this.cubeNormals = Buffers.newDirectByteBuffer(s_cubeNormals.length); cubeNormals.put(s_cubeNormals); cubeNormals.flip(); this.cubeIndices = Buffers.newDirectByteBuffer(s_cubeIndices.length); cubeIndices.put(s_cubeIndices); cubeIndices.flip(); this.cubeTexCoords = Buffers.newDirectShortBuffer(s_cubeTexCoords.length); cubeTexCoords.put(s_cubeTexCoords); cubeTexCoords.flip(); } public static short[] s_cubeVertices = { -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10, 10, -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10, -10, -10, -10, 10, 10, -10, -10, 10, -10, 10, -10, -10, -10, -10, 10, 10, 10, 10, -10, 10, 10, 10, -10, 10, -10, 10, -10, 10, 10, 10, -10, 10, 10, 10, 10, -10, -10, -10, -10, 10, -10, 10, -10, -10, 10, 10, -10, -10, -10 }; public static short[] s_cubeTexCoords = { 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, 0, (short) 0xffff, (short) 0xffff, 0, (short) 0xffff, (short) 0xffff, 0, 0, }; public static float[] s_cubeColors = { 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255 }; public byte[] s_cubeIndices = { 0, 3, 1, 2, 0, 1, /* front */ 6, 5, 4, 5, 7, 4, /* back */ 8, 11, 9, 10, 8, 9, /* top */ 15, 12, 13, 12, 14, 13, /* bottom */ 16, 19, 17, 18, 16, 17, /* right */ 23, 20, 21, 20, 22, 21 /* left */ }; public static byte[] s_cubeNormals = { 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0, -128, 0, 0 }; } |
import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.ShortBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.FPSCounter; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES1; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLPipelineFactory; import com.jogamp.opengl.glu.GLU; import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; public class Renderer implements GLEventListener{ int maxvbonumbers = 20; int[] vboNames = new int[maxvbonumbers]; boolean innerCube; boolean initialized = false; float time = 0.0f; static int bufferCount = 0; static int maxBuffers = 10; ShortBuffer [] cubeVertices = new ShortBuffer[maxBuffers]; ShortBuffer [] cubeTexCoords = new ShortBuffer[maxBuffers]; FloatBuffer [] cubeColors = new FloatBuffer[maxBuffers]; ByteBuffer [] cubeNormals = new ByteBuffer[maxBuffers]; ByteBuffer [] cubeIndices = new ByteBuffer[maxBuffers]; private GLU glu; public boolean glDebug = false; public boolean glTrace = false; boolean quit = false; static float[] light_position = { -50.f, 50.f, 50.f, 0.f }; static float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f }; static float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f }; static float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f }; static float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f }; // private static short[] s_cubeVertices = null; // // // private static short[] s_cubeTexCoords = null; // // // // private static float[] s_cubeColors = null; // // // // private static byte[] s_cubeIndices= null; // // private static byte[] s_cubeNormals = null; // static GL2ES1 gl = null; static float aspect; public void pushData(CubeObject cubeObject, CubeObject2 cubeObject2) { if(!innerCube) { System.err.println("Entering initialization"); System.err.println("GL Profile: "+gl.getGLProfile()); System.err.println("GL:" + gl); System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION)); System.err.println("GL_EXTENSIONS:"); System.err.println(" " + gl.glGetString(gl.GL_EXTENSIONS)); System.err.println("GLF:" + gl); light_position = cubeObject.light_position; light_ambient = cubeObject.light_ambient; light_diffuse = cubeObject.light_diffuse; material_spec = cubeObject.material_spec; zero_vec4 = cubeObject.zero_vec4; cubeVertices[bufferCount] = cubeObject.cubeVertices; cubeTexCoords[bufferCount] = cubeObject.cubeTexCoords; cubeColors[bufferCount] = cubeObject.cubeColors; cubeNormals[bufferCount] = cubeObject.cubeNormals; cubeIndices[bufferCount] =cubeObject.cubeIndices; bufferCount++; cubeVertices[bufferCount] = cubeObject2.cubeVertices; cubeTexCoords[bufferCount] = cubeObject2.cubeTexCoords; cubeColors[bufferCount] = cubeObject2.cubeColors; cubeNormals[bufferCount] = cubeObject2.cubeNormals; cubeIndices[bufferCount] =cubeObject2.cubeIndices; bufferCount++; } } //bind data public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { aspect = (height != 0) ? ((float)width / (float)height) : 1.0f; gl = drawable.getGL().getGL2ES1(); gl.glViewport(0, 0, width, height); gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); // JAU gl.glScissor(0, 0, width, height); if(innerCube) { // Clear background to white gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); } else { // Clear background to blue gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f); } if(!innerCube) { gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, light_position, 0); gl.glLightfv(gl.GL_LIGHT0, gl.GL_AMBIENT, light_ambient, 0); gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, light_diffuse, 0); gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, zero_vec4, 0); gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, material_spec, 0); gl.glEnable(gl.GL_LIGHTING); gl.glEnable(gl.GL_LIGHT0); gl.glEnable(gl.GL_COLOR_MATERIAL); } else { gl.glDisable(gl.GL_LIGHTING); gl.glDisable(gl.GL_LIGHT0); } gl.glEnable(gl.GL_CULL_FACE); gl.glEnable(gl.GL_NORMALIZE); buffers(); } public void buffers() { int vbonums = 0; for (int i=0;i<bufferCount;i++) { gl.glEnableClientState(gl.GL_VERTEX_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeVertices[i].limit() * Buffers.SIZEOF_SHORT, cubeVertices[i], GL.GL_STATIC_DRAW); gl.glVertexPointer(3, gl.GL_SHORT, 0, 0); vbonums++; gl.glEnableClientState(gl.GL_NORMAL_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeNormals[i].limit() * Buffers.SIZEOF_BYTE, cubeNormals[i], GL.GL_STATIC_DRAW); gl.glNormalPointer(gl.GL_BYTE, 0, 0); vbonums++; gl.glEnableClientState(gl.GL_COLOR_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeColors[i].limit() * Buffers.SIZEOF_FLOAT, cubeColors[i], GL.GL_STATIC_DRAW); gl.glColorPointer(4, gl.GL_FLOAT, 0, 0); vbonums++; if (cubeTexCoords != null) { gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL.GL_ARRAY_BUFFER, cubeTexCoords[i].limit() * Buffers.SIZEOF_SHORT, cubeTexCoords[i], GL.GL_STATIC_DRAW); gl.glTexCoordPointer(2, gl.GL_SHORT, 0, 0); /* issues an GL_INVALID_ENUM gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_INCR); } */ vbonums++; } else { gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY); } gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_FASTEST); gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); if(!innerCube) { glu.gluPerspective(90.0f, aspect, 1.0f, 100.0f); } else { gl.glOrthof(-20.0f, 20.0f, -20.0f, 20.0f, 1.0f, 40.0f); } // weird effect ..: gl.glCullFace(gl.GL_FRONT); } } public Renderer (boolean useTexCoords, boolean innerCube) { // Initialize data Buffers // store data /* this.cubeVertices = Buffers.newDirectShortBuffer(s_cubeVertices.length); cubeVertices.put(s_cubeVertices); cubeVertices.flip(); this.cubeColors = Buffers.newDirectFloatBuffer(s_cubeColors.length); cubeColors.put(s_cubeColors); cubeColors.flip(); this.cubeNormals = Buffers.newDirectByteBuffer(s_cubeNormals.length); cubeNormals.put(s_cubeNormals); cubeNormals.flip(); this.cubeIndices = Buffers.newDirectByteBuffer(s_cubeIndices.length); cubeIndices.put(s_cubeIndices); cubeIndices.flip(); if (useTexCoords) { this.cubeTexCoords = Buffers.newDirectShortBuffer(s_cubeTexCoords.length); cubeTexCoords.put(s_cubeTexCoords); cubeTexCoords.flip(); } */ } public void init(GLAutoDrawable drawable) { //initialize gl flags GL _gl = drawable.getGL(); _gl.glGetError(); // flush error .. if(glDebug) { try { _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Debug", null, _gl, null) ); } catch (Exception e) {e.printStackTrace();} } if(glTrace) { try { _gl = _gl.getContext().setGL( GLPipelineFactory.create("com.jogamp.opengl.Trace", null, _gl, new Object[] { System.err } ) ); } catch (Exception e) {e.printStackTrace();} } gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null); gl.glGenBuffers(maxvbonumbers, vboNames, 0); glu = GLU.createGLU(); CubeObject cubeObject = new CubeObject(); CubeObject2 cubeObject2 = new CubeObject2(); pushData(cubeObject, cubeObject2); } public void dispose(GLAutoDrawable drawable) { quit = true; } public void display(GLAutoDrawable drawable) { display(drawable, true); } public void display(GLAutoDrawable drawable, boolean clear) { //GL2ES1// gl = drawable.getGL().getGL2ES1(); if (clear) { gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); } gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.f, 0.f, -30.f); gl.glRotatef((float) (time * 29.77f), 1.0f, 2.0f, 0.0f); gl.glRotatef((float) (time * 22.311f), -0.1f, 0.0f, -5.0f); for (int i=0;i<bufferCount;i++) { gl.glDrawElements(gl.GL_TRIANGLES, 6 * 6, gl.GL_UNSIGNED_BYTE, cubeIndices[i]); } time += 0.01f; } public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { } private void run(int type) { int width = 800; int height = 480; System.err.println("Cube.run()"); try { GLCapabilities caps = new GLCapabilities(null); // For emulation library, use 16 bpp caps.setRedBits(5); caps.setGreenBits(6); caps.setBlueBits(5); caps.setDepthBits(16); Window nWindow = null; GLWindow window; if (0 != (type & USE_AWT)) { Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0 nWindow = NewtFactory.createWindow(nScreen, caps); nWindow.setUndecorated(false); window = GLWindow.create(nWindow); } else { window = GLWindow.create(caps); } window.addGLEventListener(this); window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // Size OpenGL to Video Surface window.setSize(width, height); window.setFullscreen(true); window.setVisible(true); while (!quit && window.getTotalFPSDuration() < 31000) { window.display(); } // Shut things down cooperatively window.destroy(); System.out.println("Cube shut down cleanly."); } catch (Throwable t) { t.printStackTrace(); } } public static int USE_NEWT = 0; public static int USE_AWT = 1 << 0; public static void main(String[] args) { int type = USE_NEWT; for (int i = args.length - 1; i >= 0; i--) { if (args[i].equals("-awt")) { type |= USE_AWT; } } new Renderer(true, true).run(type); System.exit(0); } } |
Does that help?
|
Administrator
|
Yes. I was right, call glBindBuffer before each call of glDrawElements. You seem to use the latest bound VBO.
Julien Gouesse | Personal blog | Website
|
How do I go about calling bindbuffers?
I have two sets of buffers, one for one model one for the other as you saw in my code. So do I call bind buffers on all four before I do drawelements or just one of them? For the first call to drawELements: gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[i]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[I+1]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[I + 2]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[I+3]); For the second call to drawElements: gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[ii+4]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[I+5]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[I+6]); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboNames[i]+7); ? |
Administrator
|
You have to use GL_ELEMENT_ARRAY_BUFFER for the indices (instead of GL_ARRAY_BUFFER).
Julien Gouesse | Personal blog | Website
|
When I change the buffers to GL_ELEMENT_ARRAY_BUFFER I get the following cryptic exception:
java.lang.RuntimeException: com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread main-Display-.windows_nil-1-EDT-1 at jogamp.newt.DefaultEDTUtil.invokeImpl(DefaultEDTUtil.java:252) at jogamp.newt.DefaultEDTUtil.invoke(DefaultEDTUtil.java:165) at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:442) at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2782) at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1330) at jogamp.newt.WindowImpl.setVisible(WindowImpl.java:1335) at com.jogamp.newt.opengl.GLWindow.setVisible(GLWindow.java:578) at RenderEngine.Renderer.run(Renderer.java:527) at RenderEngine.Renderer.main(Renderer.java:569) Caused by: com.jogamp.opengl.GLException: Caught GLException: array vertex_buffer_object must be bound to call this method on thread main-Display-.windows_nil-1-EDT-1 at com.jogamp.opengl.GLException.newGLException(GLException.java:76) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1327) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:260) at com.jogamp.newt.opengl.GLWindow.access$200(GLWindow.java:119) at com.jogamp.newt.opengl.GLWindow$2.windowResized(GLWindow.java:141) at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:4383) at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:4317) at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:1306) at jogamp.newt.WindowImpl$VisibleAction.run(WindowImpl.java:1318) at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:145) at jogamp.newt.DefaultEDTUtil$NEDT.run(DefaultEDTUtil.java:375) Caused by: com.jogamp.opengl.GLException: array vertex_buffer_object must be bound to call this method at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:40621) at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOBound(GL4bcImpl.java:40653) at jogamp.opengl.gl4.GL4bcImpl.glVertexPointer(GL4bcImpl.java:6362) at RenderEngine.Renderer.buffers(Renderer.java:227) at RenderEngine.Renderer.reshape(Renderer.java:210) at jogamp.opengl.GLDrawableHelper.reshape(GLDrawableHelper.java:751) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:440) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293) ... 11 more |
Administrator
|
You must use GL_ELEMENT_ARRAY_BUFFER only for the indices, not for the rest (colors, texture coordinates, ...). The message isn't cryptic, you call glVertexPointer with no VBO bound to the expected target.
Julien Gouesse | Personal blog | Website
|
So you use glVertexPointer on the indices as well?
Like there is gl.glNormalPointer(gl.GL_BYTE, 0, 0);, and gl.glColorPointer(4, gl.GL_FLOAT, 0, 0); but there is no gl.glIndexPointer for the indices. So am I to use glVertexPointer? |
Administrator
|
I checked the API and I didn't find anything for GL_INDEX_ARRAY like ther eis for GL_NORMAL_ARRAY
gl.glEnableClientState(gl.GL_NORMAL_ARRAY); gl.glBindBuffer(GL. GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL. GL_ARRAY_BUFFER, cubeNormals[i].limit() * Buffers.SIZEOF_BYTE, cubeNormals[i], GL.GL_STATIC_DRAW); gl.glNormalPointer(gl.GL_BYTE, 0, 0); //Indices vbonums++; // cubeIndices[bufferCount] =cubeObject2.cubeIndices; gl.glEnableClientState(gl.GL_ARRAY_BUFFER_BINDING); gl.glBindBuffer(GL. GL_ARRAY_BUFFER, vboNames[vbonums]); gl.glBufferData(GL. GL_ARRAY_BUFFER, cubeIndices[i].limit() * Buffers.SIZEOF_BYTE, cubeIndices[i], GL.GL_STATIC_DRAW); gl.glNormalPointer(gl.GL_BYTE, 0, 0); vbonums++; |
Administrator
|
Ok, there's another solution that gmseed (another JOGL user) used some years ago. You can simply call glBufferData with GL_ELEMENT_ARRAY_BUFFER and your direct NIO buffer containing the indices and call glDrawElements with the indices count:
https://www.opengl.org/discussion_boards/showthread.php/176377-VBOs-and-glDrawElements%28%29-with-JOGL?p=1231350&viewfull=1#post1231350 This solution works, I remember that gmseed contributed to JogAmp's Ardor3D Continuation, I provided the very first blueprint of our STL importer. If it still doesn't work, I'll look at my own source code again as I use indices elsewhere with VBOs.
Julien Gouesse | Personal blog | Website
|
What is an NIO buffer?
|
Administrator
|
A NIO buffer is typically an instance of this class. A direct NIO buffer is a buffer whose content resides (most of the type) outside of the Java heap in the native heap.
You can create NIO buffers to use with JOGL by using this class. I advise you to read my post about deallocating direct NIO buffer native memory. By the way, if you pass an indirect NIO buffer to JOGL, it will have to build a direct one anyway, it's not a good idea.
Julien Gouesse | Personal blog | Website
|
Ok so the intellisense still isn't bringing up IndexPointer. See below:
|
Administrator
|
You no longer need glIndexPointer if you follow gmseed's example.
Julien Gouesse | Personal blog | Website
|
I read over the links that you posted. I don't quite understand them fully. which post is gmseed's
??? |
Administrator
|
Free forum by Nabble | Edit this page |