Now compatible with GLKView's

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40112
This commit is contained in:
kearwood
2012-10-03 19:29:37 +00:00
parent a6dcbaaca4
commit e6e90c1945
3 changed files with 11 additions and 5 deletions

View File

@@ -132,6 +132,9 @@ void KRCamera::setPosition(const KRVector3 &position) {
void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix) void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix)
{ {
GLint defaultFBO;
GLDEBUG(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO));
m_pContext->rotateBuffers(true); m_pContext->rotateBuffers(true);
KRMat4 invViewMatrix = viewMatrix; KRMat4 invViewMatrix = viewMatrix;
invViewMatrix.invert(); invViewMatrix.invert();
@@ -185,6 +188,8 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix)
} }
renderFrame(scene, viewMatrix, lightDirection, cameraPosition); renderFrame(scene, viewMatrix, lightDirection, cameraPosition);
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO));
renderPost(); renderPost();
m_iFrame++; m_iFrame++;
@@ -341,8 +346,9 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
// Disable alpha blending // Disable alpha blending
GLDEBUG(glDisable(GL_BLEND)); GLDEBUG(glDisable(GL_BLEND));
GLDEBUG(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
GLDEBUG(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); GLDEBUG(glClearColor(0.0f, 0.0f, 0.0f, 1.0f));
GLDEBUG(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
// Enable backface culling // Enable backface culling
GLDEBUG(glCullFace(GL_BACK)); GLDEBUG(glCullFace(GL_BACK));
@@ -633,9 +639,6 @@ void KRCamera::renderShadowBuffer(KRScene &scene, int iShadow)
void KRCamera::renderPost() void KRCamera::renderPost()
{ {
GLDEBUG(glBindFramebuffer(GL_FRAMEBUFFER, 1)); // renderFramebuffer
// Disable alpha blending // Disable alpha blending
GLDEBUG(glDisable(GL_BLEND)); GLDEBUG(glDisable(GL_BLEND));

View File

@@ -129,7 +129,7 @@ private:
KRMat4 shadowmvpmatrix[KRENGINE_MAX_SHADOW_BUFFERS]; /* MVP Matrix for view from light source */ KRMat4 shadowmvpmatrix[KRENGINE_MAX_SHADOW_BUFFERS]; /* MVP Matrix for view from light source */
void renderPost(); void renderPost();
void destroyBuffers(); void destroyBuffers();
void renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightDirection, KRVector3 &cameraPosition); void renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightDirection, KRVector3 &cameraPosition);

View File

@@ -69,6 +69,9 @@ KRMat4 &KRInstance::getModelMatrix() {
void KRInstance::loadModel() { void KRInstance::loadModel() {
if(m_pModel == NULL) { if(m_pModel == NULL) {
m_pModel = m_pContext->getModelManager()->getModel(m_model_name.c_str()); m_pModel = m_pContext->getModelManager()->getModel(m_model_name.c_str());
if(m_pModel == NULL) {
fprintf(stderr, "KREngine - Model not found: %s\n", m_model_name.c_str());
}
} }
} }