Esempio n. 1
0
void ConeNode::glRenderAction(GLRenderState& renderState) const
	{
	/* Set up OpenGL state: */
	renderState.enableCulling(GL_BACK);
	
	/* Render the display list: */
	DisplayList::glRenderAction(renderState.contextData);
	}
Esempio n. 2
0
void QuadSetNode::glRenderAction(GLRenderState& renderState) const
	{
	/* Bail out if there are less than 4 points: */
	if(coord.getValue()==0||coord.getValue()->point.getNumValues()<4)
		return;
	
	/* Set up OpenGL state: */
	renderState.enableCulling(GL_BACK);
	
	/* Render the quad set: */
	size_t numPoints=coord.getValue()->point.getNumValues();
	glBegin(GL_QUADS);
	std::vector<Vector>::const_iterator qnIt=quadNormals.begin();
	for(size_t q=0;q+4<=numPoints;q+=4,++qnIt)
		{
		/* Get the quad's four corner points in counter-clockwise order: */
		Point ps[4];
		if(ccw.getValue())
			{
			for(size_t i=0;i<4;++i)
				ps[i]=coord.getValue()->point.getValue(q+i);
			}
		else
			{
			for(size_t i=0;i<4;++i)
				ps[i]=coord.getValue()->point.getValue(q+3-i);
			}
		
		if(pointTransform.getValue()!=0)
			{
			/* Transform the quad's corner points: */
			for(int i=0;i<4;++i)
				ps[i]=pointTransform.getValue()->transformPoint(ps[i]);
			}
		
		/* Draw the quad's front: */
		glNormal(*qnIt);
		for(int i=0;i<4;++i)
			{
			glTexCoord(quadTexCoords[i]);
			glVertex(ps[i]);
			}
		
		if(!solid.getValue())
			{
			/* Draw the quad's back: */
			glNormal(-*qnIt);
			for(int i=3;i>=0;--i)
				{
				glTexCoord(quadTexCoords[i]);
				glVertex(ps[i]);
				}
			}
		}
	glEnd();
	}
Esempio n. 3
0
void LODSphereNode::glRenderAction(GLRenderState& renderState) const
{
  Scalar current_ratio = Geometry::sqrDist(renderState.getViewerPos(), Point::origin) / radius.getValue();
  renderState.enableCulling(GL_BACK);
  if (detail.getNumValues() == 1) {
    spheres.front()->glRenderAction(renderState.contextData);
  } else {
    std::vector<LODSphereNodeDisplayList*>::const_reverse_iterator sphere = spheres.rbegin();
    MFFloat::ValueList::const_reverse_iterator ratio = lodRatio.getValues().rbegin();
    while (sphere != spheres.rend() && ratio != lodRatio.getValues().rend()) {
      if (current_ratio < *ratio) break;
      ++sphere; ++ratio;
    }
    (*sphere)->glRenderAction(renderState.contextData);
  }
}
void VectorEvaluationLocator::highlightLocator(GLRenderState& renderState) const
	{
	/* Call the base class method: */
	EvaluationLocator::highlightLocator(renderState);
	
	/* Render the evaluated vector value if valid: */
	if(valueValid)
		{
		/* Set up OpenGL state for arrow rendering: */
		renderState.enableCulling(GL_BACK);
		renderState.setLighting(true);
		renderState.setTwoSidedLighting(false);
		glColor((*colorMap)(currentScalarValue));
		renderState.enableColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
		renderState.setTextureLevel(0);
		renderState.setSeparateSpecularColor(false);
		
		/* Render an arrow glyph: */
		Scalar arrowShaftRadius=Scalar((Vrui::Scalar(0.5)*Vrui::getUiSize())/Vrui::getNavigationTransformation().getScaling());
		Visualization::Wrappers::renderArrow(point,currentValue*arrowLengthScale,arrowShaftRadius,arrowShaftRadius*Scalar(3),arrowShaftRadius*Scalar(6),16);
		}
	}
Esempio n. 5
0
void QuadSetNode::glRenderAction(GLRenderState& renderState) const
	{
	/* Bail out if there are no complete quads: */
	if(numQuads==0)
		return;
	
	/* Set up OpenGL state: */
	if(solid.getValue())
		renderState.enableCulling(GL_BACK);
	else
		renderState.disableCulling();
	
	/* Get the context data item: */
	DataItem* dataItem=renderState.contextData.retrieveDataItem<DataItem>(this);
	
	if(dataItem->vertexBufferObjectId!=0&&dataItem->indexBufferObjectId!=0)
		{
		typedef GLGeometry::Vertex<Scalar,2,void,0,Scalar,Scalar,3> Vertex; // Type for vertices
		typedef GLuint Index; // Type for vertex indices
		
		/* Bind the quad set's vertex and index buffer objects: */
		glBindBufferARB(GL_ARRAY_BUFFER_ARB,dataItem->vertexBufferObjectId);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,dataItem->indexBufferObjectId);
		
		/* Check if the vertex or index buffers are outdated: */
		if(dataItem->version!=version)
			{
			/* Upload the quad set's new vertices: */
			uploadQuads(dataItem);
			dataItem->version=version;
			}
		
		/* Set up the vertex arrays: */
		GLVertexArrayParts::enable(Vertex::getPartsMask());
		glVertexPointer(static_cast<Vertex*>(0));
		
		/* Render the quad set: */
		if(subdivideX.getValue()>1||subdivideY.getValue()>1)
			{
			/* Draw a set of quad strips: */
			const Index* indexPtr=0;
			for(unsigned int strip=0;strip<numQuads*subdivideY.getValue();++strip,indexPtr+=(subdivideX.getValue()+1)*2)
				glDrawElements(GL_QUAD_STRIP,(subdivideX.getValue()+1)*2,GL_UNSIGNED_INT,indexPtr);
			}
		else
			{
			/* Draw all quads in one go: */
			glDrawArrays(GL_QUADS,0,numQuads*4);
			}
		
		/* Reset the vertex arrays: */
		GLVertexArrayParts::disable(Vertex::getPartsMask());
		
		/* Protect the buffers: */
		glBindBufferARB(GL_ARRAY_BUFFER_ARB,0);
		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
		}
	else
		{
		/* If your OpenGL can't do vertex buffers, you're f****d anyway. */
		}
	}