Profiler / Debug visualizations in progress
Implemented support for dynamic VBO's (used by text rendering system)
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
||||
E43B0AD815DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E43B0AD915DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4409D2916FA748700310F76 /* font.tga in Resources */ = {isa = PBXBuildFile; fileRef = E41AE1DD16B124CA00980428 /* font.tga */; };
|
||||
E44F38241683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E44F38281683B24800399B5D /* KRRenderSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44F38271683B24400399B5D /* KRRenderSettings.cpp */; };
|
||||
@@ -144,7 +145,6 @@
|
||||
E48B68171697794F00D99917 /* KRAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B68141697794F00D99917 /* KRAudioSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E48B68181697794F00D99917 /* KRAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B68141697794F00D99917 /* KRAudioSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E48B953016B9C8BA0042EE29 /* font.tga in Resources */ = {isa = PBXBuildFile; fileRef = E41AE1DD16B124CA00980428 /* font.tga */; };
|
||||
E48B955016B9C8D60042EE29 /* font.pvr in Resources */ = {isa = PBXBuildFile; fileRef = E4CE184815FEEDA200F80870 /* font.pvr */; };
|
||||
E48C696F15374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E48C697015374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E48C697215374F7E00232E28 /* KRContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48C697115374F7E00232E28 /* KRContext.cpp */; };
|
||||
@@ -1405,6 +1405,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E4409D2916FA748700310F76 /* font.tga in Resources */,
|
||||
E437849816C4884F0037FD43 /* hrtf_kemar.krbundle in Resources */,
|
||||
E4E6F68516BA5DF700E410F8 /* sky_box.fsh in Resources */,
|
||||
E4E6F68616BA5DF700E410F8 /* debug_font.fsh in Resources */,
|
||||
@@ -1436,7 +1437,6 @@
|
||||
E4E6F6A016BA5DF700E410F8 /* volumetric_fog_downsampled.vsh in Resources */,
|
||||
E4E6F6A116BA5DF700E410F8 /* volumetric_fog.fsh in Resources */,
|
||||
E4E6F6A216BA5DF700E410F8 /* volumetric_fog.vsh in Resources */,
|
||||
E48B955016B9C8D60042EE29 /* font.pvr in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -51,9 +51,14 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
|
||||
|
||||
volumetricLightAccumulationBuffer = 0;
|
||||
volumetricLightAccumulationTexture = 0;
|
||||
|
||||
m_debug_text_vertices = NULL;
|
||||
}
|
||||
|
||||
KRCamera::~KRCamera() {
|
||||
if(m_debug_text_vertices) {
|
||||
delete m_debug_text_vertices;
|
||||
}
|
||||
destroyBuffers();
|
||||
}
|
||||
|
||||
@@ -234,7 +239,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
||||
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture);
|
||||
|
||||
// Render a full screen quad
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
}
|
||||
|
||||
@@ -370,7 +375,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
||||
|
||||
KRShader *pVisShader = getContext().getShaderManager()->getShader("visualize_overlay", this, std::vector<KRLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, true, false, false, false, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, true, false, false, false, false, false, false, true);
|
||||
for(std::map<KRAABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
|
||||
KRMat4 matModel = KRMat4();
|
||||
matModel.scale((*itr).first.size() / 2.0f);
|
||||
@@ -390,6 +395,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
||||
|
||||
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO));
|
||||
renderPost();
|
||||
m_pContext->getModelManager()->unbindVBO();
|
||||
}
|
||||
|
||||
|
||||
@@ -590,7 +596,7 @@ void KRCamera::renderPost()
|
||||
}
|
||||
|
||||
// Update attribute values.
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false, true);
|
||||
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
|
||||
@@ -612,7 +618,7 @@ void KRCamera::renderPost()
|
||||
// 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);
|
||||
// m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||
// m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false);
|
||||
// m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, true);
|
||||
// GLDEBUG(glActiveTexture(GL_TEXTURE0));
|
||||
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]));
|
||||
//#if GL_EXT_shadow_samplers
|
||||
@@ -631,50 +637,171 @@ void KRCamera::renderPost()
|
||||
|
||||
|
||||
|
||||
if(m_debug_text_vertices) {
|
||||
m_pContext->getModelManager()->releaseVBO(m_debug_text_vertices);
|
||||
}
|
||||
|
||||
const char *szText = settings.m_debug_text.c_str();
|
||||
if(*szText) {
|
||||
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"));
|
||||
|
||||
bool show_active_textures = false;
|
||||
std::string debug_text = "";
|
||||
if(show_active_textures) {
|
||||
|
||||
const char *pChar = szText;
|
||||
int iPos=0;
|
||||
float dScale = 1.0 / 24.0;
|
||||
float dTexScale = 1.0 / 16.0;
|
||||
while(*pChar) {
|
||||
int iChar = *pChar++ - '\0';
|
||||
int iCol = iChar % 16;
|
||||
int iRow = 15 - (iChar - iCol) / 16;
|
||||
|
||||
GLfloat charVertices[] = {
|
||||
-1.0f, dScale * iPos - 1.0,
|
||||
-1.0 + dScale, dScale * iPos - 1.0,
|
||||
-1.0f, dScale * iPos + dScale - 1.0,
|
||||
-1.0 + dScale, dScale * iPos + dScale - 1.0,
|
||||
};
|
||||
|
||||
GLfloat charTexCoords[] = {
|
||||
dTexScale * iCol, dTexScale * iRow + dTexScale,
|
||||
dTexScale * iCol, dTexScale * iRow,
|
||||
dTexScale * iCol + dTexScale, dTexScale * iRow + dTexScale,
|
||||
dTexScale * iCol + dTexScale, dTexScale * iRow
|
||||
};
|
||||
#if GL_OES_vertex_array_object
|
||||
GLDEBUG(glBindVertexArrayOES(0));
|
||||
#elif GL_vertex_array_object
|
||||
#endif
|
||||
m_pContext->getModelManager()->configureAttribs(true, false, false, true, false, false, false);
|
||||
GLDEBUG(glVertexAttribPointer(KRMesh::KRENGINE_ATTRIB_TEXUVA, 2, GL_FLOAT, 0, 0, charTexCoords));
|
||||
GLDEBUG(glVertexAttribPointer(KRMesh::KRENGINE_ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, charVertices));
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
|
||||
iPos++;
|
||||
|
||||
std::set<KRTexture *> active_textures = m_pContext->getTextureManager()->getActiveTextures();
|
||||
for(std::set<KRTexture *>::iterator itr=active_textures.begin(); itr != active_textures.end(); itr++) {
|
||||
KRTexture *texture = *itr;
|
||||
if(debug_text.length()) {
|
||||
debug_text += "\n";
|
||||
}
|
||||
debug_text += texture->getName();
|
||||
debug_text += " ";
|
||||
debug_text += texture->getMemSize() / 1024;
|
||||
debug_text += "kB";
|
||||
debug_text += " ";
|
||||
debug_text += texture->getMaxMipMap();
|
||||
if(texture->getCurrentLodMaxDim() != texture->getMaxMipMap()) {
|
||||
debug_text += "px => ";
|
||||
debug_text += texture->getCurrentLodMaxDim();
|
||||
}
|
||||
debug_text += "px";
|
||||
}
|
||||
|
||||
GLDEBUG(glActiveTexture(GL_TEXTURE0));
|
||||
GLDEBUG(glBindTexture(GL_TEXTURE_2D, 0));
|
||||
szText = debug_text.c_str();
|
||||
}
|
||||
if(*szText) {
|
||||
int row_count = 1;
|
||||
int col_count = 0;
|
||||
int iCol = 0;
|
||||
const char *pChar = szText;
|
||||
while(*pChar) {
|
||||
char c = *pChar++;
|
||||
if(c == '\n') {
|
||||
row_count++;
|
||||
iCol = 0;
|
||||
} else {
|
||||
iCol++;
|
||||
if(iCol > col_count) col_count = iCol;
|
||||
}
|
||||
}
|
||||
|
||||
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||
|
||||
const int DEBUG_TEXT_COLUMNS = 256;
|
||||
const int DEBUG_TEXT_ROWS = 128;
|
||||
|
||||
if(m_debug_text_vertices == NULL) {
|
||||
m_debug_text_vertices = new DebugTextVertexData[DEBUG_TEXT_COLUMNS * DEBUG_TEXT_ROWS * 6];
|
||||
}
|
||||
int vertex_count = 0;
|
||||
|
||||
|
||||
|
||||
pChar = szText;
|
||||
float dScaleX = 2.0 / (2048 / 16);
|
||||
float dScaleY = 2.0 / (1536 / 16);
|
||||
float dTexScale = 1.0 / 16.0;
|
||||
int iRow = row_count - 1; iCol = 0;
|
||||
while(*pChar) {
|
||||
char c = *pChar++;
|
||||
if(c == ' ') {
|
||||
iCol++;
|
||||
} else if(c == '\n') {
|
||||
iCol = 0;
|
||||
iRow--;
|
||||
} else {
|
||||
if(iCol < DEBUG_TEXT_COLUMNS && iRow < DEBUG_TEXT_ROWS) {
|
||||
int iChar = c - '\0';
|
||||
int iTexCol = iChar % 16;
|
||||
int iTexRow = 15 - (iChar - iTexCol) / 16;
|
||||
|
||||
KRVector2 top_left_pos = KRVector2(-1.0f + dScaleX * iCol, dScaleY * iRow - 1.0);
|
||||
KRVector2 bottom_right_pos = KRVector2(-1.0 + dScaleX * (iCol + 1), dScaleY * iRow + dScaleY - 1.0);
|
||||
top_left_pos += KRVector2(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
||||
bottom_right_pos += KRVector2(1.0f / 2048.0f * 0.5f, 1.0f / 1536.0f * 0.5f);
|
||||
KRVector2 top_left_uv = KRVector2(dTexScale * iTexCol, dTexScale * iTexRow);
|
||||
KRVector2 bottom_right_uv = KRVector2(dTexScale * iTexCol + dTexScale, dTexScale * iTexRow + dTexScale);
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
||||
vertex_count++;
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
||||
vertex_count++;
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
||||
vertex_count++;
|
||||
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
||||
vertex_count++;
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
||||
vertex_count++;
|
||||
|
||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
||||
vertex_count++;
|
||||
}
|
||||
|
||||
iCol++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Disable backface culling
|
||||
GLDEBUG(glDisable(GL_CULL_FACE));
|
||||
|
||||
// Disable z-buffer write
|
||||
GLDEBUG(glDepthMask(GL_FALSE));
|
||||
|
||||
// Disable z-buffer test
|
||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||
// GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||
|
||||
// Enable alpha blending
|
||||
GLDEBUG(glEnable(GL_BLEND));
|
||||
GLDEBUG(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||
|
||||
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"));
|
||||
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_debug_text_vertices, vertex_count * sizeof(DebugTextVertexData), NULL, 0, true, false, false, true, false, false, false, true);
|
||||
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, vertex_count));
|
||||
|
||||
// Re-enable z-buffer write
|
||||
GLDEBUG(glDepthMask(GL_TRUE));
|
||||
|
||||
} else {
|
||||
if(m_debug_text_vertices) {
|
||||
delete m_debug_text_vertices;
|
||||
m_debug_text_vertices = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,17 @@ private:
|
||||
KRViewport m_viewport;
|
||||
|
||||
float m_particlesAbsoluteTime;
|
||||
|
||||
|
||||
typedef struct {
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
GLfloat z;
|
||||
GLfloat u;
|
||||
GLfloat v;
|
||||
} DebugTextVertexData;
|
||||
|
||||
DebugTextVertexData *m_debug_text_vertices;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -133,7 +133,7 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRLight *> &light
|
||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||
|
||||
// Render a full screen quad
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
||||
|
||||
GLDEBUG(glUniform1f(pParticleShader->m_uniforms[KRShader::KRENGINE_UNIFORM_FLARE_SIZE], m_dust_particle_size));
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
||||
KRVector2(slice_near, slice_spacing).setUniform(pFogShader->m_uniforms[KRShader::KRENGINE_UNIFORM_SLICE_DEPTH_SCALE]);
|
||||
(m_color * pCamera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f).setUniform(pFogShader->m_uniforms[KRShader::KRENGINE_UNIFORM_LIGHT_COLOR]);
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getVolumetricLightingVertexes(), KRMeshManager::KRENGINE_MAX_VOLUMETRIC_PLANES * 6 * sizeof(KRMeshManager::VolumetricLightingVertexData), NULL, 0, true, false, false, false, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getVolumetricLightingVertexes(), KRMeshManager::KRENGINE_MAX_VOLUMETRIC_PLANES * 6 * sizeof(KRMeshManager::VolumetricLightingVertexData), NULL, 0, true, false, false, false, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, slice_count*6));
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, const KR
|
||||
m_flareSize
|
||||
));
|
||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ void KRMesh::renderSubmesh(int iSubmesh) {
|
||||
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((unsigned char *)pVertexData + iBuffer * MAX_VBO_SIZE * vertex_size, vertex_size * cBufferVertexes, NULL, 0, has_vertex_attribute(KRENGINE_ATTRIB_VERTEX), has_vertex_attribute(KRENGINE_ATTRIB_NORMAL), has_vertex_attribute(KRENGINE_ATTRIB_TANGENT), has_vertex_attribute(KRENGINE_ATTRIB_TEXUVA), has_vertex_attribute(KRENGINE_ATTRIB_TEXUVB), has_vertex_attribute(KRENGINE_ATTRIB_BONEINDEXES),
|
||||
has_vertex_attribute(KRENGINE_ATTRIB_BONEWEIGHTS));
|
||||
has_vertex_attribute(KRENGINE_ATTRIB_BONEWEIGHTS), true);
|
||||
|
||||
|
||||
if(iVertex + cVertexes >= MAX_VBO_SIZE) {
|
||||
|
||||
@@ -114,7 +114,38 @@ void KRMeshManager::unbindVBO() {
|
||||
}
|
||||
}
|
||||
|
||||
void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb, bool enable_bone_indexes, bool enable_bone_weights) {
|
||||
void KRMeshManager::releaseVBO(GLvoid *data)
|
||||
{
|
||||
if(m_currentVBO.data == data) {
|
||||
unbindVBO();
|
||||
}
|
||||
|
||||
vbo_info_type vbo_to_release;
|
||||
if(m_vbosActive.find(data) != m_vbosActive.end()) {
|
||||
fprintf(stderr, "glFinish called due to releasing a VBO that is active in the current frame.\n");
|
||||
GLDEBUG(glFinish());
|
||||
|
||||
// The VBO is active
|
||||
vbo_to_release = m_vbosActive[data];
|
||||
m_vbosActive.erase(data);
|
||||
} else {
|
||||
// The VBO is inactive
|
||||
vbo_to_release = m_vbosPool[data];
|
||||
m_vbosPool.erase(data);
|
||||
}
|
||||
|
||||
m_vboMemUsed -= vbo_to_release.size;
|
||||
|
||||
#if GL_OES_vertex_array_object
|
||||
GLDEBUG(glDeleteVertexArraysOES(1, &vbo_to_release.vao_handle));
|
||||
#endif
|
||||
GLDEBUG(glDeleteBuffers(1, &vbo_to_release.vbo_handle));
|
||||
if(vbo_to_release.vbo_handle_indexes != -1) {
|
||||
GLDEBUG(glDeleteBuffers(1, &vbo_to_release.vbo_handle_indexes));
|
||||
}
|
||||
}
|
||||
|
||||
void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb, bool enable_bone_indexes, bool enable_bone_weights, bool static_vbo) {
|
||||
|
||||
if(m_currentVBO.data != data || m_currentVBO.size != size) {
|
||||
|
||||
@@ -168,7 +199,7 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
||||
#endif
|
||||
|
||||
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.vbo_handle));
|
||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW));
|
||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||
m_vboMemUsed += size;
|
||||
configureAttribs(enable_vertex, enable_normal, enable_tangent, enable_uva, enable_uvb, enable_bone_indexes, enable_bone_weights);
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ public:
|
||||
std::multimap<std::string, KRMesh *> getModels();
|
||||
|
||||
|
||||
void bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb, bool enable_bone_indexes, bool enable_bone_weights);
|
||||
void bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, bool enable_vertex, bool enable_normal, bool enable_tangent, bool enable_uva, bool enable_uvb, bool enable_bone_indexes, bool enable_bone_weights, bool static_vbo);
|
||||
void releaseVBO(GLvoid *data);
|
||||
void unbindVBO();
|
||||
long getMemUsed();
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRLight *>
|
||||
1.0f
|
||||
));
|
||||
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false, false, false, false);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRLight *>
|
||||
// 1.0f
|
||||
// ));
|
||||
//
|
||||
// m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false);
|
||||
// m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, true, false, false, true, false, false);
|
||||
// GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||
// }
|
||||
//// }
|
||||
|
||||
@@ -111,7 +111,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRLight *> &lights, con
|
||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||
|
||||
// Render a full screen quad
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false);
|
||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, true, false, false, true, false, false, false, true);
|
||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||
} else {
|
||||
#if GL_OES_vertex_array_object
|
||||
|
||||
@@ -251,7 +251,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::map<KRAABB, int> &visibleBo
|
||||
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
|
||||
|
||||
|
||||
getContext().getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, true, false, false, false, false, false, false);
|
||||
getContext().getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, true, false, false, false, false, false, false, true);
|
||||
|
||||
// Enable additive blending
|
||||
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
||||
|
||||
@@ -135,3 +135,14 @@ KRTexture *KRTexture::compress()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int KRTexture::getCurrentLodMaxDim() {
|
||||
return m_current_lod_max_dim;
|
||||
}
|
||||
|
||||
int KRTexture::getMaxMipMap() {
|
||||
return m_max_lod_max_dim;
|
||||
}
|
||||
|
||||
int KRTexture::getMinMipMap() {
|
||||
return m_min_lod_max_dim;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ public:
|
||||
virtual bool isAnimated();
|
||||
|
||||
KRTexture *compress();
|
||||
int getCurrentLodMaxDim();
|
||||
int getMaxMipMap();
|
||||
int getMinMipMap();
|
||||
|
||||
protected:
|
||||
virtual bool createGLTexture(int lod_max_dim) = 0;
|
||||
|
||||
@@ -79,14 +79,6 @@ void KRTexture2D::bind() {
|
||||
}
|
||||
}
|
||||
|
||||
int KRTexture2D::getMaxMipMap() {
|
||||
return m_max_lod_max_dim;
|
||||
}
|
||||
|
||||
int KRTexture2D::getMinMipMap() {
|
||||
return m_min_lod_max_dim;
|
||||
}
|
||||
|
||||
bool KRTexture2D::hasMipmaps() {
|
||||
return m_max_lod_max_dim != m_min_lod_max_dim;
|
||||
}
|
||||
@@ -107,4 +99,4 @@ bool KRTexture2D::save(KRDataBlock &data) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
virtual bool save(KRDataBlock &data);
|
||||
|
||||
bool hasMipmaps();
|
||||
int getMaxMipMap();
|
||||
int getMinMipMap();
|
||||
|
||||
virtual bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed) = 0;
|
||||
virtual void bind();
|
||||
|
||||
@@ -300,4 +300,10 @@ void KRTextureManager::compress()
|
||||
lowerName.begin(), ::tolower);
|
||||
m_textures[lowerName] = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::set<KRTexture *> &KRTextureManager::getActiveTextures()
|
||||
{
|
||||
return m_activeTextures;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
void compress();
|
||||
|
||||
std::set<KRTexture *> &getActiveTextures();
|
||||
|
||||
private:
|
||||
long m_memoryTransferredThisFrame;
|
||||
|
||||
|
||||
@@ -31,5 +31,7 @@ uniform sampler2D diffuseTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(diffuseTexture, textureCoordinate);
|
||||
lowp vec4 font_color = texture2D(diffuseTexture, textureCoordinate);
|
||||
gl_FragColor = vec4(font_color.r, font_color.g, font_color.b, font_color.r + 0.50);
|
||||
// gl_FragColor = vec4(textureCoordinate.s, textureCoordinate.t, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
gl_Position = /*mvp_matrix * */vertex_position;
|
||||
textureCoordinate = vertex_uv.xy;
|
||||
}
|
||||
|
||||
@@ -31,5 +31,6 @@ uniform sampler2D diffuseTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(diffuseTexture, textureCoordinate);
|
||||
vec4 font_color = texture2D(diffuseTexture, textureCoordinate);
|
||||
gl_FragColor = vec4(font_color.r, font_color.g, font_color.b, font_color.r + 0.50);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = mvp_matrix * vertex_position;
|
||||
gl_Position = /*mvp_matrix * */vertex_position;
|
||||
textureCoordinate = vertex_uv.xy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user