java - SIGSEGV when enabling attribute -


i trying render object in android app. geometry based on interleaved vertex buffer (position data , normal data) , index buffer.

the vertex shader expects 2 attributes:

vertexshader:

... attribute vec3 vposition; attribute vec3 vnormal; ... 

on java side:

//after compiling shader positionhandle = gles20.glgetattriblocation(effect, "vposition"); normalhandle = gles20.glgetattriblocation(effect, "vnormal"); 

i draw geometry with:

gles20.gluseprogram(effect); gles20.glenablevertexattribarray(positionhandle); gles20.glenablevertexattribarray(normalhandle);  final int stride = 24; gles20.glbindbuffer(gles20.gl_array_buffer, vertexbuffer); gles20.glvertexattribpointer(positionhandle, 3, gles20.gl_float, false, stride, 0); gles20.glvertexattribpointer(normalhandle, 3, gles20.gl_float, false, stride, 12);  gles20.gldrawelements(gles20.gl_triangles, indexcount,      gles20.gl_unsigned_short, indexbuffer); 

however, results in

a/libc(1010): fatal signal 11 (sigsegv) @ 0x00000002 (code=1), thread 1024 (thread-81)

if remove call glenablevertexattribarray(normalhandle), renders (although black due missing normals). normalhandle variable assigned value of 1.

i have tested on emulator because don't have physical device right now.

is wrong above code? or can error caused emulator , app should run on physical device?

copied previous comment:

the line

gles20.gldrawelements(gles20.gl_triangles, indexcount, gles20.gl_unsigned_short, indexbuffer); 

looks bit suspicious me, last parameter supposed byte offset bound element_array_buffer, variable names suggest passing buffer handle. if so, have kind of weird effects.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -