glBufferSubData 1281错误

时间:2012-12-19 15:41:05

标签: java debugging opengl lwjgl

我正在尝试使实例渲染工作,但我似乎无法找到我的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错误。

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

1 个答案:

答案 0 :(得分:0)

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