void RenderServer::BindCamera(boost::shared_ptr<Camera>& camera) { camera->Bind(); // adjust the viewport glViewport( camera->GetViewportX(), camera->GetViewportY(), camera->GetViewportWidth(), camera->GetViewportHeight() ); // set depth range glDepthRange(0, 1); if (mEnablePicking) { glRenderMode(GL_SELECT); GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluPickMatrix(mPickAt[0],viewport[3]-mPickAt[1],mPickRange,mPickRange,viewport); glMultMatrixf(camera->GetProjectionTransform().m); glMatrixMode(GL_MODELVIEW); //glLoadIdentity(); //glMultMatrixf(camera->GetViewTransform().m); glInitNames(); } else { // setup the projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMultMatrixf(camera->GetProjectionTransform().m); // initialize the modelview stack glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(camera->GetViewTransform().m); } }
void StaticMesh::RenderInternal() { if ( (mMesh.get() == 0) || (mMaterials.empty()) ) { return; } const float* pos = mMesh->GetPos().get(); if (pos == 0) { return; } glVertexPointer(3, GL_FLOAT, 0, pos); glEnableClientState (GL_VERTEX_ARRAY); const float* tex = mMesh->GetTexCoords().get(); if (tex != 0) { glTexCoordPointer(3, GL_FLOAT, 0, tex); glEnableClientState (GL_TEXTURE_COORD_ARRAY); } const float* normal = mMesh->GetNormals().get(); if (normal != 0) { glNormalPointer(GL_FLOAT, 0, normal); glEnableClientState(GL_NORMAL_ARRAY); } glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glScalef(mScale[0],mScale[1],mScale[2]); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); const TriMesh::TFaces& faces = mMesh->GetFaces(); TriMesh::TFaces::const_iterator iter = faces.begin(); TMaterialList::const_iterator miter = mMaterials.begin(); while ( (iter != faces.end()) && (miter != mMaterials.end()) ) { const boost::shared_ptr<Material> material = (*miter); if (material.get() != 0) { material->Bind(); const TriMesh::Face& face = (*iter); const boost::shared_ptr<IndexBuffer>& idx = face.indeces; glDrawElements(GL_TRIANGLES, idx->GetNumIndex(), GL_UNSIGNED_INT, idx->GetIndex().get()); } ++iter; ++miter; } glDisable(GL_BLEND); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY ); glDisableClientState(GL_NORMAL_ARRAY); }