提交 ad0ee4d2 编写于 作者: J jp9000

libobs-opengl: Bind index buffers to VAO

To be able to use index buffers, they must also be bound to a vertex
array object along with the vertex buffers.

Ideally, if there are multiple index buffers for a vertex buffer,
separate VAOs should be created for each combination.
上级 8e4fdbbc
......@@ -104,11 +104,5 @@ enum gs_index_type gs_indexbuffer_get_type(const gs_indexbuffer_t *ib)
void device_load_indexbuffer(gs_device_t *device, gs_indexbuffer_t *ib)
{
if (ib == device->cur_index_buffer)
return;
device->cur_index_buffer = ib;
if (!gl_bind_buffer(GL_ELEMENT_ARRAY_BUFFER, ib->buffer))
blog(LOG_ERROR, "device_load_indexbuffer (GL) failed");
}
......@@ -979,7 +979,7 @@ void device_draw(gs_device_t *device, enum gs_draw_mode draw_mode,
if (!program)
goto fail;
load_vb_buffers(program, device->cur_vertex_buffer);
load_vb_buffers(program, device->cur_vertex_buffer, ib);
if (program != device->cur_program && device->cur_program) {
glUseProgram(0);
......
......@@ -377,7 +377,7 @@ struct gs_vertex_buffer {
};
extern bool load_vb_buffers(struct gs_program *program,
struct gs_vertex_buffer *vb);
struct gs_vertex_buffer *vb, struct gs_index_buffer *ib);
struct gs_index_buffer {
GLuint buffer;
......
......@@ -234,7 +234,8 @@ static bool load_vb_buffer(struct shader_attrib *attrib,
return success;
}
bool load_vb_buffers(struct gs_program *program, struct gs_vertex_buffer *vb)
bool load_vb_buffers(struct gs_program *program, struct gs_vertex_buffer *vb,
struct gs_index_buffer *ib)
{
struct gs_shader *shader = program->vertex_shader;
size_t i;
......@@ -248,6 +249,9 @@ bool load_vb_buffers(struct gs_program *program, struct gs_vertex_buffer *vb)
return false;
}
if (ib && !gl_bind_buffer(GL_ELEMENT_ARRAY_BUFFER, ib->buffer))
return false;
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册