mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2025-02-17 07:30:50 +00:00
Turn draw_indexed__raw into macro
This commit is contained in:
parent
ce0d3adb3a
commit
136937cfb2
@ -477,9 +477,13 @@ static void draw(GlRenderer *renderer)
|
||||
if (opaque_triangle_len)
|
||||
{
|
||||
if (!DRAWBUFFER_IS_EMPTY(renderer->command_buffer))
|
||||
renderer->command_buffer->draw_indexed__raw(GL_TRIANGLES,
|
||||
{
|
||||
DRAW_INDEXED_RAW(
|
||||
renderer->command_buffer->id,
|
||||
GL_TRIANGLES,
|
||||
opaque_triangle_indices,
|
||||
opaque_triangle_len);
|
||||
}
|
||||
}
|
||||
|
||||
GLushort *opaque_line_indices =
|
||||
@ -490,9 +494,13 @@ static void draw(GlRenderer *renderer)
|
||||
if (opaque_line_len)
|
||||
{
|
||||
if (!DRAWBUFFER_IS_EMPTY(renderer->command_buffer))
|
||||
renderer->command_buffer->draw_indexed__raw(GL_LINES,
|
||||
{
|
||||
DRAW_INDEXED_RAW(
|
||||
renderer->command_buffer->id,
|
||||
GL_LINES,
|
||||
opaque_line_indices,
|
||||
opaque_line_len);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderer->semi_transparent_index_pos > 0) {
|
||||
@ -556,9 +564,13 @@ static void draw(GlRenderer *renderer)
|
||||
GLushort *indices = renderer->semi_transparent_indices + cur_index;
|
||||
|
||||
if (!DRAWBUFFER_IS_EMPTY(renderer->command_buffer))
|
||||
renderer->command_buffer->draw_indexed__raw(it->draw_mode,
|
||||
{
|
||||
DRAW_INDEXED_RAW(
|
||||
renderer->command_buffer->id,
|
||||
it->draw_mode,
|
||||
indices,
|
||||
len);
|
||||
}
|
||||
|
||||
cur_index = it->last_index;
|
||||
}
|
||||
|
@ -17,7 +17,15 @@
|
||||
#define DRAWBUFFER_IS_EMPTY(x) ((x)->map_index == 0)
|
||||
#define DRAWBUFFER_REMAINING_CAPACITY(x) ((x)->capacity - (x)->map_index)
|
||||
#define DRAWBUFFER_NEXT_INDEX(x) ((x)->map_start + (x)->map_index)
|
||||
#define DRAWBUFFER_BIND(x) (glBindBuffer(GL_ARRAY_BUFFER, (x)->id))
|
||||
#define DRAWBUFFER_BIND(x) (glBindBuffer(GL_ARRAY_BUFFER, (x)))
|
||||
/// This method doesn't call prepare_draw/finalize_draw itself, it
|
||||
/// must be handled by the caller. This is because this command
|
||||
/// can be called several times on the same buffer (i.e. multiple
|
||||
/// draw calls between the prepare/finalize)
|
||||
#define DRAW_INDEXED_RAW(id, mode, indices, count) \
|
||||
DRAWBUFFER_BIND(id); \
|
||||
glDrawElements(mode, count, GL_UNSIGNED_SHORT, indices)
|
||||
|
||||
|
||||
template<typename T>
|
||||
class DrawBuffer
|
||||
@ -60,7 +68,7 @@ public:
|
||||
this->id = id;
|
||||
|
||||
// Create and map the buffer
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(id);
|
||||
|
||||
size_t element_size = sizeof(T);
|
||||
// We allocate enough space for 3 times the buffer space and
|
||||
@ -83,7 +91,7 @@ public:
|
||||
|
||||
~DrawBuffer()
|
||||
{
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(this->id);
|
||||
|
||||
this->unmap__no_bind();
|
||||
|
||||
@ -110,7 +118,7 @@ public:
|
||||
VertexArrayObject_bind(this->vao);
|
||||
|
||||
// ARRAY_BUFFER is captured by VertexAttribPointer
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(this->id);
|
||||
|
||||
std::vector<Attribute> attrs = T::attributes();
|
||||
|
||||
@ -184,7 +192,7 @@ public:
|
||||
GLintptr offset_bytes;
|
||||
void *m;
|
||||
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(this->id);
|
||||
|
||||
// If we're already mapped something's wrong
|
||||
assert(this->map == NULL);
|
||||
@ -220,7 +228,7 @@ public:
|
||||
{
|
||||
assert(this->map != NULL);
|
||||
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(this->id);
|
||||
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
|
||||
@ -271,7 +279,7 @@ public:
|
||||
|
||||
// I don't need to bind this to draw (it's captured by the
|
||||
// VAO) but I need it to map/unmap the storage.
|
||||
DRAWBUFFER_BIND(this);
|
||||
DRAWBUFFER_BIND(this->id);
|
||||
|
||||
this->unmap__no_bind();
|
||||
}
|
||||
@ -297,16 +305,6 @@ public:
|
||||
this->finalize_draw__no_bind();
|
||||
}
|
||||
|
||||
/// This method doesn't call prepare_draw/finalize_draw itself, it
|
||||
/// must be handled by the caller. This is because this command
|
||||
/// can be called several times on the same buffer (i.e. multiple
|
||||
/// draw calls between the prepare/finalize)
|
||||
void draw_indexed__raw(GLenum mode, GLushort *indices, GLsizei count)
|
||||
{
|
||||
DRAWBUFFER_BIND(this);
|
||||
glDrawElements(mode, count, GL_UNSIGNED_SHORT, indices);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user