void InstancedTessellation::draw(void) { //matrices for translation and rotation glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (isMobilePlatform()) { nv::matrix4f translation; m_viewMatrix = m_transformer->getModelViewMat() * m_ModelMatrix[ m_modelIndex ] ; //note: there is no m_pModel matrix as the m_pModel is always at origin(0,0,0) in the world-space m_normalMatrixHandle = nv::inverse(m_viewMatrix); m_normalMatrixHandle = nv::transpose(m_normalMatrixHandle); m_lightPositionEye = nv::vec4f(m_lightPosition.x, m_lightPosition.y, m_lightPosition.z, m_lightType); drawModelLit(); } else { for( int x = -1; x <= 1; ++x ) { for( int y = 0; y <= 0; ++y ) { for( int z = 0; z <= 3; ++z ) { nv::matrix4f translation = nv::translation( translation, 20.0f * float(x), 18.0f * float(y), -18.0f * float( z ) ); m_viewMatrix = m_transformer->getModelViewMat() * translation * m_ModelMatrix[ m_modelIndex ] ; //note: there is no m_pModel matrix as the m_pModel is always at origin(0,0,0) in the world-space m_normalMatrixHandle = nv::inverse(m_viewMatrix); m_normalMatrixHandle = nv::transpose(m_normalMatrixHandle); m_lightPositionEye = nv::vec4f(m_lightPosition.x, m_lightPosition.y, m_lightPosition.z, m_lightType); drawModelLit(); } } } } }
void InstancingApp::draw(void) { glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); m_viewMatrix = m_transformer->getModelViewMat(); m_normalMatrix = nv::inverse(m_viewMatrix); m_normalMatrix = nv::transpose(m_normalMatrix); drawModelLit(); }