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.
This commit is contained in:
parent
8e4fdbbc20
commit
ad0ee4d2d8
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user