Refactoring of streamer code to integrate texture and vbo memory management in progress.
--HG-- branch : nfb
This commit is contained in:
@@ -321,7 +321,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
|||||||
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
|||||||
|
|
||||||
KRShader *pVisShader = getContext().getShaderManager()->getShader("visualize_overlay", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *pVisShader = getContext().getShaderManager()->getShader("visualize_overlay", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_3D_CUBE_VERTICES);
|
||||||
for(unordered_map<KRAABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
|
for(unordered_map<KRAABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
|
||||||
KRMat4 matModel = KRMat4();
|
KRMat4 matModel = KRMat4();
|
||||||
matModel.scale((*itr).first.size() * 0.5f);
|
matModel.scale((*itr).first.size() * 0.5f);
|
||||||
@@ -716,7 +716,7 @@ void KRCamera::renderPost()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update attribute values.
|
// Update attribute values.
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
|
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
|
|
||||||
@@ -738,7 +738,7 @@ void KRCamera::renderPost()
|
|||||||
// viewMatrix.translate(-0.70, 0.70 - 0.45 * iShadow, 0.0);
|
// viewMatrix.translate(-0.70, 0.70 - 0.45 * iShadow, 0.0);
|
||||||
// getContext().getShaderManager()->selectShader(blitShader, KRViewport(getViewportSize(), viewMatrix, KRMat4()), shadowViewports, KRMat4(), KRVector3(), NULL, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
// getContext().getShaderManager()->selectShader(blitShader, KRViewport(getViewportSize(), viewMatrix, KRMat4()), shadowViewports, KRMat4(), KRVector3(), NULL, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
// m_pContext->getTextureManager()->selectTexture(1, NULL);
|
// m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
// m_pContext->getMeshManager()->bindVBO(KRENGINE_VBO_2D_SQUARE_INDICES, KRENGINE_VBO_2D_SQUARE_VERTEXES, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
// m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
// m_pContext->getTextureManager()->_setActiveTexture(0);
|
// m_pContext->getTextureManager()->_setActiveTexture(0);
|
||||||
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]));
|
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]));
|
||||||
//#if GL_EXT_shadow_samplers
|
//#if GL_EXT_shadow_samplers
|
||||||
@@ -907,7 +907,6 @@ void KRCamera::renderPost()
|
|||||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
||||||
|
|
||||||
KRDataBlock index_data;
|
KRDataBlock index_data;
|
||||||
//m_pContext->getMeshManager()->bindVBO((void *)m_debug_text_vertices, vertex_count * sizeof(DebugTextVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
|
||||||
m_pContext->getMeshManager()->bindVBO(m_debug_text_vertices, index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
m_pContext->getMeshManager()->bindVBO(m_debug_text_vertices, index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
||||||
|
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, vertex_count));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, vertex_count));
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &
|
|||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,7 +342,6 @@ void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const st
|
|||||||
}
|
}
|
||||||
vbo_index++;
|
vbo_index++;
|
||||||
|
|
||||||
//m_pContext->getMeshManager()->bindVBO((unsigned char *)pVertexData + start_vertex_offset * m_vertex_size, vertex_count * m_vertex_size, index_data + start_index_offset, index_count * 2, vertex_attrib_flags, true);
|
|
||||||
m_pContext->getMeshManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
m_pContext->getMeshManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
||||||
|
|
||||||
|
|
||||||
@@ -375,7 +374,6 @@ void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const st
|
|||||||
}
|
}
|
||||||
vbo_index++;
|
vbo_index++;
|
||||||
|
|
||||||
//m_pContext->getMeshManager()->bindVBO((unsigned char *)pVertexData + iBuffer * MAX_VBO_SIZE * vertex_size, vertex_size * cBufferVertexes, NULL, 0, vertex_attrib_flags, true);
|
|
||||||
m_pContext->getMeshManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
m_pContext->getMeshManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public:
|
|||||||
virtual bool save(const std::string& path);
|
virtual bool save(const std::string& path);
|
||||||
virtual bool save(KRDataBlock &data);
|
virtual bool save(KRDataBlock &data);
|
||||||
|
|
||||||
void LoadData(/*std::vector<__uint16_t> vertex_indexes, std::vector<std::pair<int, int> > vertex_index_bases, std::vector<KRVector3> vertices, std::vector<KRVector2> uva, std::vector<KRVector2> uvb, std::vector<KRVector3> normals, std::vector<KRVector3> tangents, std::vector<int> submesh_starts, std::vector<int> submesh_lengths, std::vector<std::string> material_names, std::vector<std::string> bone_names, std::vector<KRMat4> bone_bind_poses, std::vector<std::vector<int> > bone_indexes, std::vector<std::vector<float> > bone_weights, model_format_t model_format, */const mesh_info &mi, bool calculate_normals, bool calculate_tangents);
|
void LoadData(const mesh_info &mi, bool calculate_normals, bool calculate_tangents);
|
||||||
void loadPack(KRDataBlock *data);
|
void loadPack(KRDataBlock *data);
|
||||||
|
|
||||||
void convertToIndexed();
|
void convertToIndexed();
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ KRMeshManager::KRMeshManager(KRContext &context) : KRContextObject(context) {
|
|||||||
memcpy(KRENGINE_VBO_3D_CUBE_VERTICES.getStart(), _KRENGINE_VBO_3D_CUBE_VERTEX_DATA, sizeof(GLfloat) * 3 * 14);
|
memcpy(KRENGINE_VBO_3D_CUBE_VERTICES.getStart(), _KRENGINE_VBO_3D_CUBE_VERTEX_DATA, sizeof(GLfloat) * 3 * 14);
|
||||||
KRENGINE_VBO_3D_CUBE_VERTICES.unlock();
|
KRENGINE_VBO_3D_CUBE_VERTICES.unlock();
|
||||||
|
|
||||||
|
KRENGINE_VBO_DATA_3D_CUBE_VERTICES.init(KRENGINE_VBO_3D_CUBE_VERTICES, KRENGINE_VBO_3D_CUBE_INDEXES, KRENGINE_VBO_3D_CUBE_ATTRIBS, false, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const GLfloat _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA[] = {
|
static const GLfloat _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA[] = {
|
||||||
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
@@ -87,6 +91,9 @@ KRMeshManager::KRMeshManager(KRContext &context) : KRContextObject(context) {
|
|||||||
KRENGINE_VBO_2D_SQUARE_VERTICES.lock();
|
KRENGINE_VBO_2D_SQUARE_VERTICES.lock();
|
||||||
memcpy(KRENGINE_VBO_2D_SQUARE_VERTICES.getStart(), _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA, sizeof(GLfloat) * 5 * 4);
|
memcpy(KRENGINE_VBO_2D_SQUARE_VERTICES.getStart(), _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA, sizeof(GLfloat) * 5 * 4);
|
||||||
KRENGINE_VBO_2D_SQUARE_VERTICES.unlock();
|
KRENGINE_VBO_2D_SQUARE_VERTICES.unlock();
|
||||||
|
|
||||||
|
KRENGINE_VBO_DATA_2D_SQUARE_VERTICES.init(KRENGINE_VBO_2D_SQUARE_VERTICES, KRENGINE_VBO_2D_SQUARE_INDEXES, KRENGINE_VBO_2D_SQUARE_ATTRIBS, false, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMeshManager::~KRMeshManager() {
|
KRMeshManager::~KRMeshManager() {
|
||||||
@@ -167,35 +174,37 @@ void KRMeshManager::releaseVBO(KRDataBlock &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(vbo_to_release) {
|
if(vbo_to_release) {
|
||||||
m_vboMemUsed -= vbo_to_release->m_size;
|
m_vboMemUsed -= vbo_to_release->getSize();
|
||||||
|
|
||||||
vbo_to_release->unload();
|
vbo_to_release->unload();
|
||||||
delete vbo_to_release;
|
if(vbo_to_release->isTemporary()) {
|
||||||
|
delete vbo_to_release;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRMeshManager::bindVBO(KRVBOData *vbo_data)
|
||||||
|
|
||||||
void KRMeshManager::bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo)
|
|
||||||
{
|
{
|
||||||
bool vbo_changed = false;
|
bool vbo_changed = false;
|
||||||
if(m_currentVBO == NULL) {
|
if(m_currentVBO == NULL) {
|
||||||
vbo_changed = true;
|
vbo_changed = true;
|
||||||
} else if(m_currentVBO->m_data != &data) {
|
} else if(m_currentVBO->m_data != vbo_data->m_data) {
|
||||||
vbo_changed = true;
|
vbo_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool used_vbo_data = false;
|
||||||
|
|
||||||
if(vbo_changed) {
|
if(vbo_changed) {
|
||||||
|
|
||||||
if(m_vbosActive.find(&data) != m_vbosActive.end()) {
|
if(m_vbosActive.find(vbo_data->m_data) != m_vbosActive.end()) {
|
||||||
m_currentVBO = m_vbosActive[&data];
|
m_currentVBO = m_vbosActive[vbo_data->m_data];
|
||||||
|
|
||||||
m_currentVBO->bind();
|
m_currentVBO->bind();
|
||||||
|
|
||||||
} else if(m_vbosPool.find(&data) != m_vbosPool.end()) {
|
} else if(m_vbosPool.find(vbo_data->m_data) != m_vbosPool.end()) {
|
||||||
m_currentVBO = m_vbosPool[&data];
|
m_currentVBO = m_vbosPool[vbo_data->m_data];
|
||||||
m_vbosPool.erase(&data);
|
m_vbosPool.erase(vbo_data->m_data);
|
||||||
m_vbosActive[&data] = m_currentVBO;
|
m_vbosActive[vbo_data->m_data] = m_currentVBO;
|
||||||
|
|
||||||
m_currentVBO->bind();
|
m_currentVBO->bind();
|
||||||
|
|
||||||
@@ -203,7 +212,7 @@ void KRMeshManager::bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vert
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
while(m_vbosPool.size() + m_vbosActive.size() + 1 >= KRContext::KRENGINE_MAX_VBO_HANDLES || m_vboMemUsed + data.getSize() + index_data.getSize() >= KRContext::KRENGINE_MAX_VBO_MEM) {
|
while(m_vbosPool.size() + m_vbosActive.size() + 1 >= KRContext::KRENGINE_MAX_VBO_HANDLES || m_vboMemUsed + vbo_data->getSize() >= KRContext::KRENGINE_MAX_VBO_MEM) {
|
||||||
if(m_vbosPool.empty()) {
|
if(m_vbosPool.empty()) {
|
||||||
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "flushBuffers due to VBO exhaustion...");
|
KRContext::Log(KRContext::LOG_LEVEL_WARNING, "flushBuffers due to VBO exhaustion...");
|
||||||
m_pContext->rotateBuffers(false);
|
m_pContext->rotateBuffers(false);
|
||||||
@@ -212,22 +221,34 @@ void KRMeshManager::bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vert
|
|||||||
KRVBOData *firstVBO = first_itr->second;
|
KRVBOData *firstVBO = first_itr->second;
|
||||||
m_vbosPool.erase(first_itr);
|
m_vbosPool.erase(first_itr);
|
||||||
|
|
||||||
m_vboMemUsed -= firstVBO->m_size;
|
m_vboMemUsed -= firstVBO->getSize();
|
||||||
firstVBO->unload();
|
firstVBO->unload();
|
||||||
|
if(firstVBO->isTemporary()) {
|
||||||
delete firstVBO;
|
delete firstVBO;
|
||||||
|
}
|
||||||
// fprintf(stderr, "VBO Swapping...\n");
|
// fprintf(stderr, "VBO Swapping...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentVBO = new KRVBOData();
|
used_vbo_data = true;
|
||||||
|
m_currentVBO = vbo_data;
|
||||||
|
|
||||||
m_currentVBO->load(data, index_data, vertex_attrib_flags, static_vbo);
|
m_currentVBO->load();
|
||||||
m_memoryTransferredThisFrame += m_currentVBO->m_size;
|
m_memoryTransferredThisFrame += m_currentVBO->getSize();
|
||||||
m_vboMemUsed += m_currentVBO->m_size;
|
m_vboMemUsed += m_currentVBO->getSize();
|
||||||
|
|
||||||
m_vbosActive[&data] = m_currentVBO;
|
m_vbosActive[vbo_data->m_data] = m_currentVBO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!used_vbo_data && vbo_data->isTemporary()) {
|
||||||
|
delete vbo_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRMeshManager::bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo)
|
||||||
|
{
|
||||||
|
KRVBOData *vbo_data = new KRVBOData(data, index_data, vertex_attrib_flags, static_vbo, true);
|
||||||
|
bindVBO(vbo_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMeshManager::configureAttribs(__int32_t attributes)
|
void KRMeshManager::configureAttribs(__int32_t attributes)
|
||||||
@@ -308,7 +329,7 @@ long KRMeshManager::getMemActive()
|
|||||||
{
|
{
|
||||||
long mem_active = 0;
|
long mem_active = 0;
|
||||||
for(unordered_map<KRDataBlock *, KRVBOData *>::iterator itr = m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {
|
for(unordered_map<KRDataBlock *, KRVBOData *>::iterator itr = m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {
|
||||||
mem_active += (*itr).second->m_size;
|
mem_active += (*itr).second->getSize();
|
||||||
}
|
}
|
||||||
return mem_active;
|
return mem_active;
|
||||||
}
|
}
|
||||||
@@ -466,10 +487,38 @@ void KRMeshManager::doStreaming(long &memoryRemaining, long &memoryRemainingThis
|
|||||||
|
|
||||||
KRMeshManager::KRVBOData::KRVBOData()
|
KRMeshManager::KRVBOData::KRVBOData()
|
||||||
{
|
{
|
||||||
|
m_temp_vbo = false;
|
||||||
|
m_static_vbo = false;
|
||||||
|
m_data = NULL;
|
||||||
|
m_index_data = NULL;
|
||||||
|
m_vertex_attrib_flags = 0;
|
||||||
m_vbo_handle = -1;
|
m_vbo_handle = -1;
|
||||||
m_vbo_handle_indexes = -1;
|
m_vbo_handle_indexes = -1;
|
||||||
m_vao_handle = -1;
|
m_vao_handle = -1;
|
||||||
m_data = NULL;
|
m_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRMeshManager::KRVBOData::KRVBOData(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo, bool temp_vbo)
|
||||||
|
{
|
||||||
|
init(data,index_data,vertex_attrib_flags, static_vbo, temp_vbo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRMeshManager::KRVBOData::init(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo, bool temp_vbo)
|
||||||
|
{
|
||||||
|
m_temp_vbo = temp_vbo;
|
||||||
|
m_static_vbo = static_vbo;
|
||||||
|
m_data = &data;
|
||||||
|
m_index_data = &index_data;
|
||||||
|
m_vertex_attrib_flags = vertex_attrib_flags;
|
||||||
|
|
||||||
|
m_vbo_handle = -1;
|
||||||
|
m_vbo_handle_indexes = -1;
|
||||||
|
m_vao_handle = -1;
|
||||||
|
|
||||||
|
m_size = m_data->getSize();
|
||||||
|
if(m_index_data != NULL) {
|
||||||
|
m_size += m_index_data->getSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMeshManager::KRVBOData::~KRVBOData()
|
KRMeshManager::KRVBOData::~KRVBOData()
|
||||||
@@ -477,14 +526,76 @@ KRMeshManager::KRVBOData::~KRVBOData()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void KRMeshManager::KRVBOData::load()
|
||||||
|
{
|
||||||
|
m_vao_handle = -1;
|
||||||
|
m_vbo_handle = -1;
|
||||||
|
m_vbo_handle_indexes = -1;
|
||||||
|
|
||||||
|
GLDEBUG(glGenBuffers(1, &m_vbo_handle));
|
||||||
|
if(m_index_data->getSize() > 0) {
|
||||||
|
GLDEBUG(glGenBuffers(1, &m_vbo_handle_indexes));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if GL_OES_vertex_array_object
|
||||||
|
GLDEBUG(glGenVertexArraysOES(1, &m_vao_handle));
|
||||||
|
GLDEBUG(glBindVertexArrayOES(m_vao_handle));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_vbo_handle));
|
||||||
|
#if GL_OES_mapbuffer
|
||||||
|
|
||||||
|
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, m_data->getSize(), NULL, m_static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
||||||
|
m_data->copy(map_ptr);
|
||||||
|
GLDEBUG(glUnmapBufferOES(GL_ARRAY_BUFFER));
|
||||||
|
#else
|
||||||
|
m_data->lock();
|
||||||
|
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, m_data->getSize(), m_data->getStart(), m_static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
m_data->unlock();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
configureAttribs(m_vertex_attrib_flags);
|
||||||
|
|
||||||
|
if(m_index_data->getSize() == 0) {
|
||||||
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
|
} else {
|
||||||
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbo_handle_indexes));
|
||||||
|
|
||||||
|
#if GL_OES_mapbuffer
|
||||||
|
|
||||||
|
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_data->getSize(), NULL, m_static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
||||||
|
m_index_data->copy(map_ptr);
|
||||||
|
GLDEBUG(glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER));
|
||||||
|
#else
|
||||||
|
m_index_data->lock();
|
||||||
|
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_data->getSize(), m_index_data->getStart(), m_static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
m_index_data->unlock();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KRMeshManager::KRVBOData::unload()
|
void KRMeshManager::KRVBOData::unload()
|
||||||
{
|
{
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
GLDEBUG(glDeleteVertexArraysOES(1, &m_vao_handle));
|
if(m_vao_handle != -1) {
|
||||||
|
GLDEBUG(glDeleteVertexArraysOES(1, &m_vao_handle));
|
||||||
|
m_vao_handle = -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
GLDEBUG(glDeleteBuffers(1, &m_vbo_handle));
|
if(m_vbo_handle != -1) {
|
||||||
|
GLDEBUG(glDeleteBuffers(1, &m_vbo_handle));
|
||||||
|
m_vbo_handle = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if(m_vbo_handle_indexes != -1) {
|
if(m_vbo_handle_indexes != -1) {
|
||||||
GLDEBUG(glDeleteBuffers(1, &m_vbo_handle_indexes));
|
GLDEBUG(glDeleteBuffers(1, &m_vbo_handle_indexes));
|
||||||
|
m_vbo_handle_indexes = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,61 +612,4 @@ void KRMeshManager::KRVBOData::bind()
|
|||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbo_handle_indexes));
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbo_handle_indexes));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMeshManager::KRVBOData::load(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo)
|
|
||||||
{
|
|
||||||
m_vertex_attrib_flags = vertex_attrib_flags;
|
|
||||||
m_vao_handle = -1;
|
|
||||||
m_vbo_handle = -1;
|
|
||||||
m_vbo_handle_indexes = -1;
|
|
||||||
|
|
||||||
GLDEBUG(glGenBuffers(1, &m_vbo_handle));
|
|
||||||
if(index_data.getSize() > 0) {
|
|
||||||
GLDEBUG(glGenBuffers(1, &m_vbo_handle_indexes));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if GL_OES_vertex_array_object
|
|
||||||
GLDEBUG(glGenVertexArraysOES(1, &m_vao_handle));
|
|
||||||
GLDEBUG(glBindVertexArrayOES(m_vao_handle));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_vbo_handle));
|
|
||||||
#if GL_OES_mapbuffer
|
|
||||||
|
|
||||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, data.getSize(), NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
|
||||||
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
|
||||||
data.copy(map_ptr);
|
|
||||||
GLDEBUG(glUnmapBufferOES(GL_ARRAY_BUFFER));
|
|
||||||
#else
|
|
||||||
data.lock();
|
|
||||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, data.getSize(), data.getStart(), static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
|
||||||
data.unlock();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
configureAttribs(vertex_attrib_flags);
|
|
||||||
|
|
||||||
m_size = data.getSize();
|
|
||||||
m_data = &data;
|
|
||||||
|
|
||||||
if(index_data.getSize() == 0) {
|
|
||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
|
||||||
} else {
|
|
||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_vbo_handle_indexes));
|
|
||||||
|
|
||||||
#if GL_OES_mapbuffer
|
|
||||||
|
|
||||||
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data.getSize(), NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
|
||||||
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
|
||||||
index_data.copy(map_ptr);
|
|
||||||
GLDEBUG(glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER));
|
|
||||||
#else
|
|
||||||
index_data.lock();
|
|
||||||
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data.getSize(), index_data.getStart(), static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
|
||||||
index_data.unlock();
|
|
||||||
#endif
|
|
||||||
m_size += index_data.getSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -59,6 +59,42 @@ public:
|
|||||||
std::vector<std::string> getModelNames();
|
std::vector<std::string> getModelNames();
|
||||||
unordered_multimap<std::string, KRMesh *> &getModels();
|
unordered_multimap<std::string, KRMesh *> &getModels();
|
||||||
|
|
||||||
|
class KRVBOData {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
KRVBOData();
|
||||||
|
KRVBOData(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo, bool temp_vbo);
|
||||||
|
void init(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo, bool temp_vbo);
|
||||||
|
~KRVBOData();
|
||||||
|
|
||||||
|
|
||||||
|
KRDataBlock *m_data;
|
||||||
|
KRDataBlock *m_index_data;
|
||||||
|
|
||||||
|
|
||||||
|
void load();
|
||||||
|
void unload();
|
||||||
|
void bind();
|
||||||
|
|
||||||
|
// Disable copy constructors
|
||||||
|
KRVBOData(const KRVBOData& o) = delete;
|
||||||
|
KRVBOData(KRVBOData& o) = delete;
|
||||||
|
|
||||||
|
bool isTemporary() { return m_temp_vbo; }
|
||||||
|
bool getSize() { return m_size; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_vertex_attrib_flags;
|
||||||
|
GLuint m_vbo_handle;
|
||||||
|
GLuint m_vbo_handle_indexes;
|
||||||
|
GLuint m_vao_handle;
|
||||||
|
bool m_static_vbo;
|
||||||
|
bool m_temp_vbo;
|
||||||
|
GLsizeiptr m_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
void bindVBO(KRVBOData *vbo_data);
|
||||||
void bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo);
|
void bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo);
|
||||||
void releaseVBO(KRDataBlock &data);
|
void releaseVBO(KRDataBlock &data);
|
||||||
void unbindVBO();
|
void unbindVBO();
|
||||||
@@ -108,42 +144,19 @@ public:
|
|||||||
std::vector<draw_call_info> getDrawCalls();
|
std::vector<draw_call_info> getDrawCalls();
|
||||||
|
|
||||||
|
|
||||||
KRDataBlock KRENGINE_VBO_3D_CUBE_VERTICES, KRENGINE_VBO_3D_CUBE_INDEXES;
|
|
||||||
__int32_t KRENGINE_VBO_3D_CUBE_ATTRIBS;
|
KRVBOData KRENGINE_VBO_DATA_3D_CUBE_VERTICES;
|
||||||
|
KRVBOData KRENGINE_VBO_DATA_2D_SQUARE_VERTICES;
|
||||||
KRDataBlock KRENGINE_VBO_2D_SQUARE_VERTICES, KRENGINE_VBO_2D_SQUARE_INDEXES;
|
|
||||||
__int32_t KRENGINE_VBO_2D_SQUARE_ATTRIBS;
|
|
||||||
|
|
||||||
|
|
||||||
void doStreaming(long &memoryRemaining, long &memoryRemainingThisFrame);
|
void doStreaming(long &memoryRemaining, long &memoryRemainingThisFrame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unordered_multimap<std::string, KRMesh *> m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model
|
KRDataBlock KRENGINE_VBO_3D_CUBE_VERTICES, KRENGINE_VBO_3D_CUBE_INDEXES;
|
||||||
|
__int32_t KRENGINE_VBO_3D_CUBE_ATTRIBS;
|
||||||
|
KRDataBlock KRENGINE_VBO_2D_SQUARE_VERTICES, KRENGINE_VBO_2D_SQUARE_INDEXES;
|
||||||
|
__int32_t KRENGINE_VBO_2D_SQUARE_ATTRIBS;
|
||||||
|
|
||||||
class KRVBOData {
|
unordered_multimap<std::string, KRMesh *> m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
KRVBOData();
|
|
||||||
~KRVBOData();
|
|
||||||
|
|
||||||
GLsizeiptr m_size;
|
|
||||||
KRDataBlock *m_data;
|
|
||||||
|
|
||||||
void load(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo);
|
|
||||||
void unload();
|
|
||||||
void bind();
|
|
||||||
|
|
||||||
// Disable copy constructors
|
|
||||||
KRVBOData(const KRVBOData& o) = delete;
|
|
||||||
KRVBOData(KRVBOData& o) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_vertex_attrib_flags;
|
|
||||||
GLuint m_vbo_handle;
|
|
||||||
GLuint m_vbo_handle_indexes;
|
|
||||||
GLuint m_vao_handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
long m_vboMemUsed;
|
long m_vboMemUsed;
|
||||||
KRVBOData *m_currentVBO;
|
KRVBOData *m_currentVBO;
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
|
|||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
||||||
|
|
||||||
//m_pContext->getMeshManager()->bindVBO((void *)m_pContext->getMeshManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
|
||||||
KRDataBlock index_data;
|
KRDataBlock index_data;
|
||||||
m_pContext->getMeshManager()->bindVBO(m_pContext->getMeshManager()->getRandomParticles(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
m_pContext->getMeshManager()->bindVBO(m_pContext->getMeshManager()->getRandomParticles(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||||
@@ -87,31 +86,3 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// KRMat4 particleModelMatrix = KRMat4();
|
|
||||||
//// particleModelMatrix.scale(particleBlockScale);
|
|
||||||
////
|
|
||||||
//// KRVector3 particleBlockOrigin = KRVector3(m_viewport.getCameraPosition().x - fmod(m_viewport.getCameraPosition().x + x * particleBlockScale, particleBlockScale), m_viewport.getCameraPosition().y - fmod(m_viewport.getCameraPosition().y + y * particleBlockScale, particleBlockScale),m_viewport.getCameraPosition().z - fmod(m_viewport.getCameraPosition().z + z * particleBlockScale, particleBlockScale));
|
|
||||||
////
|
|
||||||
//// particleModelMatrix.translate(particleBlockOrigin);
|
|
||||||
//// particleModelMatrix.translate(sin(m_particlesAbsoluteTime * 0.0523f) * 10.0f, sin(m_particlesAbsoluteTime * 0.0553f) * 10.0f, sin(m_particlesAbsoluteTime * 0.0521f) * 10.0f);
|
|
||||||
//
|
|
||||||
// int particle_count = 10000;
|
|
||||||
//
|
|
||||||
// if(getContext().getShaderManager()->selectShader(pParticleShader, m_viewport, particleModelMatrix, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_ADDITIVE_PARTICLES)) {
|
|
||||||
// GLDEBUG(glUniform1f(
|
|
||||||
// pParticleShader->m_uniforms[KRShader::KRENGINE_UNIFORM_FLARE_SIZE],
|
|
||||||
// 1.0f
|
|
||||||
// ));
|
|
||||||
//
|
|
||||||
// m_pContext->getMeshManager()->bindVBO((void *)m_pContext->getMeshManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
|
||||||
// GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
|
||||||
// }
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
@@ -97,7 +97,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
|
|||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
} else {
|
} else {
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
|
|||||||
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
|
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
|
||||||
|
|
||||||
|
|
||||||
getContext().getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
getContext().getMeshManager()->bindVBO(&getContext().getMeshManager()->KRENGINE_VBO_DATA_3D_CUBE_VERTICES);
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
|
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
|
||||||
m_pContext->getMeshManager()->bindVBO(getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getMeshManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getMeshManager()->bindVBO(&m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user