android - java opengl: glDrawElements() with >32767 vertices -


this must simple, i'm missing it.

i have complex model has >32767 vertices. now, indices can passed opengl type gl_unsigned_byte or gl_unsigned_short. java has no concept of unsigned, unsigned short option maps (signed) short, 16 bits, or +32767. when specify vertices, need pass opengl short[], values in array point vertex in vertice array. however, if there >32767 vertices, value won't fit in short[].

is there way specify indices? code snippet below, thanks.

    short[] shorts = ... read indices ...;     ...     shortbuffer indicesbuffer = null;     bytebuffer ibb = bytebuffer.allocatedirect(indices.length * short.size / 8);     ibb.order(byteorder.nativeorder());     indicesbuffer = ibb.asshortbuffer();     indicesbuffer.put(indices);     indicesbuffer.position(0);     ...     gl.gldrawelements(gl10.gl_triangles, numofindices, gl10.gl_unsigned_short, indicesbuffer);     ... 

i haven't used opengl java i'm speculating here, there's chance can use negative numbers binary reprentation same unsigned positive numbers want. you're giving gl byte pairs , telling interpret them unsigned, , long have right value when interpreted way, should work. doesn't matter if java thought meant different when stored bits in memory.

if you're iterating, ignore wraparound , keep on incrementing. when -1, you're done.

if you're calculating index numbers ints (which don't have range problem) , casting short, subtract 65536 number that's greater 32767.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -