Login  Register

Re: Port from V2.0rc5 to 2.4.4 breaks glDrawElements

Posted by Xerxes Rånby on Jan 15, 2015; 7:11am
URL: https://forum.jogamp.org/Port-from-V2-0rc5-to-2-2-4-breaks-glDrawElements-tp4033854p4033855.html

In your codes for loop try change
CurrentGL.glDrawElements to
CurrentGL2.glDrawElements

GL2 inherit GL2ES1
GL2ES1 implements the fixed function glDrawElements that still work like your code expected.
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2.html
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL2ES1.html#glDrawElements%28int,%20int,%20int,%20java.nio.Buffer%29

2015-01-15 2:45 GMT+01:00 BIS [via jogamp] <[hidden email]>:
Hi, all -


I'm trying to port some old-ish code, previously compiled and used in the field with both JOGL 1.1.1 and 2.0-rc5. (This is from one of the featured apps on the JOGL home page. I'm trying to dust it off and bring it up to date.)

Consider the following snippet -

***********************************
CurrentGL2.glEnableClientState(GL2.GL_VERTEX_ARRAY);
CurrentGL2.glEnableClientState(GL2.GL_NORMAL_ARRAY);
                                                                               
CurrentGL2.glVertexPointer(3, GL2.GL_DOUBLE, 0, VertsBuffer);
CurrentGL2.glNormalPointer(GL2.GL_DOUBLE, 0, NormsBuffer);
                                       

for (int t = 0; t < max; t++)
{

    int index = t * 3;
    IndexBuffer.position(index);

    CurrentGL.glDrawElements(GL.GL_TRIANGLES, 3, GL.GL_UNSIGNED_INT,  IndexBuffer);
}

***********************************

All buffers are rewound at the proper times, etc. - this is pretty unremarkable code, directly ported from working C code. And as I said, it had previously worked with the two above-mentioned versions of JOGL.

So I'm trying to port this to JOGL 2.2.4, and  the call to glDrawElements won't compile. It no longer wants a Buffer passed as the last variable, but a long (an offset into the the buffer).

Here's the Javadoc declaration from V1.1.1 -

**********************************
public void glDrawElements(int mode,
                           int count,
                           int type,
                           Buffer indices)

Interface to C language function:
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);

**********************************

The current javadoc shows the declaration changed to the following -

**********************************
void glDrawElements(int mode,
                  int count,
                  int type,
                  long indices_buffer_offset)

Entry point to C language function:
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices)

*********************************

Note what has happened to the final parameter. Also note how the current version still claims to wrap the same base GL glDrawElements function, which will still want a pointer to the index array as it's 4th parameter.

So what am I missing here? I have been away from the GL scene for a while, but as far as I can tell, the underlying C function hasn't changed, so why has the JOGL wrapper? And what would be a work-around? (This code doesn't use VBO's or any other extension-based GL feature. It's a lowest common denominator app.)

TIA for your time and help -



If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Port-from-V2-0rc5-to-2-4-4-breaks-glDrawElements-tp4033854.html
To start a new topic under jogl, email [hidden email]
To unsubscribe from jogamp, click here.
NAML