void BSP_GhostTestApp3D:: DrawPolies( ){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (int i = 0; i < m_meshes.size(); ++i) { MT_Transform trans = GetTransform(i); float opengl_mat[16]; trans.getValue(opengl_mat); glPushMatrix(); glMultMatrixf(opengl_mat); MT_Vector3 color(1.0,1.0,1.0); if (i == m_current_object) { color = MT_Vector3(1.0,0,0); } BSP_MeshDrawer::DrawMesh(m_meshes[i].Ref(),m_render_modes[i]); glPopMatrix(); } m_window->swapBuffers(); }
int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; float glviewmat[16]; unsigned int count; std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); viewmat.getValue(glviewmat); glPushMatrix(); glLoadMatrixf(glviewmat); for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light; if(kxlight->ApplyLight(kxscene, objectlayer, count)) count++; } glPopMatrix(); return count; }
void RAS_OpenGLRasterizer::ProcessLighting(bool uselights, const MT_Transform& viewmat) { bool enable = false; int layer= -1; /* find the layer */ if (uselights) { if (m_clientobject) layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); } /* avoid state switching */ if (m_lastlightlayer == layer && m_lastauxinfo == m_auxilaryClientInfo) return; m_lastlightlayer = layer; m_lastauxinfo = m_auxilaryClientInfo; /* enable/disable lights as needed */ if (layer >= 0) { //enable = ApplyLights(layer, viewmat); // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; float glviewmat[16]; unsigned int count; std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); for (count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); viewmat.getValue(glviewmat); glPushMatrix(); glLoadMatrixf(glviewmat); for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light; if (kxlight->ApplyLight(kxscene, layer, count)) count++; } glPopMatrix(); enable = count > 0; } if (enable) EnableOpenGLLights(); else DisableOpenGLLights(); }