本文整理汇总了C#中OpenGL.PushName方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.PushName方法的具体用法?C# OpenGL.PushName怎么用?C# OpenGL.PushName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL
的用法示例。
在下文中一共展示了OpenGL.PushName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// This function draws the polygon.
/// </summary>
/// <param name="gl">OpenGL.</param>
public override void Draw(OpenGL gl)
{
if(DoPreDraw(gl))
{
polyAttributes.Set(gl);
foreach(Face face in faces)
{
// Begin drawing a polygon.
if(face.Indices.Count == 2)
gl.Begin(OpenGL.LINES);
else
gl.Begin(OpenGL.POLYGON);
foreach(Index index in face.Indices)
{
// Set a texture coord (if any).
if(index.UV != -1)
gl.TexCoord(uvs[index.UV]);
// Set a normal, or generate one.
if(index.Normal != -1)
gl.Normal(normals[index.Normal]);
else
{
// Do we have enough vertices for a normal?
if(face.Indices.Count >= 3)
{
// Create a normal.
Vertex vNormal = face.GetSurfaceNormal(this);
vNormal.UnitLength();
// Add it to the normals, setting the index for next time.
index.Normal = normals.Add(new Normal(vNormal));
gl.Normal(vNormal);
}
}
// Set the vertex.
gl.Vertex(vertices[index.Vertex]);
}
gl.End();
}
// If the current context is edit vertices, draw the vertices.
if(currentContext == Context.EditVertices)
{
// Push all the attributes.
gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);
// Set the colour to red, large points, no lighting.
gl.Color(1, 0, 0, 1);
gl.PointSize(5);
gl.Disable(OpenGL.LIGHTING);
// Draw the control points.
for(int point = 0; point < vertices.Count; point++)
{
// Name the point, then draw it.
gl.PushName((uint)point);
gl.Begin(OpenGL.POINTS);
gl.Vertex(vertices[point]);
gl.End();
gl.PopName();
}
// Restore the attributes.
gl.PopAttrib();
}
// If the current context is edit normals, draw the normals.
if(currentContext == Context.EditNormals)
{
// We're going to disable lighting.
Attributes.Lighting lighting = new Attributes.Lighting();
lighting.Enable = false;
lighting.Set(gl);
gl.Color(1, 0, 0);
gl.Begin(OpenGL.LINES);
// Draw the normals points.
foreach(Face face in faces)
{
foreach(Index index in face.Indices)
{
if(index.Normal == -1)
continue;
// Translate to that vertex.
Vertex v = vertices[index.Vertex];
gl.PushName((uint)index.Normal);
gl.Vertex(v);
gl.Vertex(v + normals[index.Normal]);
//.........这里部分代码省略.........
示例2: Draw
/// <summary>
/// Use this to draw the vertex grid.
/// </summary>
/// <param name="gl">OpenGL object.</param>
/// <param name="points">Draw each individual vertex (with selection names).</param>
/// <param name="lines">Draw the lines connecting the points.</param>
public virtual void Draw(OpenGL gl, bool points, bool lines)
{
// Save the attributes.
gl.PushAttrib(OpenGL.GL_ALL_ATTRIB_BITS);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Color(1, 0, 0, 1);
if(points)
{
int name = 0;
gl.PointSize(5);
// Add a new name (the vertex name).
gl.PushName(0);
foreach(Vertex v in vertices)
{
// Set the name, draw the vertex.
gl.LoadName((uint)name++);
//todo draw vertex
//((IInteractable)v).DrawPick(gl);
}
// Pop the name.
gl.PopName();
}
if(lines)
{
// Draw lines along each row, then along each column.
gl.DepthFunc(OpenGL.GL_ALWAYS);
gl.LineWidth(1);
gl.Disable(OpenGL.GL_LINE_SMOOTH);
for(int col=0; col < y; col++)
{
for(int row=0; row < x; row++)
{
// Create vertex indicies.
int nTopLeft = (col * x) + row;
int nBottomLeft = ((col + 1) * x) + row;
gl.Begin(OpenGL.GL_LINES);
if(row < (x-1))
{
gl.Vertex(vertices[nTopLeft]);
gl.Vertex(vertices[nTopLeft + 1]);
}
if(col < (y-1))
{
gl.Vertex(vertices[nTopLeft]);
gl.Vertex(vertices[nBottomLeft]);
}
gl.End();
}
}
gl.DepthFunc(OpenGL.GL_LESS);
}
gl.PopAttrib();
}
示例3: Polygon
void IInteractable.DrawPick(OpenGL gl)
{
if(on)
{
if(DoPreDraw(gl))
{
Polygon poly = new Polygon();
poly.CreateCube();
poly.Scale = new Vertex(0.2f, 0.2f, 0.2f);
poly.Draw(gl);
gl.PushName(0);
gl.Vertex(direction);
gl.PopName();
DoPostDraw(gl);
}
}
}