LWJGL
May 25, 2013, 01:46:23 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: JVMcrash with glDrawElements  (Read 925 times)
g4m0r
Newbie
*
Posts: 6


« on: May 01, 2012, 00:53:54 »

Hi,

I have a problem.
I have a VertexArray with glDrawElements.
If I render vertexes only, it works.

But when I also want to render the normals or texture coordinates the JVM crashes.
What's wrong?

here the render():
                 GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       GL11.glTexCoordPointer(2, 0, tex_cords);
      
       GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
       GL11.glVertexPointer(3, 0, vertex);


                       GL11.glDrawElements(GL11.GL_QUADS, vert_ind);
          
       GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
       GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

      
Logged
Fool Running
Nerdus Imperius
*****
Posts: 742


« Reply #1 on: May 01, 2012, 06:14:56 »

A couple things I would check:
Make sure you did a flip() on the buffers.
Make sure there are enough bytes in the texture/normal buffers for the number of vertexes you have.
Make sure your vert_ind buffer doesn't attempt to access a vertex index that doesn't exist.
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
g4m0r
Newbie
*
Posts: 6


« Reply #2 on: May 01, 2012, 08:59:01 »

Hi,

thx.
Is that the problem:
I just increment a integer for every Vector.x, Vector.y, Vector.z on the entire Mesh for INDEX  (vert_ind)

And now for example I have normals with only 1 Vector for a QUAD, but vert_ind have for every quad 12
(4 vertices with 3 floats(=Vector) ) indeces.
Must I do a new indexBuffer for the normals?
Logged
Fool Running
Nerdus Imperius
*****
Posts: 742


« Reply #3 on: May 02, 2012, 05:32:33 »

When using glDrawElements() with normals and texture coordinates, you must have a normal and a texture coordinate for each vertex. You can't have one normal that is used for 4 vertexes. If you need to have 4 vertexes that all have the same normal, you need to duplicate the normal 4 times in your normal buffer.
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!