Java opengl: glDrawElements () s> 32767 vertices

It should be simple, but I will skip it.

I have a complex model having> 32767 vertices. indexes can now only be passed to opengl as type GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT. java does not have an unsigned concept, so the unsigned short version displays simply (signed) short, which is 16 bits, or +32767. when I specify the vertices, I need to pass opengl short [], where the values ​​in the array point to the vertex in the vertex array. however, if there are> 32767 vertices, the value will not match the short [].

is there any other way to specify indexes? snapshot below, thanks.

    short[] shorts = ... read the 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);
    ...
+3
1

OpenGL Java, , , , , . GL , unsigned, , , . , Java, - , .

, wraparound . -1, .

int ( ), , 65536 , 32767.

+4

Source: https://habr.com/ru/post/1778018/


All Articles