// Virtual interface for OpenGL Geometry properties. void GLC_Geometry::glPropGeom(const GLC_RenderProperties& renderProperties) { glLineWidth(lineWidth()); if(m_IsWire) { glLineWidth(m_LineWidth); glDisable(GL_LIGHTING); if (!renderProperties.isSelected()) { // Set polyline colors GLfloat color[4]= {static_cast<float>(m_WireColor.redF()), static_cast<float>(m_WireColor.greenF()), static_cast<float>(m_WireColor.blueF()), static_cast<float>(m_WireColor.alphaF())}; glColor4fv(color); } else { GLC_SelectionMaterial::glExecute(); } } else if (m_MaterialHash.size() == 1) { GLC_Material* pCurrentMaterial= m_MaterialHash.begin().value(); if (pCurrentMaterial->hasTexture()) { glEnable(GL_LIGHTING); pCurrentMaterial->glExecute(); if (renderProperties.isSelected()) GLC_SelectionMaterial::glExecute(); } else { glEnable(GL_LIGHTING); if (renderProperties.isSelected()) GLC_SelectionMaterial::glExecute(); else pCurrentMaterial->glExecute(); } } }
// Geometry display void GLC_Geometry::render(const GLC_RenderProperties& renderProperties) { Q_ASSERT(!m_IsWire || (m_IsWire && m_MaterialHash.isEmpty())); bool renderWire= (renderProperties.renderingFlag() == glc::TransparentRenderFlag) && isTransparent(); renderWire= renderWire || ((renderProperties.renderingFlag() != glc::TransparentRenderFlag) && !isTransparent()); if (!m_IsWire || renderWire) { if (m_MaterialHash.isEmpty() && !m_IsWire) { GLC_Material* pMaterial= new GLC_Material(); pMaterial->setName(name()); addMaterial(pMaterial); } m_IsSelected= renderProperties.isSelected(); // Define Geometry's property if(!GLC_State::isInSelectionMode()) { glPropGeom(renderProperties); } glDraw(renderProperties); m_IsSelected= false; m_GeometryIsValid= true; // OpenGL error handler GLenum error= glGetError(); if (error != GL_NO_ERROR) { GLC_OpenGlException OpenGlException("GLC_Geometry::glExecute " + name(), error); throw(OpenGlException); } } }