0

我正在尝试使实例化渲染正常工作,但我似乎找不到 glBufferSubData 给我 1281 异常(无效值)的原因。

这是我的代码:

FloatBuffer square_vertices_fb = BufferUtils.createFloatBuffer(16);
     square_vertices_fb.put(square_vertices);
     square_vertices_fb.rewind();

     FloatBuffer instance_colors_fb = BufferUtils.createFloatBuffer(instance_colors.length);
     instance_colors_fb.put(instance_colors);
     instance_colors_fb.rewind();

     FloatBuffer instance_positions_fb = BufferUtils.createFloatBuffer(instance_positions.length);
     instance_positions_fb.put(instance_positions);
     instance_positions_fb.rewind();
    glBufferData(GL_ARRAY_BUFFER, square_vertices.length + instance_colors.length + instance_positions.length, GL_STATIC_DRAW);
    System.out.println(Integer.toString(glGetError()));
    glBufferSubData(GL_ARRAY_BUFFER, 0, square_vertices_fb);
    System.out.println(Integer.toString(glGetError()));
    glBufferSubData(GL_ARRAY_BUFFER, square_vertices.length, instance_colors_fb);
    glBufferSubData(GL_ARRAY_BUFFER, square_vertices.length + instance_colors.length, instance_positions_fb);

我在第一次错误检查时得到 0(无错误),但在第一个 glBufferSubData 之后出现 1281 错误。

关于这里有什么问题的任何想法?

4

1 回答 1

0

好的,我发现 LWJGL 的 glBufferSubData 需要以字节为单位的偏移量。问题已解决。

于 2012-12-19T16:47:48.897 回答