本文整理汇总了C#中OpenGL.LineWidth方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.LineWidth方法的具体用法?C# OpenGL.LineWidth怎么用?C# OpenGL.LineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGL
的用法示例。
在下文中一共展示了OpenGL.LineWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDisplayList
/// <summary>
/// Creates the display list. This function draws the
/// geometry as well as compiling it.
/// </summary>
private void CreateDisplayList(OpenGL gl)
{
// Create the display list.
displayList = new DisplayList();
// Generate the display list and
displayList.Generate(gl);
displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);
// Push attributes, set the color.
gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
OpenGL.GL_LINE_BIT);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.LineWidth(1.0f);
// Draw the grid lines.
gl.Begin(OpenGL.GL_LINES);
for (int i = -10; i <= 10; i++)
{
float fcol = ((i % 10) == 0) ? 0.3f : 0.15f;
gl.Color(fcol, fcol, fcol);
gl.Vertex(i, -10, 0);
gl.Vertex(i, 10, 0);
gl.Vertex(-10, i, 0);
gl.Vertex(10, i, 0);
}
gl.End();
// Restore attributes.
gl.PopAttrib();
// End the display list.
displayList.End(gl);
}
示例2: CreateDisplayList
/// <summary>
/// Creates the display list. This function draws the
/// geometry as well as compiling it.
/// </summary>
private void CreateDisplayList(OpenGL gl)
{
// Create the display list.
displayList = new DisplayList();
// Generate the display list and
displayList.Generate(gl);
displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);
// Push all attributes, disable lighting and depth testing.
gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.DepthFunc(OpenGL.GL_ALWAYS);
// Set a nice fat line width.
gl.LineWidth(1.50f);
// Draw the axies.
gl.Begin(OpenGL.GL_LINES);
gl.Color(1f, 0f, 0f, 1f);
gl.Vertex(0, 0, 0);
gl.Vertex(3, 0, 0);
gl.Color(0f, 1f, 0f, 1f);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 3, 0);
gl.Color(0f, 0f, 1f, 1f);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 0, 3);
gl.End();
// Restore attributes.
gl.PopAttrib();
// End the display list.
displayList.End(gl);
}
示例3: DrawGrid
public virtual void DrawGrid(OpenGL gl)
{
gl.PushAttrib(OpenGL.LINE_BIT | OpenGL.ENABLE_BIT | OpenGL.COLOR_BUFFER_BIT);
// Turn off lighting, set up some nice anti-aliasing for lines.
gl.Disable(OpenGL.LIGHTING);
gl.Hint(OpenGL.LINE_SMOOTH_HINT, OpenGL.NICEST);
gl.Enable(OpenGL.LINE_SMOOTH);
gl.Enable(OpenGL.BLEND);
gl.BlendFunc(OpenGL.SRC_ALPHA, OpenGL.ONE_MINUS_SRC_ALPHA);
// Create the grid.
gl.LineWidth(1.5f);
gl.Begin(OpenGL.LINES);
for (int i = -10; i <= 10; i++)
{
gl.Color(0.2f, 0.2f, 0.2f, 1f);
gl.Vertex(i, 0, -10);
gl.Vertex(i, 0, 10);
gl.Vertex(-10, 0, i);
gl.Vertex(10, 0, i);
}
gl.End();
// Turn off the depth test for the axies.
gl.Disable(OpenGL.DEPTH_TEST);
gl.LineWidth(2.0f);
// Create the axies.
gl.Begin(OpenGL.LINES);
gl.Color(1f, 0f, 0f, 1f);
gl.Vertex(0f, 0f, 0f);
gl.Vertex(3f, 0f, 0f);
gl.Color(0f, 1f, 0f, 1f);
gl.Vertex(0f, 0f, 0f);
gl.Vertex(0f, 3f, 0f);
gl.Color(0f, 0f, 1f, 1f);
gl.Vertex(0f, 0f, 0f);
gl.Vertex(0f, 0f, 3f);
gl.End();
gl.PopAttrib();
// gl.Flush();
}
示例4: Create
/// <summary>
/// This function creates the internal display lists.
/// </summary>
/// <param name="gl">OpenGL object.</param>
public virtual void Create(OpenGL gl)
{
// Create the arrow.
arrow.Generate(gl);
arrow.New(gl, DisplayList.DisplayListMode.Compile);
// Draw the 'line' of the arrow.
gl.Begin(OpenGL.LINES);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 0, 1);
gl.End();
// Draw the arrowhead.
gl.Begin(OpenGL.TRIANGLE_FAN);
gl.Vertex(0, 0, 1);
gl.Vertex(0.2f, 0.8f, 0.2f);
gl.Vertex(0.2f, 0.8f, -0.2f);
gl.Vertex(-0.2f, 0.8f, -0.2f);
gl.Vertex(-0.2f, 0.8f, 0.2f);
gl.End();
// End the arrow list.
arrow.End(gl);
// Create the grid.
grid.Generate(gl);
grid.New(gl, DisplayList.DisplayListMode.Compile);
gl.PushAttrib(OpenGL.LIGHTING_BIT);
gl.Disable(OpenGL.LIGHTING);
gl.Color(1, 1, 1);
gl.Begin(OpenGL.LINES);
for(int i = -10; i <= 10; i++)
{
gl.Vertex(i, 0, -10);
gl.Vertex(i, 0, 10);
gl.Vertex(-10, 0, i);
gl.Vertex(10, 0, i);
}
gl.End();
gl.PopAttrib();
grid.End(gl);
// Create the axies.
axies.Generate(gl);
axies.New(gl, DisplayList.DisplayListMode.Compile);
gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);
gl.Disable(OpenGL.LIGHTING);
gl.Disable(OpenGL.DEPTH_TEST);
gl.LineWidth(2.0f);
gl.Begin(OpenGL.LINES);
gl.Color(1, 0, 0, 1);
gl.Vertex(0, 0, 0);
gl.Vertex(3, 0, 0);
gl.Color(0, 1, 0, 1);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 3, 0);
gl.Color(0, 0, 1, 1);
gl.Vertex(0, 0, 0);
gl.Vertex(0, 0, 3);
gl.End();
gl.PopAttrib();
axies.End(gl);
camera.Generate(gl);
camera.New(gl, DisplayList.DisplayListMode.Compile);
Polygon poly = new Polygon();
poly.CreateCube();
poly.Scale.Set(.2f ,0.2f, 0.2f);
poly.Draw(gl);
// poly.Dispose();
camera.End(gl);
}
示例5: Render
/// <summary>
/// Render to the provided instance of OpenGL.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
/// <param name="renderMode">The render mode.</param>
public void Render(OpenGL gl, RenderMode renderMode)
{
// Push attributes, disable lighting.
gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
OpenGL.GL_LINE_BIT | OpenGL.GL_POLYGON_BIT);
gl.Disable(OpenGL.GL_LIGHTING);
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.LineWidth(1.0f);
gl.Color(1f, 0.2f, 0.2f, 0.6f);
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK,
renderMode == RenderMode.HitTest ? (uint)PolygonMode.Filled : (uint)PolygonMode.Lines);
gl.Begin(OpenGL.GL_QUADS); // Draw The Cube Using quads
gl.Vertex(hhl); // Top Right Of The Quad (Top)
gl.Vertex(lhl); // Top Left Of The Quad (Top)
gl.Vertex(lhh); // Bottom Left Of The Quad (Top)
gl.Vertex(hhh); // Bottom Right Of The Quad (Top)
gl.Vertex(hlh); // Top Right Of The Quad (Bottom)
gl.Vertex(llh); // Top Left Of The Quad (Bottom)
gl.Vertex(lll); // Bottom Left Of The Quad (Bottom)
gl.Vertex(hll); // Bottom Right Of The Quad (Bottom)
gl.Vertex(hhh); // Top Right Of The Quad (Front)
gl.Vertex(lhh); // Top Left Of The Quad (Front)
gl.Vertex(llh); // Bottom Left Of The Quad (Front)
gl.Vertex(hlh); // Bottom Right Of The Quad (Front)
gl.Vertex(hll); // Top Right Of The Quad (Back)
gl.Vertex(lll); // Top Left Of The Quad (Back)
gl.Vertex(lhl); // Bottom Left Of The Quad (Back)
gl.Vertex(hhl); // Bottom Right Of The Quad (Back)
gl.Vertex(lhh); // Top Right Of The Quad (Left)
gl.Vertex(lhl); // Top Left Of The Quad (Left)
gl.Vertex(lll); // Bottom Left Of The Quad (Left)
gl.Vertex(llh); // Bottom Right Of The Quad (Left)
gl.Vertex(hhl); // Top Right Of The Quad (Right)
gl.Vertex(hhh); // Top Left Of The Quad (Right)
gl.Vertex(hlh); // Bottom Left Of The Quad (Right)
gl.Vertex(hll); // Bottom Right Of The Quad (Right)
gl.End(); // End Drawing The Cube
// Pop attributes.
gl.PopAttrib();
}
示例6: SetAttributes
/// <summary>
/// Sets the attributes.
/// </summary>
/// <param name="gl">The OpenGL instance.</param>
public override void SetAttributes(OpenGL gl)
{
if(width.HasValue) gl.LineWidth(width.Value);
if(smooth.HasValue) gl.EnableIf(OpenGL.GL_LINE_SMOOTH, smooth.Value);
}
示例7: 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();
}
示例8: Set
public override void Set(OpenGL gl)
{
base.Set(gl);
// Save the current attributes.
gl.PushAttrib(AttributeBit);
gl.LineWidth(width);
gl.EnableIf(OpenGL.LINE_SMOOTH, smooth);
}