Port from V2.0rc5 to 2.2.4 breaks glDrawElements

classic Classic list List threaded Threaded
9 messages Options
BIS
Reply | Threaded
Open this post in threaded view
|

Port from V2.0rc5 to 2.2.4 breaks glDrawElements

BIS
This post was updated on .
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 parameter, 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.

Note also the bug description found here - https://jogamp.org/bugzilla/show_bug.cgi?id=789 . Is it possible that glDrawElements was broken when this was fixed?

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 -
Reply | Threaded
Open this post in threaded view
|

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

Xerxes Rånby
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

BIS
Reply | Threaded
Open this post in threaded view
|

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

BIS
Reply | Threaded
Open this post in threaded view
|

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

gouessej
Administrator
BIS, you should have look at the Java documentation of the API:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/
Julien Gouesse | Personal blog | Website
BIS
Reply | Threaded
Open this post in threaded view
|

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

BIS
Thanks for the link. I'm still trying to find the relevant bits of documentation in the V2.4.4 downloads. (I wish you still packaged the relevant javadocs in a separate download package.) Still getting back up to speed, you know.

Thanks again for the link.

Reply | Threaded
Open this post in threaded view
|

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

gouessej
Administrator
There is no version 2.4.4 yet (January 2015). The current version is the 2.2.4. The archive of the Java documentation is here:
http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z
Julien Gouesse | Personal blog | Website
BIS
Reply | Threaded
Open this post in threaded view
|

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

BIS


gouessej wrote
There is no version 2.4.4 yet (January 2015). The current version is the 2.2.4.

Aaargh - typo. It's late. (Got it right in the text, just screwed up the topic title.)

And I have that download, just haven't found the javadocs yet. Still looking.
Reply | Threaded
Open this post in threaded view
|

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

gouessej
Administrator
BIS
Reply | Threaded
Open this post in threaded view
|

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

BIS
Aha!!

Right - that should fill in a few gaps. I had looked for something similar but specific to 2.2.4. Like I said, I'm still getting back up to speed with the site and where to find relevant docs. (And just Java in general. It's been a few years.)

Thanks for your time and help. I appreciate it.