Use a non-hardcoded values for mat4 array (max 1024)
Also cull mesh that doesn't have enough space to be rendered
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "graphics/central_settings.hpp"
|
||||
|
||||
#include "matrix4.h"
|
||||
#include <algorithm>
|
||||
|
||||
GLuint SharedGPUObjects::m_billboard_vbo;
|
||||
GLuint SharedGPUObjects::m_sky_tri_vbo;
|
||||
@@ -34,6 +35,7 @@ GLuint SharedGPUObjects::m_ui_vao;
|
||||
GLuint SharedGPUObjects::m_quad_buffer;
|
||||
GLuint SharedGPUObjects::m_quad_vbo;
|
||||
GLuint SharedGPUObjects::m_skinning_ubo;
|
||||
int SharedGPUObjects::m_max_mat4_size = 1024;
|
||||
bool SharedGPUObjects::m_has_been_initialised = false;
|
||||
|
||||
/** Initialises m_full_screen_quad_vbo.
|
||||
@@ -178,8 +180,11 @@ void SharedGPUObjects::initSkinningUBO()
|
||||
irr::core::matrix4 m;
|
||||
glGenBuffers(1, &m_skinning_ubo);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, m_skinning_ubo);
|
||||
glBufferData(GL_UNIFORM_BUFFER, 1000 * 16 * sizeof(float), 0,
|
||||
GL_STREAM_DRAW);
|
||||
int max_size = 0;
|
||||
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_size);
|
||||
max_size = std::min(max_size, 65536);
|
||||
m_max_mat4_size = max_size / 16 / sizeof(float);
|
||||
glBufferData(GL_UNIFORM_BUFFER, max_size, 0, GL_STREAM_DRAW);
|
||||
// Reserve a identity matrix for non moving mesh in animated model used by
|
||||
// vertex shader calculation
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, 16 * sizeof(float), m.pointer());
|
||||
|
||||
Reference in New Issue
Block a user