本文整理汇总了C#中SharpGL.OpenGL.Disable方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.Disable方法的具体用法?C# OpenGL.Disable怎么用?C# OpenGL.Disable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.Disable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDisplayList
private void CreateDisplayList(OpenGL gl)
{
displayList = new DisplayList();
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 line width.
gl.LineWidth(lineWidth);
//Draw the line.
gl.Begin(OpenGL.GL_LINES);
gl.Color(Convert.ColorToGLColor(c1));
gl.Vertex(v1.X, v1.Y, v1.Z);
gl.Color(Convert.ColorToGLColor(c2));
gl.Vertex(v2.X, v2.Y, v2.Z);
gl.End();
// Restore attributes.
gl.PopAttrib();
displayList.End(gl);
}
示例2: InitShader
void IRenderable.Render(OpenGL gl, RenderMode renderMode)
{
if (positionBuffer != null && colorBuffer != null && radiusBuffer != null)
{
if (this.shaderProgram == null)
{
this.shaderProgram = InitShader(gl, renderMode);
}
if (this.vertexArrayObject == null)
{
CreateVertexArrayObject(gl, renderMode);
}
BeforeRendering(gl, renderMode);
if (this.RenderGrid && this.vertexArrayObject != null)
{
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(this.vertexArrayObject[0]);
gl.DrawArrays(OpenGL.GL_POINTS, 0, count);
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
}
AfterRendering(gl, renderMode);
}
}
示例3: CreateDisplayList
private void CreateDisplayList(OpenGL gl)
{
displayList = new DisplayList();
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 line width.
gl.LineWidth(lineWidth);
//Draw the line.
gl.Begin(OpenGL.GL_LINES);
for (float i = (size * -1); i < size; i+=0.4f)
{
float add = 0.2f;
if (i > 0) add = 0.4f;
if (i < 0 && i > -0.2f) add = 0.4f;
gl.Color(1f, 0f, 0f, 1f);
gl.Vertex(i, 0, 0);
gl.Vertex(i + add, 0, 0);
gl.Color(0f, 1f, 0f, 1f);
gl.Vertex(0, i, 0);
gl.Vertex(0, i + add, 0);
gl.Color(0f, 0f, 1f, 1f);
gl.Vertex(0, 0, i);
gl.Vertex(0, 0, i + add);
}
gl.End();
// Restore attributes.
gl.PopAttrib();
displayList.End(gl);
}
示例4: CreateDisplayList
private void CreateDisplayList(OpenGL gl)
{
displayList = new DisplayList();
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 line width.
gl.LineWidth(lineWidth);
//Draw the line.
gl.Begin(OpenGL.GL_LINES);
for (int i = (size * -1); i <= size; i++)
{
if (i != 0)
{
if ((i % 4) == 0)
gl.Color(Convert.ColorToGLColor(darkColor));
else
gl.Color(Convert.ColorToGLColor(lightColor));
gl.Vertex(i, (size * -1), 0);
gl.Vertex(i, size, 0);
gl.Vertex((size * -1), i, 0);
gl.Vertex(size, i, 0);
}
}
gl.End();
// Restore attributes.
gl.PopAttrib();
displayList.End(gl);
}
示例5: Draw
public override void Draw(ref OpenGL gl)
{
if (!TexturesInitialised)
{
InitializeTexture(ref gl);
}
// Clear the color and depth buffer.
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
// Load the identity matrix.
gl.LoadIdentity();
gl.Enable(OpenGL.GL_TEXTURE_2D);
gl.Enable(OpenGL.GL_LIGHTING);
gl.Enable(OpenGL.GL_LIGHT0);
gl.Enable(OpenGL.GL_DEPTH_TEST);
gl.Enable(OpenGL.GL_NORMALIZE);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, gtexture[0]);
gl.Color(1.0f, 1.0f, 1.0f, 0.1f);
gl.Begin(OpenGL.GL_QUADS);
gl.FrontFace(OpenGL.GL_FRONT_FACE);
gl.TexCoord(1.0f, 1.0f);
gl.Vertex(gImage1.Width, gImage1.Height, 1.0f);
gl.TexCoord(0.0f, 1.0f);
gl.Vertex(0.0f, gImage1.Height, 1.0f);
gl.TexCoord(0.0f, 0.0f);
gl.Vertex(0.0f, 0.0f, 1.0f);
gl.TexCoord(1.0f, 0.0f);
gl.Vertex(gImage1.Width, 0.0f, 1.0f);
gl.End();
gl.Disable(OpenGL.GL_TEXTURE_2D);
gl.MatrixMode(OpenGL.GL_PROJECTION);
gl.LoadIdentity();
gl.Ortho(0.0, (double)gImage1.Width, (double)gImage1.Height, 0.0, -1.0, 1.0);
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.Disable(OpenGL.GL_DEPTH_TEST);
}
示例6: Resized
//Handles the Resized event of the openGLControl1 control
private void Resized(ref OpenGL gl, double Width, double Height)
{
// Set the projection matrix.
gl.MatrixMode(OpenGL.GL_PROJECTION);
// Load the identity.
gl.LoadIdentity();
if (!TexturesInitialised)
{
gl.Ortho(-1, 1, -1, 1, -1, 1);
}
else
{
gl.Ortho(0, gImage1.Width, gImage1.Height, 0, -1, 1);
}
gl.MatrixMode(OpenGL.GL_MODELVIEW);
gl.Disable(OpenGL.GL_DEPTH_TEST);
// Create a perspective transformation.
gl.Perspective(45.0f, (double)Width / (double)Height, 1.0, 1000.0);
gl.Viewport(0, 0, (int)Width, (int)Height);
// Use the 'look at' helper function to position and aim the camera.
gl.LookAt(-5, 5, -5, 0, 0, 0, 0, 1, 0);
// Set the modelview matrix.
gl.MatrixMode(OpenGL.GL_MODELVIEW);
}
示例7: RecursiveRender
private void RecursiveRender(Assimp.Scene scene, Node node, ref OpenGL gl)
{
Matrix4 m = FromMatrix(node.Transform);
m.Transpose();
gl.PushMatrix();
gl.MultMatrix(FloatFromMatrix(m));
if (node.HasMeshes)
{
foreach (int index in node.MeshIndices)
{
Mesh mesh = scene.Meshes[index];
ApplyMaterial(m_model.Materials[mesh.MaterialIndex], ref gl);
if (mesh.HasNormals)
{
gl.Enable(OpenGL.GL_LIGHTING);
}
else
{
gl.Disable(OpenGL.GL_LIGHTING);
}
bool hasColors = mesh.HasVertexColors(0);
if (hasColors)
{
gl.Enable(OpenGL.GL_COLOR_MATERIAL);
}
else
{
gl.Disable(OpenGL.GL_COLOR_MATERIAL);
}
bool hasTexCoords = mesh.HasTextureCoords(0);
foreach (Assimp.Face face in mesh.Faces)
{
BeginMode faceMode;
switch (face.IndexCount)
{
case 1:
faceMode = BeginMode.Points;
break;
case 2:
faceMode = BeginMode.Lines;
break;
case 3:
faceMode = BeginMode.Triangles;
break;
default:
faceMode = BeginMode.Polygon;
break;
}
gl.Begin(faceMode);
for (int i = 0; i < face.IndexCount; i++)
{
int indice = face.Indices[i];
if (hasColors)
{
Color4 vertColor = FromColor(mesh.VertexColorChannels[0][indice]);
if (mesh.HasNormals)
{
Vector3 normal = FromVector(mesh.Normals[indice]);
gl.Normal(normal.X, normal.Y, normal.Z);
}
if (hasTexCoords)
{
Vector3 uvw = FromVector(mesh.TextureCoordinateChannels[0][indice]);
gl.TexCoord(uvw.X, 1 - uvw.Y);
}
Vector3 pos = FromVector(mesh.Vertices[indice]);
gl.Vertex(pos.X, pos.Y, pos.Z);
}
gl.End();
}
}
}
for (int i = 0; i < node.ChildCount; i++)
{
RecursiveRender(m_model, node.Children[i], ref gl);
}
}
}
示例8: DrawMesh
/// <summary>
/// Draw a mesh.
/// </summary>
/// <param name="gl">OpenGL handler.</param>
/// <param name="buildingObj">The mesh.</param>BuildingObjectLib3DS _object,
private void DrawMesh(OpenGL gl, Lib3dsMesh thisMesh, Hashtable textures, List<Lib3dsMaterial> matrials, DrawType type)
{
if (thisMesh == null || thisMesh.nfaces == 0)
return;
// Draw all the faces in this mesh.
for (int j = 0; j < thisMesh.faces.Count; j++)
{
Lib3dsFace thisFace = thisMesh.faces[j];
float transparency = matrials[thisFace.material].transparency;
//float[] fogColor = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
//float[] LightAmbient = new float[4] { 0.5f, 0.5f, 0.5f, 1.0f };
//float[] LightDiffuse = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f };
//float[] LightPosition = new float[4] { 0.0f, 0.0f, 2.0f, 1.0f };
switch (type)
{
case DrawType.WireFrame:
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_LINE);
IsDrawTexture = false;
gl.Color(0.5f, 0.5f, 0.5f, 0.5f);
gl.LineWidth(1.5f);
break;
case DrawType.Full:
IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
break;
case DrawType.Face:
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
IsDrawTexture = false;
break;
case DrawType.Translucent:
IsDrawTexture = BindTexture(gl, textures, matrials[thisFace.material].name);
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(OpenGL.GL_SRC_ALPHA,OpenGL.GL_ONE_MINUS_SRC_ALPHA);
//gl.Enable(OpenGL.GL_TEXTURE_2D); // Enable Texture Mapping
//gl.ShadeModel(OpenGL.GL_SMOOTH); // Enable Smooth Shading
//gl.ClearColor(0.5f,0.5f,0.5f,1.0f); // We'll Clear To The Color Of The Fog
//gl.ClearDepth(1.0f); // Depth Buffer Setup
//gl.Enable(OpenGL.GL_DEPTH_TEST); // Enables Depth Testing
//gl.DepthFunc(OpenGL.GL_LEQUAL); // The Type Of Depth Testing To Do
//gl.Hint(OpenGL.GL_PERSPECTIVE_CORRECTION_HINT, OpenGL.GL_NICEST); // Really Nice Perspective Calculations
//gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_AMBIENT, LightAmbient); // Setup The Ambient Light
//gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
//gl.Light(OpenGL.GL_LIGHT1, OpenGL.GL_POSITION,LightPosition); // Position The Light
//gl.Enable(OpenGL.GL_LIGHT1);
//gl.Fog(OpenGL.GL_FOG_COLOR, fogColor);//设置雾颜色,f是一个指定颜色的数组float f[4]
//gl.Fog(OpenGL.GL_FOG_DENSITY, 0.85f); // 设置雾的密度
//gl.Hint(OpenGL.GL_FOG_HINT, OpenGL.GL_DONT_CARE); // 设置系统如何计算雾气
//gl.Fog(OpenGL.GL_FOG_START, 0.01f);//设置雾从多远开始
//gl.Fog(OpenGL.GL_FOG_END, 100.0f);//设置雾从多远结束
//gl.Fog(OpenGL.GL_FOG_MODE, OpenGL.GL_LINEAR);//设置使用哪种雾,共有三中雾化模式
//gl.Enable(OpenGL.GL_FOG);//打开雾效果
transparency = 0.2f;
break;
default:
gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
IsDrawTexture = false;
break;
}
if (type != DrawType.WireFrame)
{
gl.Color(matrials[thisFace.material].diffuse[0], matrials[thisFace.material].diffuse[1],
matrials[thisFace.material].diffuse[2], matrials[thisFace.material].transparency);
}
gl.Begin(OpenGL.GL_TRIANGLES);
for (int k = 0; k != 3; ++k)
{
int index = thisFace.index[k];
if (IsDrawTexture)
gl.TexCoord(thisMesh.texcos[index].s, thisMesh.texcos[index].t);
gl.Vertex(thisMesh.vertices[index].x / 20, thisMesh.vertices[index].z / 20, -thisMesh.vertices[index].y / 20);
}
gl.End();
if(type == DrawType.Translucent)
gl.Disable(OpenGL.GL_BLEND);
}
}
示例9: AfterRendering
protected void AfterRendering(OpenGL gl, RenderMode renderMode)
{
shaderProgram.Unbind(gl);
gl.Disable(OpenGL.GL_BLEND);
gl.Disable(OpenGL.GL_VERTEX_PROGRAM_POINT_SIZE);
gl.Disable(OpenGL.GL_POINT_SPRITE_ARB);
gl.Disable(OpenGL.GL_POINT_SMOOTH);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
}
示例10: foreach
/// <summary>
/// This is called when a face is interactable, so highlight it.
/// </summary>
void IInteractable.DrawPick(OpenGL gl)
{
// Save all the attributes.
gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);
// Disable lighting, set colour to red etc.
gl.Disable(OpenGL.LIGHTING);
gl.DepthFunc(OpenGL.LEQUAL);
// Now draw it with a faint red.
gl.Enable(OpenGL.BLEND);
gl.BlendFunc(OpenGL.SRC_ALPHA, OpenGL.ONE_MINUS_SRC_ALPHA);
gl.Color(1, 0, 0, 0.2f);
// Draw the face.
gl.Begin(OpenGL.POLYGON);
foreach(Index index in indices)
gl.Vertex(parentpoly.Vertices[index.Vertex]);
gl.End();
gl.Disable(OpenGL.BLEND);
// Draw the face.
gl.Begin(OpenGL.LINE_LOOP);
for(int i = 0; i < indices.Count - 1; i++)
gl.Vertex(parentpoly.Vertices[indices[i].Vertex]);
gl.End();
gl.PopAttrib();
}
示例11: DoRenderMatrix
/// <summary>
/// 渲染基质
/// </summary>
/// <param name="gl"></param>
/// <param name="renderMode"></param>
private void DoRenderMatrix(OpenGL gl, RenderMode renderMode)
{
if (this.positionBuffer == null || this.colorBuffer == null) { return; }
if (this.RenderGrid && this.matrixVertexArrayObject != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);
shaderProgram.SetUniform1(gl, "opacity", this.Opacity);
gl.Enable(OpenGL.GL_POLYGON_OFFSET_FILL);
gl.PolygonOffset(1.0f, 1.0f);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(matrixVertexArrayObject[0]);
switch (this.MatrixType)
{
case MatrixFormat.Triangle:
gl.DrawArrays(this.matrixRenderMode, 0, this.MatrixVertexOrIndexCount);
break;
case MatrixFormat.Tetrahedron:
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
break;
case MatrixFormat.TriangularPrism:
// 先渲染三棱柱的上下三角形
gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.MatrixVertexOrIndexCount);
// 再渲染三棱柱的三个侧面
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
break;
default:
break;
}
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
gl.Disable(OpenGL.GL_POLYGON_OFFSET_FILL);
}
if (this.RenderGridWireframe && this.matrixVertexArrayObject != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);
shaderProgram.SetUniform1(gl, "opacity", this.Opacity);
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);
gl.Enable(OpenGL.GL_BLEND);
gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);
gl.BindVertexArray(matrixVertexArrayObject[0]);
switch (this.MatrixType)
{
case MatrixFormat.Triangle:
gl.DrawArrays(this.matrixRenderMode, 0, this.MatrixVertexOrIndexCount);
break;
case MatrixFormat.Tetrahedron:
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
break;
case MatrixFormat.TriangularPrism:
// 先渲染三棱柱的上下三角形
gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.MatrixVertexOrIndexCount / 9 * 6);
// 再渲染三棱柱的三个侧面
gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
gl.PrimitiveRestartIndex(uint.MaxValue);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
break;
default:
break;
}
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_BLEND);
}
}
示例12: DoRenderFraction
private void DoRenderFraction(OpenGL gl, RenderMode renderMode)
{
if (this.fractionPositionBuffer == null || this.fractionUVBuffer == null) { return; }
if (this.RenderFraction && this.fractionVertexArrayObject != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);
gl.Enable(OpenGL.GL_POLYGON_OFFSET_FILL);
gl.PolygonOffset(1.0f, 1.0f);
gl.BindVertexArray(fractionVertexArrayObject[0]);
switch (this.FractionType)
{
case FractureFormat.Line:
float[] originalWidth = new float[1];
gl.GetFloat(SharpGL.Enumerations.GetTarget.LineWidth, originalWidth);
gl.LineWidth(this.FractionLineWidth);
gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);
gl.LineWidth(originalWidth[0]);
break;
case FractureFormat.Triange:
gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
break;
case FractureFormat.Quad:
gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
break;
default:
throw new NotImplementedException();
//break;
}
gl.BindVertexArray(0);
gl.Disable(OpenGL.GL_POLYGON_OFFSET_FILL);
}
if (this.renderFractionWireframe && this.fractionVertexArrayObject != null)
{
shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);
gl.BindVertexArray(fractionVertexArrayObject[0]);
{
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);
switch (this.FractionType)
{
case FractureFormat.Line:
gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);
break;
case FractureFormat.Triange:
gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
break;
case FractureFormat.Quad:
gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
break;
default:
break;
}
gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
}
gl.BindVertexArray(0);
}
}
示例13: OnRender
public override void OnRender(OpenGL gl)
{
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.ClearColor(0.137f, 0.121f, 0.125f, 0f);
_graph.Render();
gl.Disable(OpenGL.GL_DEPTH_TEST);
using (new Bind(_shader))
{
gl.UniformMatrix4(_modelUniform, 1, false, Mat4.Identity.ToColumnMajorArray());
gl.PointSize(10f);
gl.Begin(BeginMode.Points);
gl.Vertex(6, 0);
gl.End();
}
gl.PointSize(5f);
_points.Render();
gl.Enable(OpenGL.GL_DEPTH_TEST);
}
示例14: AfterRendering
protected void AfterRendering(OpenGL gl, RenderMode renderMode)
{
gl.Disable(OpenGL.GL_POLYGON_SMOOTH);
shaderProgram.Unbind(gl);
gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
gl.Disable(OpenGL.GL_TEXTURE_2D);
}
示例15: 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.ALL_ATTRIB_BITS);
gl.Disable(OpenGL.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++);
((IInteractable)v).DrawPick(gl);
}
// Pop the name.
gl.PopName();
}
if(lines)
{
// Draw lines along each row, then along each column.
gl.DepthFunc(OpenGL.ALWAYS);
gl.LineWidth(1);
gl.Disable(OpenGL.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.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.LESS);
}
gl.PopAttrib();
}